]> git.sesse.net Git - vlc/commitdiff
aout3 API change :
authorChristophe Massiot <massiot@videolan.org>
Fri, 30 Aug 2002 23:27:06 +0000 (23:27 +0000)
committerChristophe Massiot <massiot@videolan.org>
Fri, 30 Aug 2002 23:27:06 +0000 (23:27 +0000)
pf_setformat disappears (it was never called independantly of Open). If
the format needs to be changed, we will have Close/Open. This is much
simpler than before. Please check that I didn't break some plug-ins.

15 files changed:
include/aout_internal.h
modules/audio_output/alsa.c
modules/audio_output/arts.c
modules/audio_output/esd.c
modules/audio_output/file.c
modules/audio_output/oss.c
modules/audio_output/sdl.c
modules/audio_output/waveout.c
modules/gui/beos/AudioOutput.cpp
modules/gui/macosx/aout.m
modules/gui/qnx/aout.c
modules/misc/dummy/aout.c
modules/video_output/directx/aout.c
src/audio_output/output.c
src/misc/threads.c

index ab69b7acba5825c7e8a9cbb40a801d69dd1a4dcd..ae78699d1f9efa1a5cbfb7f40503a12bb8912ebf 100644 (file)
@@ -2,7 +2,7 @@
  * aout_internal.h : internal defines for audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.13 2002/08/30 22:22:24 massiot Exp $
+ * $Id: aout_internal.h,v 1.14 2002/08/30 23:27:05 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -158,7 +158,6 @@ typedef struct aout_output_t
 
     struct module_t *       p_module;
     struct aout_sys_t *     p_sys;
-    int                  (* pf_setformat)( aout_instance_t * );
     void                 (* pf_play)( aout_instance_t * );
     int                     i_nb_samples;
 } aout_output_t;
index 26a589f3c94f7e70a05762e1e1426d6df2c156ce..459210e192d70251fceb3934f222baa8ad22f074 100644 (file)
@@ -2,7 +2,7 @@
  * alsa.c : alsa plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: alsa.c,v 1.9 2002/08/29 23:53:22 massiot Exp $
+ * $Id: alsa.c,v 1.10 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Henri Fallon <henri@videolan.org> - Original Author
  *          Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
@@ -52,8 +52,6 @@ struct aout_sys_t
     snd_pcm_sframes_t   i_buffer_size;
     int                 i_period_time;
 
-    volatile vlc_bool_t b_initialized;
-
     volatile vlc_bool_t b_can_sleek;
 
 #ifdef DEBUG
@@ -77,10 +75,7 @@ struct aout_sys_t
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
 static void Close        ( vlc_object_t * );
-
-static int  SetFormat    ( aout_instance_t * );
 static void Play         ( aout_instance_t * );
-
 static int  ALSAThread   ( aout_instance_t * );
 static void ALSAFill     ( aout_instance_t * );
 
@@ -105,6 +100,18 @@ static int Open( vlc_object_t *p_this )
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
     struct aout_sys_t * p_sys;
 
+    int i_snd_rc;
+
+    char * psz_device;
+    char psz_alsadev[128];
+    char * psz_userdev;
+
+    int i_format;
+    int i_channels;
+
+    snd_pcm_hw_params_t *p_hw;
+    snd_pcm_sw_params_t *p_sw;
+
     /* Allocate structures */
     p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_sys == NULL )
@@ -113,48 +120,12 @@ static int Open( vlc_object_t *p_this )
         return -1;
     }
 
-    /* Create ALSA thread and wait for its readiness. */
-    p_sys->b_initialized = VLC_FALSE;
-    if( vlc_thread_create( p_aout, "aout", ALSAThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
-    {
-        msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) );
-        free( p_sys );
-        return -1;
-    }
-
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
 #ifdef DEBUG
     snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
 #endif
 
-    return 0;
-}
-
-/*****************************************************************************
- * SetFormat : sets the alsa output format
- *****************************************************************************
- * This function prepares the device, sets the rate, format, the mode
- * ( "play as soon as you have data" ), and buffer information.
- *****************************************************************************/
-static int SetFormat( aout_instance_t * p_aout )
-{
-    struct aout_sys_t * p_sys = p_aout->output.p_sys;
-
-    int i_snd_rc;
-
-    char * psz_device;
-    char psz_alsadev[128];
-    char * psz_userdev;
-
-    int i_format;
-    int i_channels;
-
-    snd_pcm_hw_params_t *p_hw;
-    snd_pcm_sw_params_t *p_sw;
-
     /* Read in ALSA device preferences from configuration */
     psz_userdev = config_GetPsz( p_aout, "alsa-device" );
 
@@ -334,13 +305,20 @@ static int SetFormat( aout_instance_t * p_aout )
     snd_output_printf( p_sys->p_snd_stderr, "\n" );
 #endif
 
-    p_sys->b_initialized = VLC_TRUE;
+    /* Create ALSA thread and wait for its readiness. */
+    if( vlc_thread_create( p_aout, "aout", ALSAThread,
+                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+    {
+        msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) );
+        free( p_sys );
+        return -1;
+    }
 
     return 0;
 }
 
 /*****************************************************************************
- * Play: queue a buffer for playing by ALSAThread
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t *p_aout )
 {
@@ -383,9 +361,6 @@ static int ALSAThread( aout_instance_t * p_aout )
 {
     struct aout_sys_t * p_sys = p_aout->output.p_sys;
 
-    while ( !p_aout->b_die && !p_sys->b_initialized )
-        msleep( THREAD_SLEEP );
-
     while ( !p_aout->b_die )
     {
         ALSAFill( p_aout );
index 2785610d3ee65f4e0de1c30ced5ae1420879fa20..cfcead5b3e5b78517aa0d431f3b0e5f16fa4a8b4 100644 (file)
@@ -2,6 +2,7 @@
  * arts.c : aRts module
  *****************************************************************************
  * Copyright (C) 2001-2002 VideoLAN
+ * $Id: arts.c,v 1.10 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Emmanuel Blindauer <manu@agat.net>
  *          Samuel Hocevar <sam@zoy.org>
@@ -46,7 +47,6 @@
 struct aout_sys_t
 {
     arts_stream_t stream;
-    vlc_bool_t    b_initialized;
 
     mtime_t       latency;
     int           i_size;
@@ -57,8 +57,6 @@ struct aout_sys_t
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
 static void Close        ( vlc_object_t * );
-
-static int  SetFormat    ( aout_instance_t * );
 static void Play         ( aout_instance_t * );
 static int  aRtsThread   ( aout_instance_t * );
 
@@ -87,6 +85,7 @@ static int Open( vlc_object_t *p_this )
         msg_Err( p_aout, "out of memory" );
         return -1;
     }
+    p_aout->output.p_sys = p_sys;
 
     i_err = arts_init();
     
@@ -97,35 +96,10 @@ static int Open( vlc_object_t *p_this )
         return -1;
     }
 
-    p_aout->output.p_sys = p_sys;
-
-    /* Create aRts thread and wait for its readiness. */
-    p_sys->b_initialized = VLC_FALSE;
-    if( vlc_thread_create( p_aout, "aout", aRtsThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
-    {
-        msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) );
-        free( p_sys );
-        return -1;
-    }
-
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
     p_sys->stream = NULL;
 
-    return 0;
-}
-
-/*****************************************************************************
- * SetFormat: set the output format
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_aout )
-{
-    struct aout_sys_t * p_sys = p_aout->output.p_sys;
-
-    p_sys->b_initialized = VLC_FALSE;
-
     if( p_sys->stream )
     {
         arts_close_stream( p_sys->stream );
@@ -152,13 +126,20 @@ static int SetFormat( aout_instance_t *p_aout )
     p_aout->output.output.i_format = AOUT_FMT_S16_NE;
     p_aout->output.i_nb_samples = p_sys->i_size;
 
-    p_sys->b_initialized = VLC_TRUE;
+    /* Create aRts thread and wait for its readiness. */
+    if( vlc_thread_create( p_aout, "aout", aRtsThread,
+                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+    {
+        msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) );
+        free( p_sys );
+        return -1;
+    }
 
     return 0;
 }
 
 /*****************************************************************************
- * Play: queue a buffer for playing by aRtsThread
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t *p_aout )
 {
@@ -198,12 +179,6 @@ static int aRtsThread( aout_instance_t * p_aout )
         int i_tmp, i_size;
         byte_t * p_bytes;
 
-        if( !p_sys->b_initialized )
-        {
-            msleep( THREAD_SLEEP );
-            continue;
-        }
-
         /* Get the presentation date of the next write() operation. It
          * is equal to the current date + latency */
         p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency,
index 319acf62906317dafaab1dd6ea4b93fb02c9ccf4..cc66a7ec41e519b3f2136bbbe9355015e16df9a9 100644 (file)
@@ -2,7 +2,7 @@
  * esd.c : EsounD module
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: esd.c,v 1.11 2002/08/29 23:53:22 massiot Exp $
+ * $Id: esd.c,v 1.12 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -46,7 +46,6 @@ struct aout_sys_t
 {
     esd_format_t esd_format;
     int          i_fd;
-    vlc_bool_t   b_initialized;
 
     mtime_t      latency;
 };
@@ -56,8 +55,6 @@ struct aout_sys_t
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
 static void Close        ( vlc_object_t * );
-
-static int  SetFormat    ( aout_instance_t * );
 static void Play         ( aout_instance_t * );
 static int  ESDThread    ( aout_instance_t * );
 
@@ -89,31 +86,8 @@ static int Open( vlc_object_t *p_this )
 
     p_aout->output.p_sys = p_sys;
 
-    /* Create ESD thread and wait for its readiness. */
-    p_sys->b_initialized = VLC_FALSE;
-    if( vlc_thread_create( p_aout, "aout", ESDThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
-    {
-        msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) );
-        free( p_sys );
-        return -1;
-    }
-
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
-    return( 0 );
-}
-
-/*****************************************************************************
- * SetFormat: set the output format
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_aout )
-{
-    struct aout_sys_t * p_sys = p_aout->output.p_sys;
-
-    p_sys->b_initialized = VLC_FALSE;
-
     /* Initialize some variables */
     p_sys->esd_format = ESD_BITS16 | ESD_STREAM | ESD_PLAY;
     p_sys->esd_format &= ~ESD_MASK_CHAN;
@@ -155,13 +129,20 @@ static int SetFormat( aout_instance_t *p_aout )
       / p_aout->output.output.i_bytes_per_frame
       / p_aout->output.output.i_rate;
 
-    p_sys->b_initialized = VLC_TRUE;
+    /* Create ESD thread and wait for its readiness. */
+    if( vlc_thread_create( p_aout, "aout", ESDThread,
+                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+    {
+        msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) );
+        free( p_sys );
+        return -1;
+    }
 
     return 0;
 }
 
 /*****************************************************************************
- * Play: queue a buffer for playing by ESDThread
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t *p_aout )
 {
@@ -195,12 +176,6 @@ static int ESDThread( aout_instance_t * p_aout )
         int i_tmp, i_size;
         byte_t * p_bytes;
 
-        if( !p_sys->b_initialized )
-        {
-            msleep( THREAD_SLEEP );
-            continue;
-        }
-
         /* Get the presentation date of the next write() operation. It
          * is equal to the current date + buffered samples + esd latency */
         p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency,
index 1e33f001e2f49a1ed1425d813a8bf66f913a2e12..36d2dcc272d0e454034dd751f09d2ff61700594a 100644 (file)
@@ -2,7 +2,7 @@
  * file.c : audio output which writes the samples to a file
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: file.c,v 1.9 2002/08/30 22:22:24 massiot Exp $
+ * $Id: file.c,v 1.10 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -41,7 +41,6 @@
  *****************************************************************************/
 static int     Open        ( vlc_object_t * );
 static void    Close       ( vlc_object_t * );
-static int     SetFormat   ( aout_instance_t * );
 static void    Play        ( aout_instance_t * );
 
 /*****************************************************************************
@@ -82,37 +81,18 @@ static int Open( vlc_object_t * p_this )
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
     FILE * p_file;
     char * psz_name = config_GetPsz( p_this, "path" );
+    char * psz_format = config_GetPsz( p_aout, "format" );
+    char ** ppsz_compare = format_list;
+    int i = 0;
+
 
     p_file = fopen( psz_name, "wb" );
     p_aout->output.p_sys = (void *)p_file;
     free( psz_name );
     if ( p_file == NULL ) return -1;
 
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Close: close our file
- *****************************************************************************/
-static void Close( vlc_object_t * p_this )
-{
-    aout_instance_t * p_aout = (aout_instance_t *)p_this;
-
-    fclose( (FILE *)p_aout->output.p_sys );
-}
-
-/*****************************************************************************
- * SetFormat: pretend to set the dsp output format
- *****************************************************************************/
-static int SetFormat( aout_instance_t * p_aout )
-{
-    char * psz_format = config_GetPsz( p_aout, "format" );
-    char ** ppsz_compare = format_list;
-    int i = 0;
-
     while ( *ppsz_compare != NULL )
     {
         if ( !strncmp( *ppsz_compare, psz_format, strlen(*ppsz_compare) ) )
@@ -143,6 +123,16 @@ static int SetFormat( aout_instance_t * p_aout )
     return 0;
 }
 
+/*****************************************************************************
+ * Close: close our file
+ *****************************************************************************/
+static void Close( vlc_object_t * p_this )
+{
+    aout_instance_t * p_aout = (aout_instance_t *)p_this;
+
+    fclose( (FILE *)p_aout->output.p_sys );
+}
+
 /*****************************************************************************
  * Play: pretend to play a sound
  *****************************************************************************/
index 4cc278ed855af7e51ba48aa60f6aed94a0cbc487..7e8ad0f8ce3213bac633feb72eab4ab32d2feb77 100644 (file)
@@ -2,7 +2,7 @@
  * oss.c : OSS /dev/dsp module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: oss.c,v 1.20 2002/08/29 23:53:22 massiot Exp $
+ * $Id: oss.c,v 1.21 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -62,7 +62,6 @@
 struct aout_sys_t
 {
     int                   i_fd;
-    volatile vlc_bool_t   b_initialized;
 };
 
 #define FRAME_SIZE 1024
@@ -75,7 +74,6 @@ struct aout_sys_t
 static int  Open         ( vlc_object_t * );
 static void Close        ( vlc_object_t * );
 
-static int  SetFormat    ( aout_instance_t * );
 static void Play         ( aout_instance_t * );
 static int  OSSThread    ( aout_instance_t * );
 
@@ -102,6 +100,10 @@ static int Open( vlc_object_t *p_this )
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
     struct aout_sys_t * p_sys;
     char * psz_device;
+    int i_format;
+    int i_rate;
+    int i_fragments;
+    vlc_bool_t b_stereo;
 
     /* Allocate structure */
     p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
@@ -129,42 +131,8 @@ static int Open( vlc_object_t *p_this )
     }
     free( psz_device );
 
-    /* Create OSS thread and wait for its readiness. */
-    p_sys->b_initialized = VLC_FALSE;
-    if( vlc_thread_create( p_aout, "aout", OSSThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
-    {
-        msg_Err( p_aout, "cannot create OSS thread (%s)", strerror(errno) );
-        close( p_sys->i_fd );
-        free( psz_device );
-        free( p_sys );
-        return VLC_ETHREAD;
-    }
-
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * SetFormat: reset the dsp and set its format
- *****************************************************************************
- * This functions resets the DSP device, tries to initialize the output
- * format with the value contained in the dsp structure, and if this value
- * could not be set, the default value returned by ioctl is set. It then
- * does the same for the stereo mode, and for the output rate.
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_aout )
-{
-    struct aout_sys_t * p_sys = p_aout->output.p_sys;
-    int i_format;
-    int i_rate;
-    int i_fragments;
-    vlc_bool_t b_stereo;
-
-    p_sys->b_initialized = VLC_FALSE;
-
     /* Reset the DSP device */
     if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
     {
@@ -246,13 +214,22 @@ static int SetFormat( aout_instance_t *p_aout )
         }
     }
 
-    p_sys->b_initialized = VLC_TRUE;
+    /* Create OSS thread and wait for its readiness. */
+    if( vlc_thread_create( p_aout, "aout", OSSThread,
+                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+    {
+        msg_Err( p_aout, "cannot create OSS thread (%s)", strerror(errno) );
+        close( p_sys->i_fd );
+        free( psz_device );
+        free( p_sys );
+        return VLC_ETHREAD;
+    }
 
     return VLC_SUCCESS;
 }
 
 /*****************************************************************************
- * Play: queue a buffer for playing by OSSThread
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t *p_aout )
 {
@@ -319,12 +296,6 @@ static int OSSThread( aout_instance_t * p_aout )
         int i_tmp, i_size;
         byte_t * p_bytes;
 
-        if( !p_sys->b_initialized )
-        {
-            msleep( THREAD_SLEEP );
-            continue;
-        }
-
         if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
         {
             mtime_t buffered = BufferDuration( p_aout );
index 2b0d569373aa811a0981018044ffb8a5a51d969c..5662a93d59efc769b8f239bbe6eceb08a83a3193 100644 (file)
@@ -2,7 +2,7 @@
  * sdl.c : SDL audio output plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: sdl.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
+ * $Id: sdl.c,v 1.9 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -57,10 +57,7 @@ struct aout_sys_t
  *****************************************************************************/
 static int  Open        ( vlc_object_t * );
 static void Close       ( vlc_object_t * );
-
-static int  SetFormat   ( aout_instance_t * );
 static void Play        ( aout_instance_t * );
-
 static void SDLCallback ( void *, Uint8 *, int );
 
 /*****************************************************************************
@@ -78,6 +75,7 @@ vlc_module_end();
 static int Open ( vlc_object_t *p_this )
 {
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
+    SDL_AudioSpec desired;
 
     Uint32 i_flags = SDL_INIT_AUDIO;
 
@@ -106,16 +104,7 @@ static int Open ( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * SetFormat: reset the audio device and sets its format
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_aout )
-{
     /* TODO: finish and clean this */
-    SDL_AudioSpec desired;
 
     desired.freq       = p_aout->output.output.i_rate;
     desired.format     = AUDIO_S16SYS;
index 8e5bb3696f3a99fbca4a7657711da649ea12d12c..8ca19f26172d712f080669f65f1f063c5012b4d7 100644 (file)
@@ -2,7 +2,7 @@
  * waveout.c : Windows waveOut plugin for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: waveout.c,v 1.5 2002/08/25 09:40:00 sam Exp $
+ * $Id: waveout.c,v 1.6 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *      
@@ -43,8 +43,6 @@
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );             
 static void Close        ( vlc_object_t * );                   
-
-static int  SetFormat    ( aout_instance_t * );  
 static void Play         ( aout_instance_t * );
 
 /* local functions */
@@ -102,7 +100,6 @@ static int Open( vlc_object_t *p_this )
         return 1;
     }
 
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
     /* calculate the frame size in bytes */
@@ -119,57 +116,17 @@ static int Open( vlc_object_t *p_this )
 
     /* We need to open the device with default values to be sure it is
      * available */
-    return OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 );
-}
-
-/*****************************************************************************
- * SetFormat: reset the audio device and sets its format
- *****************************************************************************
- * This functions set a new audio format.
- * For this we need to close the current device and create another
- * one with the desired format.
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_aout )
-{
-    msg_Dbg( p_aout, "SetFormat" );
+    if ( OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 ) )
+    {
+        msg_Err( p_aout, "cannot open waveout" );
+        return 1;
+    }
 
     waveOutReset( p_aout->output.p_sys->h_waveout );
 
     p_aout->output.output.i_format = AOUT_FMT_S16_NE;
     p_aout->output.i_nb_samples = FRAME_SIZE;
 
-    /* Check if the format has changed */
-    if( (p_aout->output.p_sys->waveformat.nChannels !=
-             p_aout->output.output.i_channels) ||
-        (p_aout->output.p_sys->waveformat.nSamplesPerSec !=
-             p_aout->output.output.i_rate) )
-    {
-        if( waveOutClose( p_aout->output.p_sys->h_waveout ) !=
-                MMSYSERR_NOERROR )
-        {
-            msg_Err( p_aout, "waveOutClose failed" );
-        }
-
-        /* calculate the frame size in bytes */
-        p_aout->output.p_sys->i_buffer_size = FRAME_SIZE * sizeof(s16)
-                                            * p_aout->output.output.i_channels;
-
-        /* take care of silence buffer */
-        free( p_aout->output.p_sys->p_silence_buffer );
-        p_aout->output.p_sys->p_silence_buffer =
-            calloc( p_aout->output.p_sys->i_buffer_size, 1 );
-        if( p_aout->output.p_sys->p_silence_buffer == NULL )
-        {
-            msg_Err( p_aout, "out of memory" );
-            return 1;
-        }
-
-        if( OpenWaveOut( p_aout, WAVE_FORMAT_PCM,
-                         p_aout->output.output.i_channels,
-                         p_aout->output.output.i_rate ) )
-            return 1;
-    }
-
     /* We need to kick off the playback in order to have the callback properly
      * working */
     PlayWaveOut( p_aout, p_aout->output.p_sys->h_waveout,
index 01a1d26d8fbd203e85a5727f287ba495475ab4fc..378c311327e92d059ddc6ca0e5aa759c3fd0edbc 100644 (file)
@@ -2,7 +2,7 @@
  * aout.cpp: BeOS audio output
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: AudioOutput.cpp,v 1.6 2002/08/29 23:53:22 massiot Exp $
+ * $Id: AudioOutput.cpp,v 1.7 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -54,9 +54,7 @@ struct aout_sys_t
     void             * p_buffer;
     int                 i_buffer_size;
     uint             i_buffer_pos;
-    volatile vlc_bool_t   b_initialized;
     mtime_t          clock_diff;
-
 };
 
 #define FRAME_SIZE 2048
@@ -64,19 +62,15 @@ struct aout_sys_t
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
-int  Open         ( vlc_object_t * );
-void Close        ( vlc_object_t * );
-
 static int  SetFormat    ( aout_instance_t * );
 static void Play         ( aout_instance_t * );
-static int  BeOSThread    ( aout_instance_t * );
+static int  BeOSThread   ( aout_instance_t * );
 
 /*****************************************************************************
  * OpenAudio: opens a BPushGameSound
  *****************************************************************************/
 int E_(OpenAudio) ( vlc_object_t * p_this )
 {       
-
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
     struct aout_sys_t * p_sys;
 
@@ -113,10 +107,8 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
         free( p_sys->p_format );
         free( p_sys );
         return -1;
-
     }
     
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
     return 0;
@@ -157,15 +149,11 @@ static int SetFormat( aout_instance_t *p_aout )
 
     p_aout->output.p_sys->p_format->buffer_size = 4*8192;
 
-    p_aout->output.p_sys->b_initialized = VLC_TRUE;
-
     return( 0 );
 }
 
 /*****************************************************************************
- * Play: plays a sound samples buffer
- *****************************************************************************
- * This function writes a buffer of i_length bytes in the dsp
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t *p_aout )
 {
@@ -222,11 +210,6 @@ static int BeOSThread( aout_instance_t * p_aout )
         int i_tmp, i_size;
         byte_t * p_bytes;
 
-        if( !p_sys->b_initialized )
-        {
-            msleep( THREAD_SLEEP );
-            continue;
-        }
         mtime_t next_date = 0;
         /* Get the presentation date of the next write() operation. It
          * is equal to the current date + duration of buffered samples.
index 920c723150c29c8cc278b6331ad3beabd975892e..84316e504423b9691c2964b7786e162e982015cf 100644 (file)
@@ -2,7 +2,7 @@
  * aout.m: CoreAudio output plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout.m,v 1.7 2002/08/25 09:40:00 sam Exp $
+ * $Id: aout.m,v 1.8 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -57,7 +57,6 @@ struct aout_sys_t
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
-static int      SetFormat       ( aout_instance_t *p_aout );
 static void     Play            ( aout_instance_t *p_aout );
 
 static OSStatus IOCallback      ( AudioDeviceID inDevice,
@@ -99,22 +98,10 @@ int E_(OpenAudio)( vlc_object_t * p_this )
         return( -1 );
     }
 
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
-    return 0;
-}
-
-/*****************************************************************************
- * SetFormat: find the closest available format from p_format
- *****************************************************************************/
-static int SetFormat( aout_instance_t * p_aout )
-{
-    struct aout_sys_t * p_sys = p_aout->output.p_sys;
-    OSErr err;
-
     /* Get a description of the data format used by the device */
-    UInt32 i_param_size = sizeof( p_sys->stream_format ); 
+    i_param_size = sizeof( p_sys->stream_format ); 
     err = AudioDeviceGetProperty( p_sys->device, 0, false, 
                                   kAudioDevicePropertyStreamFormat, 
                                   &i_param_size,
@@ -208,7 +195,7 @@ void E_(CloseAudio)( aout_instance_t * p_aout )
 }
 
 /*****************************************************************************
- * Play: queue a buffer for playing by IOCallback
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t * p_aout )
 {
index 15871a6241d8f173866a88dd246a44fbf8bb7c30..02b36de53d099a5469e74f849279fc355c48f7e6 100644 (file)
@@ -47,7 +47,6 @@ struct aout_sys_t
     int          i_device;
 
     byte_t *     p_silent_buffer;
-    vlc_bool_t   b_initialized;
 };
 
 #define DEFAULT_FRAME_SIZE 2048
@@ -58,7 +57,6 @@ struct aout_sys_t
 int            E_(OpenAudio)    ( vlc_object_t *p_this );
 void           E_(CloseAudio)   ( vlc_object_t *p_this );
 static int     GetBufInfo       ( aout_instance_t * );
-static int     SetFormat        ( aout_instance_t * );
 static void    Play             ( aout_instance_t * );
 static int     QNXaoutThread    ( aout_instance_t * );
 
@@ -71,6 +69,10 @@ int E_(OpenAudio)( vlc_object_t *p_this )
 {
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     int i_ret;
+    int i_bytes_per_sample;
+    snd_pcm_channel_info_t pi;
+    snd_pcm_channel_params_t pp;
+    aout_instance_t *p_aout = (aout_instance_t *)p_this;
 
     /* allocate structure */
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
@@ -102,41 +104,9 @@ int E_(OpenAudio)( vlc_object_t *p_this )
         return -1;
     }
 
-    /* Create audio thread and wait for its readiness. */
-    p_aout->output.p_sys->b_initialized = VLC_FALSE;
-    if( vlc_thread_create( p_aout, "aout", QNXaoutThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
-    {
-        msg_Err( p_aout, "cannot create QNX audio thread (%s)", strerror(errno) );
-        E_(CloseAudio)( p_this );
-        free( p_aout->output.p_sys );
-        return -1;
-    }
-
     p_aout->output.p_sys->p_silent_buffer = malloc( DEFAULT_FRAME_SIZE * 4 );
-
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
-    return( 0 );
-}
-
-/*****************************************************************************
- * SetFormat : set the audio output format
- *****************************************************************************
- * This function prepares the device, sets the rate, format, the mode
- * ("play as soon as you have data"), and buffer information.
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_this )
-{
-    int i_ret;
-    int i_bytes_per_sample;
-    snd_pcm_channel_info_t pi;
-    snd_pcm_channel_params_t pp;
-    aout_instance_t *p_aout = (aout_instance_t *)p_this;
-
-    p_aout->output.p_sys->b_initialized = VLC_FALSE;
-
     memset( &pi, 0, sizeof(pi) );
     memset( &pp, 0, sizeof(pp) );
 
@@ -198,7 +168,15 @@ static int SetFormat( aout_instance_t *p_this )
         return -1;
     }
 
-    p_aout->output.p_sys->b_initialized = VLC_TRUE;
+    /* Create audio thread and wait for its readiness. */
+    if( vlc_thread_create( p_aout, "aout", QNXaoutThread,
+                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+    {
+        msg_Err( p_aout, "cannot create QNX audio thread (%s)", strerror(errno) );
+        E_(CloseAudio)( p_this );
+        free( p_aout->output.p_sys );
+        return -1;
+    }
 
     return( 0 );
 }
@@ -287,12 +265,6 @@ static int QNXaoutThread( aout_instance_t * p_aout )
         int i_tmp, i_size;
         byte_t * p_bytes;
 
-        if( !p_sys->b_initialized )
-        {
-            msleep( THREAD_SLEEP );
-            continue;
-        }
-
         if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
         {
             mtime_t next_date = 0;
index 18f3ec95f400a33af25c97379ac1a721efd90b96..b7fb30fe1b3fa0b75e9f5358514612a2c87a6b8e 100644 (file)
@@ -2,7 +2,7 @@
  * aout_dummy.c : dummy audio output plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout.c,v 1.7 2002/08/30 22:22:24 massiot Exp $
+ * $Id: aout.c,v 1.8 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -38,7 +38,6 @@
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
-static int     SetFormat   ( aout_instance_t * );
 static void    Play        ( aout_instance_t * );
 
 /*****************************************************************************
@@ -48,17 +47,8 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
 {
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
 
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * SetFormat: pretend to set the dsp output format
- *****************************************************************************/
-static int SetFormat( aout_instance_t * p_aout )
-{
     if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
     {
         p_aout->output.i_nb_samples = A52_FRAME_NB;
index 509204418557847dd608d09dedbdbc9f03123cd0..532a6baa660d81c84d119061ecdb01d548992610 100644 (file)
@@ -2,7 +2,7 @@
  * aout.c: Windows DirectX audio output method
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aout.c,v 1.8 2002/08/29 23:53:22 massiot Exp $
+ * $Id: aout.c,v 1.9 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -88,15 +88,9 @@ struct aout_sys_t
 
 };
 
-/*****************************************************************************
- * Prototypes.
- *****************************************************************************/
-void E_(CloseAudio) ( vlc_object_t *p_this );
-
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
-static int  SetFormat ( aout_instance_t * );
 static void Play      ( aout_instance_t * );
 
 /* local functions */
@@ -134,7 +128,6 @@ int E_(OpenAudio) ( vlc_object_t *p_this )
     p_aout->output.p_sys->p_notif = NULL;
     vlc_mutex_init( p_aout, &p_aout->output.p_sys->buffer_lock );
 
-    p_aout->output.pf_setformat = SetFormat;
     p_aout->output.pf_play = Play;
 
     /* Initialise DirectSound */
@@ -159,7 +152,6 @@ int E_(OpenAudio) ( vlc_object_t *p_this )
         goto error;
     }
 
-
     /* Now we need to setup DirectSound play notification */
     p_aout->output.p_sys->p_notif =
         vlc_object_create( p_aout, sizeof(notification_thread_t) );
@@ -171,37 +163,6 @@ int E_(OpenAudio) ( vlc_object_t *p_this )
     p_aout->output.p_sys->p_notif->p_events[1].hEventNotify =
         CreateEvent( NULL, FALSE, FALSE, NULL );
 
-    /* then launch the notification thread */
-    msg_Dbg( p_aout, "creating DirectSoundThread" );
-    if( vlc_thread_create( p_aout->output.p_sys->p_notif,
-                           "DirectSound Notification Thread",
-                           DirectSoundThread, VLC_THREAD_PRIORITY_OUTPUT, 1 ) )
-    {
-        msg_Err( p_aout, "cannot create DirectSoundThread" );
-        goto error;
-    }
-
-    vlc_object_attach( p_aout->output.p_sys->p_notif, p_aout );
-
-    return 0;
-
- error:
-    E_(CloseAudio)( VLC_OBJECT(p_aout) );
-    return 1;
-}
-
-/*****************************************************************************
- * SetFormat: reset the audio device and sets its format
- *****************************************************************************
- * This functions set a new audio format.
- * For this we need to close the current secondary buffer and create another
- * one with the desired format.
- *****************************************************************************/
-static int SetFormat( aout_instance_t *p_aout )
-{
-    HRESULT dsresult;
-
-    msg_Dbg( p_aout, "SetFormat" );
     vlc_mutex_lock( &p_aout->output.p_sys->buffer_lock );
 
     /* first release the current secondary buffer */
@@ -239,14 +200,27 @@ static int SetFormat( aout_instance_t *p_aout )
         msg_Warn( p_aout, "cannot play buffer" );
     }
 
+    /* then launch the notification thread */
+    msg_Dbg( p_aout, "creating DirectSoundThread" );
+    if( vlc_thread_create( p_aout->output.p_sys->p_notif,
+                           "DirectSound Notification Thread",
+                           DirectSoundThread, VLC_THREAD_PRIORITY_OUTPUT, 1 ) )
+    {
+        msg_Err( p_aout, "cannot create DirectSoundThread" );
+        goto error;
+    }
+
+    vlc_object_attach( p_aout->output.p_sys->p_notif, p_aout );
+
     return 0;
+
+ error:
+    E_(CloseAudio)( VLC_OBJECT(p_aout) );
+    return 1;
 }
 
 /*****************************************************************************
- * Play: play a sound buffer
- *****************************************************************************
- * This doesn't actually play the buffer. This just stores the buffer so it
- * can be played by the callback thread.
+ * Play: nothing to do
  *****************************************************************************/
 static void Play( aout_instance_t *p_aout )
 {
index afa9bc9dc8f5c08bcf0c1be72e0cf731da767d1c..e3f50144ee12b18e222569c33164c1bc46e5305f 100644 (file)
@@ -2,7 +2,7 @@
  * output.c : internal management of output streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.13 2002/08/30 22:22:24 massiot Exp $
+ * $Id: output.c,v 1.14 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
 int aout_OutputNew( aout_instance_t * p_aout,
                     audio_sample_format_t * p_format )
 {
+    /* Retrieve user defaults. */
     char * psz_name = config_GetPsz( p_aout, "aout" );
     int i_rate = config_GetInt( p_aout, "aout-rate" );
     int i_channels = config_GetInt( p_aout, "aout-channels" );
 
-    p_aout->output.p_module = module_Need( p_aout, "audio output",
-                                           psz_name );
-    if ( psz_name != NULL ) free( psz_name );
-    if ( p_aout->output.p_module == NULL )
-    {
-        msg_Err( p_aout, "no suitable aout module" );
-        return -1;
-    }
-
-    /* Retrieve user defaults. */
     memcpy( &p_aout->output.output, p_format, sizeof(audio_sample_format_t) );
     if ( i_rate != -1 ) p_aout->output.output.i_rate = i_rate;
     if ( i_channels != -1 ) p_aout->output.output.i_channels = i_channels;
@@ -68,14 +59,17 @@ int aout_OutputNew( aout_instance_t * p_aout,
                      = (p_aout->p_vlc->i_cpu & CPU_CAPABILITY_FPU) ?
                         AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32;
     }
+    aout_FormatPrepare( &p_aout->output.output );
 
     vlc_mutex_lock( &p_aout->output_fifo_lock );
 
-    /* Find the best output format. */
-    if ( p_aout->output.pf_setformat( p_aout ) != 0 )
+    /* Find the best output plug-in. */
+    p_aout->output.p_module = module_Need( p_aout, "audio output",
+                                           psz_name );
+    if ( psz_name != NULL ) free( psz_name );
+    if ( p_aout->output.p_module == NULL )
     {
-        msg_Err( p_aout, "couldn't set an output format" );
-        module_Unneed( p_aout, p_aout->output.p_module );
+        msg_Err( p_aout, "no suitable aout module" );
         vlc_mutex_unlock( &p_aout->output_fifo_lock );
         return -1;
     }
index cd664d1b7d06424c0c2cda000af98977519360c1..85778f8af18a4c0b14d7f5cdd5fef4f9b0e2c8d5 100644 (file)
@@ -2,7 +2,7 @@
  * threads.c : threads implementation for the VideoLAN client
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: threads.c,v 1.14 2002/08/30 12:23:23 sam Exp $
+ * $Id: threads.c,v 1.15 2002/08/30 23:27:06 massiot Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -320,7 +320,7 @@ int __vlc_mutex_destroy( char * psz_file, int i_line, vlc_mutex_t *p_mutex )
     i_result = pthread_mutex_destroy( &p_mutex->mutex );
     if ( i_result )
     {
-        i_thread = pthread_self();
+        i_thread = (int)pthread_self();
         psz_error = strerror(i_result);
     }
 
@@ -454,7 +454,7 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
     i_result = pthread_cond_destroy( &p_condvar->cond );
     if ( i_result )
     {
-        i_thread = pthread_self();
+        i_thread = (int)pthread_self();
         psz_error = strerror(i_result);
     }