From b9e3cae572fc05cacdc1cea6bdf8a516f919ca8f Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Fri, 26 Aug 2022 16:58:21 +0200 Subject: [PATCH] Add more valid configurations to PS2 audio driver --- src/audio/ps2/SDL_ps2audio.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/audio/ps2/SDL_ps2audio.c b/src/audio/ps2/SDL_ps2audio.c index f3b578819..b050984de 100644 --- a/src/audio/ps2/SDL_ps2audio.c +++ b/src/audio/ps2/SDL_ps2audio.c @@ -48,15 +48,30 @@ PS2AUDIO_OpenDevice(_THIS, const char *devname) } SDL_zerop(this->hidden); - /* This is the native supported audio PS2 config */ - this->spec.freq = 48000; + + /* These are the native supported audio PS2 configs */ + switch (this->spec.freq) { + case 11025: + case 12000: + case 22050: + case 24000: + case 32000: + case 44100: + case 48000: + this->spec.freq = this->spec.freq; + break; + default: + this->spec.freq = 48000; + break; + } + this->spec.samples = 512; - this->spec.channels = 2; - this->spec.format = AUDIO_S16LSB; + this->spec.channels = this->spec.channels == 1 ? 1 : 2; + this->spec.format = this->spec.format == AUDIO_S8 ? AUDIO_S8 : AUDIO_S16; SDL_CalculateAudioSpec(&this->spec); - format.bits = 16; + format.bits = this->spec.format == AUDIO_S8 ? 8 : 16; format.freq = this->spec.freq; format.channels = this->spec.channels;