From 0af2db6f29ee9bc31761c83adc08fa11953bb476 Mon Sep 17 00:00:00 2001 From: Ivan Epifanov Date: Wed, 23 Mar 2022 19:04:29 +0300 Subject: [PATCH] Vita: support audio format fallback --- src/audio/vita/SDL_vitaaudio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index 524124e80..948bc3667 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -49,6 +49,7 @@ VITAAUD_OpenDevice(_THIS, const char *devname) { int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN; int vols[2] = {SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME}; + SDL_AudioFormat test_format; this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); @@ -56,6 +57,19 @@ VITAAUD_OpenDevice(_THIS, const char *devname) return SDL_OutOfMemory(); } SDL_memset(this->hidden, 0, sizeof(*this->hidden)); + + for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) { + if ((test_format == AUDIO_U8) || + (test_format == AUDIO_S16)) { + this->spec.format = test_format; + break; + } + } + + if(!test_format) { + return SDL_SetError("Unsupported audio format"); + } + switch (this->spec.format & 0xff) { case 8: case 16: