]> Git Repo - qemu.git/commitdiff
sdlaudio: do not allow multiple instances
authorKővágó, Zoltán <[email protected]>
Wed, 3 Jun 2015 21:03:55 +0000 (23:03 +0200)
committerGerd Hoffmann <[email protected]>
Mon, 15 Jun 2015 10:42:48 +0000 (12:42 +0200)
Since SDL uses a lot of global data, we can't create independent
instances of sdl audio backend.

Signed-off-by: Kővágó, Zoltán <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
audio/sdlaudio.c

index b95a7e0ab479c60eebff89c939f7b385a2fc46cd..1140f2ea0aaf34314ce33d26f9ea72df6d541a90 100644 (file)
@@ -55,6 +55,7 @@ static struct SDLAudioState {
     SDL_mutex *mutex;
     SDL_sem *sem;
     int initialized;
+    bool driver_created;
 } glob_sdl;
 typedef struct SDLAudioState SDLAudioState;
 
@@ -393,6 +394,10 @@ static int sdl_ctl_out (HWVoiceOut *hw, int cmd, ...)
 static void *sdl_audio_init (void)
 {
     SDLAudioState *s = &glob_sdl;
+    if (s->driver_created) {
+        sdl_logerr("Can't create multiple sdl backends\n");
+        return NULL;
+    }
 
     if (SDL_InitSubSystem (SDL_INIT_AUDIO)) {
         sdl_logerr ("SDL failed to initialize audio subsystem\n");
@@ -414,6 +419,7 @@ static void *sdl_audio_init (void)
         return NULL;
     }
 
+    s->driver_created = true;
     return s;
 }
 
@@ -424,6 +430,7 @@ static void sdl_audio_fini (void *opaque)
     SDL_DestroySemaphore (s->sem);
     SDL_DestroyMutex (s->mutex);
     SDL_QuitSubSystem (SDL_INIT_AUDIO);
+    s->driver_created = false;
 }
 
 static struct audio_option sdl_options[] = {
This page took 0.026508 seconds and 4 git commands to generate.