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);
}