From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4K-0001vT-K7 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2H4I-0004eK-LV for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4I-0004e6-FZ for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:42 -0400 From: Gerd Hoffmann Date: Tue, 9 Jun 2015 12:47:31 +0200 Message-Id: <1433846851-20552-13-git-send-email-kraxel@redhat.com> In-Reply-To: <1433846851-20552-1-git-send-email-kraxel@redhat.com> References: <1433846851-20552-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 12/12] sdlaudio: do not allow multiple instances List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Vassili Karpov (malc)" , Gerd Hoffmann , =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Since SDL uses a lot of global data, we can't create independent instances of sdl audio backend. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: Gerd Hoffmann --- audio/sdlaudio.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; =20 @@ -393,6 +394,10 @@ static int sdl_ctl_out (HWVoiceOut *hw, int cmd, ...= ) static void *sdl_audio_init (void) { SDLAudioState *s =3D &glob_sdl; + if (s->driver_created) { + sdl_logerr("Can't create multiple sdl backends\n"); + return NULL; + } =20 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; } =20 + s->driver_created =3D true; return s; } =20 @@ -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 =3D false; } =20 static struct audio_option sdl_options[] =3D { --=20 1.8.3.1