/*****************************************************************************
* aout_sdl.c : audio sdl functions library
*****************************************************************************
- * Copyright (C) 1999, 2000 VideoLAN
- * $Id: aout_sdl.c,v 1.14 2001/07/12 20:44:52 reno Exp $
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: aout_sdl.c,v 1.20.2.1 2001/12/18 00:51:19 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* calloc(), malloc(), free() */
-#include <SDL/SDL.h> /* SDL base include */
+#include SDL_INCLUDE_FILE
-#include "config.h"
#include "common.h" /* boolean_t, byte_t */
+#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "audio_output.h" /* aout_thread_t */
-#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
-#include "main.h"
-
#include "modules.h"
#include "modules_export.h"
*****************************************************************************/
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 )
{
/* Otherwise, there are good chances we can use this plugin, return 100. */
intf_DbgMsg( "aout: SDL_OpenAudio successfully run" );
SDL_CloseAudio();
+#endif
if( TestMethod( AOUT_METHOD_VAR, "sdl" ) )
{
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 )
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 );
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 );
}
SDL_CloseAudio();
+ SDL_QuitSubSystem( SDL_INIT_AUDIO );
+
free( p_aout->p_sys ); /* Close the Output. */
}