From: Sam Hocevar Date: Tue, 18 Dec 2001 00:51:19 +0000 (+0000) Subject: (0.2.92 branch) X-Git-Tag: 0.2.92~27 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ea68ee7090ac971824f2c2992b9a14b69b211074;p=vlc (0.2.92 branch) * Initialize SDL before opening the SDL audio output. * Prevent two SDL video outputs or audio outputs to be spawned at the same time to avoid ugly crashes. --- diff --git a/plugins/sdl/aout_sdl.c b/plugins/sdl/aout_sdl.c index 4f35c0558e..1085e2d199 100644 --- a/plugins/sdl/aout_sdl.c +++ b/plugins/sdl/aout_sdl.c @@ -2,7 +2,7 @@ * aout_sdl.c : audio sdl functions library ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: aout_sdl.c,v 1.20 2001/12/07 18:33:08 sam Exp $ + * $Id: aout_sdl.c,v 1.20.2.1 2001/12/18 00:51:19 sam Exp $ * * Authors: Michel Kaempf * Samuel Hocevar @@ -107,7 +107,14 @@ static int aout_Probe( probedata_t *p_data ) { #if 0 SDL_AudioSpec desired, obtained; +#endif + if( SDL_WasInit( SDL_INIT_AUDIO ) != 0 ) + { + return( 0 ); + } + +#if 0 /* Start AudioSDL */ if( SDL_Init(SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) != 0 ) { @@ -154,7 +161,7 @@ static int aout_Open( aout_thread_t *p_aout ) SDL_AudioSpec desired; int i_channels = p_aout->b_stereo ? 2 : 1; - /* Allocate structure */ + /* Allocate structure */ p_aout->p_sys = malloc( sizeof( aout_sys_t ) ); if( p_aout->p_sys == NULL ) @@ -163,6 +170,23 @@ static int aout_Open( aout_thread_t *p_aout ) return( 1 ); } + /* Initialize library */ + if( SDL_Init( SDL_INIT_AUDIO +#ifndef WIN32 + /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet*/ + | SDL_INIT_EVENTTHREAD +#endif +#ifdef DEBUG + /* In debug mode you may want vlc to dump a core instead of staying + * stuck */ + | SDL_INIT_NOPARACHUTE +#endif + ) < 0 ) + { + intf_ErrMsg( "aout error: can't initialize SDL (%s)", SDL_GetError() );+ free( p_aout->p_sys ); + return( 1 ); + } + p_aout->p_sys->i_audio_end = 0; p_aout->p_sys->audio_buf = malloc( OVERFLOWLIMIT ); @@ -230,6 +254,8 @@ static int aout_SetFormat( aout_thread_t *p_aout ) if( SDL_OpenAudio( &desired, NULL ) < 0 ) { p_aout->p_sys->b_active = 0; + SDL_QuitSubSystem( SDL_INIT_AUDIO ); + free( p_aout->p_sys ); return( -1 ); } @@ -295,6 +321,8 @@ static void aout_Close( aout_thread_t *p_aout ) SDL_CloseAudio(); + SDL_QuitSubSystem( SDL_INIT_AUDIO ); + free( p_aout->p_sys ); /* Close the Output. */ } diff --git a/plugins/sdl/vout_sdl.c b/plugins/sdl/vout_sdl.c index 1ac557fa6d..59ee56fdd6 100644 --- a/plugins/sdl/vout_sdl.c +++ b/plugins/sdl/vout_sdl.c @@ -2,7 +2,7 @@ * vout_sdl.c: SDL video output display method ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: vout_sdl.c,v 1.67 2001/12/07 18:33:08 sam Exp $ + * $Id: vout_sdl.c,v 1.67.2.1 2001/12/18 00:51:19 sam Exp $ * * Authors: Samuel Hocevar * Pierre Baillet @@ -139,6 +139,11 @@ void _M( vout_getfunctions )( function_list_t * p_function_list ) *****************************************************************************/ static int vout_Probe( probedata_t *p_data ) { + if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 ) + { + return( 0 ); + } + if( TestMethod( VOUT_METHOD_VAR, "sdl" ) ) { return( 999 ); @@ -200,6 +205,7 @@ static int vout_Create( vout_thread_t *p_vout ) if( SDLOpenDisplay(p_vout) ) { intf_ErrMsg( "vout error: can't set up SDL (%s)", SDL_GetError() ); + SDL_QuitSubSystem( SDL_INIT_VIDEO ); free( p_vout->p_sys ); return( 1 ); } @@ -274,8 +280,7 @@ static int vout_Init( vout_thread_t *p_vout ) *****************************************************************************/ static void vout_End( vout_thread_t *p_vout ) { - SDLCloseDisplay( p_vout ); - SDL_QuitSubSystem( SDL_INIT_VIDEO ); + ; } /***************************************************************************** @@ -285,6 +290,10 @@ static void vout_End( vout_thread_t *p_vout ) *****************************************************************************/ static void vout_Destroy( vout_thread_t *p_vout ) { + SDLCloseDisplay( p_vout ); + + SDL_QuitSubSystem( SDL_INIT_VIDEO ); + free( p_vout->p_sys ); }