testaudiocapture: Make sure we convert captured audio to output format.

Fixes #8114.
main
Ryan C. Gordon 2023-08-11 16:52:23 -04:00
parent b75c751dfc
commit f290c85b22
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 8 additions and 5 deletions

View File

@ -98,7 +98,8 @@ int main(int argc, char **argv)
{
SDL_AudioDeviceID *devices;
SDLTest_CommonState *state;
SDL_AudioSpec spec;
SDL_AudioSpec outspec;
SDL_AudioSpec inspec;
SDL_AudioDeviceID device;
SDL_AudioDeviceID want_device = SDL_AUDIO_DEVICE_DEFAULT_CAPTURE;
const char *devname = NULL;
@ -178,8 +179,8 @@ int main(int argc, char **argv)
exit(1);
}
SDL_PauseAudioDevice(device);
SDL_GetAudioDeviceFormat(device, &spec);
stream_out = SDL_CreateAndBindAudioStream(device, &spec);
SDL_GetAudioDeviceFormat(device, &outspec);
stream_out = SDL_CreateAndBindAudioStream(device, &outspec);
if (!stream_out) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
SDL_Quit();
@ -198,14 +199,16 @@ int main(int argc, char **argv)
exit(1);
}
SDL_PauseAudioDevice(device);
SDL_GetAudioDeviceFormat(device, &spec);
stream_in = SDL_CreateAndBindAudioStream(device, &spec);
SDL_GetAudioDeviceFormat(device, &inspec);
stream_in = SDL_CreateAndBindAudioStream(device, &inspec);
if (!stream_in) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for capture: %s!\n", SDL_GetError());
SDL_Quit();
exit(1);
}
SDL_SetAudioStreamFormat(stream_in, NULL, &outspec); /* make sure we output at the playback format. */
SDL_Log("Ready! Hold down mouse or finger to record!\n");
#ifdef __EMSCRIPTEN__