🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

what this error mean ("Failed to open recording device! SDL Error: Too many open audio devices")

Started by
0 comments, last by tkialwan 4 years, 1 month ago

when I try to run this program I get the error ("Failed to open recording device! SDL Error: Too many open audio devices") why?

this is my program:

SDL_AudioSpec wav_spec;

Uint32 wav_length;

Uint8 *wav_buffer;

SDL_AudioSpec desired;

SDL_AudioSpec obtained;

SDL_zero(desired);

desired.freq = 44100;

desired.format = AUDIO_S8;

desired.channels = 2;

desired.samples = 4096;

desired.callback = NULL;

//Default audio spec

SDL_AudioSpec desiredRecordingSpec;

SDL_zero(desiredRecordingSpec);

desiredRecordingSpec.freq = 44100;

desiredRecordingSpec.format = AUDIO_F32;

desiredRecordingSpec.channels = 2;

desiredRecordingSpec.samples = 4096;

desiredRecordingSpec.callback = audioRecordingCallback;

//Open recording device

recordingDeviceId = SDL_OpenAudioDevice(NULL, SDL_TRUE, &desiredRecordingSpec, &gReceivedRecordingSpec, SDL_AUDIO_ALLOW_FORMAT_CHANGE);

//Device failed to open

if (recordingDeviceId == 0)

{

//Report error

printf("Failed to open recording device! SDL Error: %s", SDL_GetError());

SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "recording device", "Failed to open recording device...!", NULL);;

}

//Device opened successfully

else

{

//Default audio spec

SDL_AudioSpec desiredPlaybackSpec;

SDL_zero(desiredPlaybackSpec);

desiredPlaybackSpec.freq = 44100;

desiredPlaybackSpec.format = AUDIO_F32;

desiredPlaybackSpec.channels = 2;

desiredPlaybackSpec.samples = 4096;

desiredPlaybackSpec.callback = audioPlaybackCallback;

//Open playback device

playbackDeviceId = SDL_OpenAudioDevice(NULL, SDL_FALSE, &desiredPlaybackSpec, &gReceivedPlaybackSpec, SDL_AUDIO_ALLOW_ANY_CHANGE);

//Device failed to open

if (playbackDeviceId == 0)

{

//Report error

printf("Failed to open playback device! SDL Error: %s", SDL_GetError());

SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "recording device", "Failed to open playback device...!", NULL);

}

None

This topic is closed to new replies.

Advertisement