You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i am using SDL 2.30.0 to implement multiplatform audio capture. But i was surprised when one of the users reported it only works on pulseaudio and pipewire, but not on ALSA: sigrokproject/libsigrok#185
Reason is that SDL_GetAudioDeviceSpec() does not return correct values for ALSA capture device. Only way to get correct specs is by opening the device using SDL_OpenAudioDevice(). Therefore i had to implement following wrapper to get code working on ALSA:
intSDL_GetAudioDeviceSpec_open(intindex, intiscapture, SDL_AudioSpec*spec)
{
//ALSA does not allow to fully read specs of device without opening it.//This wrapper tries to open device when SDL_GetAudioDeviceSpec() incorrectly reports device to have 0 channels.//See https://github.com/libsdl-org/SDL/blob/237348c772b4ff0e758ace83f471dbf8570535e2/src/audio/alsa/SDL_alsa_audio.c#L759intret=SDL_GetAudioDeviceSpec(index, iscapture, spec);
if(!ret&&spec->channels==0) {
printf("Failed SDL_GetAudioDeviceSpec(), trying to open device to get specs.");
SDL_AudioDeviceIDd;
d=SDL_OpenAudioDevice(SDL_GetAudioDeviceName(index, iscapture), iscapture, spec, spec, SDL_AUDIO_ALLOW_ANY_CHANGE);
if(d) SDL_CloseAudioDevice(d);
}
returnret;
}
But i think this is the exact thing that should be handled by SDL, because i use SDL exactly for the reason i don't want to care about any platform-specific hacks in my app. Can you please consider fixing this on SDL side?
Thanks
The text was updated successfully, but these errors were encountered:
Hello, i am using SDL 2.30.0 to implement multiplatform audio capture. But i was surprised when one of the users reported it only works on pulseaudio and pipewire, but not on ALSA: sigrokproject/libsigrok#185
Reason is that
SDL_GetAudioDeviceSpec()
does not return correct values for ALSA capture device. Only way to get correct specs is by opening the device usingSDL_OpenAudioDevice()
. Therefore i had to implement following wrapper to get code working on ALSA:But i think this is the exact thing that should be handled by SDL, because i use SDL exactly for the reason i don't want to care about any platform-specific hacks in my app. Can you please consider fixing this on SDL side?
Thanks
The text was updated successfully, but these errors were encountered: