Skip to contentSkip to conversation

audio/sdl2: fix unrecognized audio format

PATCH New KJ Liew 1 participant 1 message Jan 20, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20200120024422.GA686.ref@PC-SEANJYE

KJ Liew

author
#1 lore raw

PATCH 1/1 audio/sdl2: fix unrecognized audio format

On Windows/SDL2, SDL_OpenAudio() may obtain audio format different from requested format.

QEMU trace:
sdl: sdl_open: req.fmt = 0x8010 obt.fmt = 0x8120
sdl: Unrecognized SDL audio format 33056
sdl: SDL_OpenAudio failed

The easiest fix is to force audio format conversion internal to SDL2.

qemu-4.2.0/audio/sdlaudio.c renamed from orig/qemu-4.2.0/audio/sdlaudio.c +2 -1
diff -ru ../orig/qemu-4.2.0/audio/sdlaudio.c ../qemu-4.2.0/audio/sdlaudio.c
@@ -147,10 +147,11 @@
     }
 #endif
 
-    status = SDL_OpenAudio (req, obt);
+    status = SDL_OpenAudio (req, NULL);
     if (status) {
         sdl_logerr ("SDL_OpenAudio failed\n");
     }
+    memcpy(obt, req, sizeof(SDL_AudioSpec));
 
 #ifndef _WIN32
     err = pthread_sigmask (SIG_SETMASK, &old, NULL);