sdl2 audio infrastructure quesiton for usb audio devices

Folks:

I am on ubuntu linux (22.04). I have a usb camera with a built in microphone.

I want to use the sdl queue ( non callback). I am attempting to use the sdl_dequeue tor retrieve sound for my own buffer.

The purpose of this is for an oscilloscope.

I can open the device okay (no error) for capture.

However my calls to sdl_dequeu constantly return 0.

What I wonder is the sdl2 audio infrastructure okay with usb cameras’ audio device?

Or would I be better off not bothering with the sdl audio infrastructure and go ahead and use the linux also infrastructure?

Thank you
Mark Allyn

Make sure you’ve opened the audio device for recording instead of playback. When calling SDL_OpenAudioDevice() pass a non-zero value for the iscapture parameter.

I did check that. Still nothing was read.

Would you mind to add, just after

SDL_Init(SDL_INIT_AUDIO); 

The following line :

SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());

And tell us what happens ?

If not successfull, I’d suggest to add :

// alsa, or pulse, or whatever audio driver SDL compatible you'd like to use
putenv((char *)"SDL_AUDIODRIVER=alsa");  

before SDL_Init().

HTH

Did you unpause the audio device with SDL_PauseAudioDevice() after opening?

Yes, I did unpause the device.

Mark

Maybe it’s a muted device?
System settings->Sound->Input
Select the USB monitor device.
Make sure the slider is not pulled all the way left.

Double check that it’s drivers are set up properly and working by recording a sample using audacity?

Have you tried unplugging it and plugging it back in?

  • This has been an automated message sent by tech support from the 1990’s. Thank you for holding. Your phone call is very important to us. Please enjoy the sounds of a dial-up modem as you wait for the next available representative.