summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2015-06-03 23:03:55 +0200
committerGerd Hoffmann <kraxel@redhat.com>2015-06-15 12:42:48 +0200
commit81ebb07c56a28aa7ca47c38eb44690025a9dd6b9 (patch)
tree04a151b6569660a16eefd6e709e88856bfd0cf4e /audio
parentd1f52a1d704de2252bc48c64ca4d46086cb249a2 (diff)
downloadhqemu-81ebb07c56a28aa7ca47c38eb44690025a9dd6b9.zip
hqemu-81ebb07c56a28aa7ca47c38eb44690025a9dd6b9.tar.gz
sdlaudio: do not allow multiple instances
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 <DirtY.iCE.hu@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio')
-rw-r--r--audio/sdlaudio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index b95a7e0..1140f2e 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -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[] = {
OpenPOWER on IntegriCloud