Inconsistent results (success, failure) when running audioOutputExample

I ran audioOutputExample without problem when I first tried it, but it doesn’t work consistently. For example, after computer restart, the first try at running the example failed, but the second, third, fourth, etc worked. Later on though, it started failing again and now I can never get it to work. I’m not changing anything in the source code so the inconsistencies are due to something else. I think this issue may be related to the sound drivers or to using Rhythmbox or watching videos on youtube between runs. Anyways, I hope there’s a way out of this…

Here are some of the errors I get:

There was an error creating the child process for this terminal

RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (hw:0,0), Device or resource busy.
RtApiAlsa::probeDeviceOpen: pcm device (hw:0,0) won’t open for output.
RtApi:: a stream is not open!

I am running the app with Netbeans 6.8 on Ubuntu 10.04. following these instructions to make it all work:

I’d be happy to show log messages or run tests or whatever else, I’m just not sure what to do to isolate the problem…

Thanks for any help!

Shawn

Definitely sounds like a driver/hardware problem, do you have multiple sound cards installed or anything like that? It might also be that rtAudio isn’t stopping it’s communication with the card properly somehow, though I have no idea how you’d fix that. Arturo will almost certainly know more. You might try uncommenting the line in testApp.cpp that says:

  
//soundStream.listDevices();  

just so you can get the rtError back and see what it might be. The call to snd_pcm_open() inside rtAudio should return an error code that you can look up.

it’s almost sure related to flash getting the device and not allowing rtAudio accessing it. try closing the browser or killing a process called npviewer. also this seems to not happen anymore from 10.10.

Well, I’m finally finished upgrading Ubuntu to 11.04. But now Netbeans is being a real hardass. It fails to load my audioOutputExample project, running textureExample fails with “Illegal instruction”, same for advancedGraphicsExample. BUT, they BOTH work if I UNcheck “Show profiling indicators during run”.

I would like to try this on audioOutputExample, but I can’t get Netbeans to load the project! I even erased the folder in its entirety and re-downloaded it and still, netbeans won’t have it.

Too bad, because until I can get it up and running again, I can’t try Joshua’s suggestions, nor Arturo’s, actually.

Any ideas?

Shawn

Ok, so I started all over again using CodeBlocks. It’s not able to build audioOutputExample either. It says:
cannot find -lopenFrameworksDebug (debug mode)
or
cannot find -lopenFrameworks (release mode)

Basically, it’s the same error I had with netbeans…

Am I missing something obvious?

Shawn

I just made another attempt. I downloaded everything from github, ran install_codeblocks.sh and install_dependencies.sh and tried to build audioOutputExample from within codeblocks (I opened audioOutputExample_linux64.cbp) Now I get the following error:

fatal error: ofTypes.h: No such file or directory

I must be doing something wrong

In codeblocks, I right-clicked the project (audioOutputExample), went to Preferences -> Project’s build options… ->Search directories tab and added
…/…/…/libs/openFrameworks/types
…/…/…/libs/openFrameworks/math
…/…/…/libs/openFrameworks/3d
…/…/…/libs/openFrameworks/gl

They eliminated errors about missing .h files, but now I have
fatal error: tesselator.h: No such file or directory

This time, I can’t find tesselator.h, so I can’t fix it the same way.

Ok so I foud tesselator.h

I added the following to search directories (same fix as above)
…/…/…/libs/tess2/include
…/…/…/libs/kiss/include

And now I’m getting
“ld cannot find -lGLee”
“ld cannot find -loFAppsink”

Well, I have no clue what changed, but I can run the example now and I can reproduce the cases where there is no sound :

In each of the following cases, the sound in audioOutputExample doesn’t work and I get the following error :

RtApiAlsa::getDeviceIno: snd_pcm_open error for device (hw:0,0), Device or resource busy.

RtApiAlsa::probeDeviceOpen: pcm device (hw:0,0) won’t open for output.

RtApi:: a stream is not open!

Process returned 0 (0x0) execution time : 3.462 s
Press ENTER to continue.

… happens when :

Rhythmbox is playing

  • Rhythmbox has played recently (under ~5 seconds ago)

  • Firefox has a tab with Grooveshark, either playing a tune or on pause

  • The Groovshark tab has been recently closed (under ~5 seconds ago)

  • Firefox has a tab with a Youtube Video, either playing or on pause

  • The Youtube tab has been recently closed (under ~5 seconds ago)

The sound DOES work in the following circumstances :

  • Rhythmbox has been set to pause more than ~5 seconds ago

  • Every Grooveshark or Youtube tab having played has been closed more than ~5 seconds ago

Can anybody else reproduce this?

yes it’s a problem with alsa + pulseaudio. unless you go directly through pulseaudio you can only have one stream at the same time. since rtAudio, the library that OF uses for ofSoundStream uses alsa it cannot be used while anything else is using the soundcard. At least now pausing the other apps works before you had to kill flash to be able to use rtAudio

Will using openAL solve my problem?