Commit 06996317 authored by Christophe Massiot's avatar Christophe Massiot

aout3 API change :

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.
parent 0b88e775
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output * aout_internal.h : internal defines for audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -158,7 +158,6 @@ typedef struct aout_output_t ...@@ -158,7 +158,6 @@ typedef struct aout_output_t
struct module_t * p_module; struct module_t * p_module;
struct aout_sys_t * p_sys; struct aout_sys_t * p_sys;
int (* pf_setformat)( aout_instance_t * );
void (* pf_play)( aout_instance_t * ); void (* pf_play)( aout_instance_t * );
int i_nb_samples; int i_nb_samples;
} aout_output_t; } aout_output_t;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* alsa.c : alsa plugin for vlc * alsa.c : alsa plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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 * Authors: Henri Fallon <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API * Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
...@@ -52,8 +52,6 @@ struct aout_sys_t ...@@ -52,8 +52,6 @@ struct aout_sys_t
snd_pcm_sframes_t i_buffer_size; snd_pcm_sframes_t i_buffer_size;
int i_period_time; int i_period_time;
volatile vlc_bool_t b_initialized;
volatile vlc_bool_t b_can_sleek; volatile vlc_bool_t b_can_sleek;
#ifdef DEBUG #ifdef DEBUG
...@@ -77,10 +75,7 @@ struct aout_sys_t ...@@ -77,10 +75,7 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * ); static void Play ( aout_instance_t * );
static int ALSAThread ( aout_instance_t * ); static int ALSAThread ( aout_instance_t * );
static void ALSAFill ( aout_instance_t * ); static void ALSAFill ( aout_instance_t * );
...@@ -105,6 +100,18 @@ static int Open( vlc_object_t *p_this ) ...@@ -105,6 +100,18 @@ static int Open( vlc_object_t *p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this; aout_instance_t * p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys; 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 */ /* Allocate structures */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
if( p_sys == NULL ) if( p_sys == NULL )
...@@ -113,48 +120,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -113,48 +120,12 @@ static int Open( vlc_object_t *p_this )
return -1; 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; p_aout->output.pf_play = Play;
#ifdef DEBUG #ifdef DEBUG
snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 ); snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 );
#endif #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 */ /* Read in ALSA device preferences from configuration */
psz_userdev = config_GetPsz( p_aout, "alsa-device" ); psz_userdev = config_GetPsz( p_aout, "alsa-device" );
...@@ -334,13 +305,20 @@ static int SetFormat( aout_instance_t * p_aout ) ...@@ -334,13 +305,20 @@ static int SetFormat( aout_instance_t * p_aout )
snd_output_printf( p_sys->p_snd_stderr, "\n" ); snd_output_printf( p_sys->p_snd_stderr, "\n" );
#endif #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; return 0;
} }
/***************************************************************************** /*****************************************************************************
* Play: queue a buffer for playing by ALSAThread * Play: nothing to do
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t *p_aout ) static void Play( aout_instance_t *p_aout )
{ {
...@@ -383,9 +361,6 @@ static int ALSAThread( 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; 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 ) while ( !p_aout->b_die )
{ {
ALSAFill( p_aout ); ALSAFill( p_aout );
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* arts.c : aRts module * arts.c : aRts module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2002 VideoLAN * 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> * Authors: Emmanuel Blindauer <manu@agat.net>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -46,7 +47,6 @@ ...@@ -46,7 +47,6 @@
struct aout_sys_t struct aout_sys_t
{ {
arts_stream_t stream; arts_stream_t stream;
vlc_bool_t b_initialized;
mtime_t latency; mtime_t latency;
int i_size; int i_size;
...@@ -57,8 +57,6 @@ struct aout_sys_t ...@@ -57,8 +57,6 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * ); static void Play ( aout_instance_t * );
static int aRtsThread ( aout_instance_t * ); static int aRtsThread ( aout_instance_t * );
...@@ -87,6 +85,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -87,6 +85,7 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_aout, "out of memory" ); msg_Err( p_aout, "out of memory" );
return -1; return -1;
} }
p_aout->output.p_sys = p_sys;
i_err = arts_init(); i_err = arts_init();
...@@ -97,35 +96,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -97,35 +96,10 @@ static int Open( vlc_object_t *p_this )
return -1; 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_aout->output.pf_play = Play;
p_sys->stream = NULL; 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 ) if( p_sys->stream )
{ {
arts_close_stream( p_sys->stream ); arts_close_stream( p_sys->stream );
...@@ -152,13 +126,20 @@ static int SetFormat( aout_instance_t *p_aout ) ...@@ -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.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = p_sys->i_size; 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; return 0;
} }
/***************************************************************************** /*****************************************************************************
* Play: queue a buffer for playing by aRtsThread * Play: nothing to do
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t *p_aout ) static void Play( aout_instance_t *p_aout )
{ {
...@@ -198,12 +179,6 @@ static int aRtsThread( aout_instance_t * p_aout ) ...@@ -198,12 +179,6 @@ static int aRtsThread( aout_instance_t * p_aout )
int i_tmp, i_size; int i_tmp, i_size;
byte_t * p_bytes; byte_t * p_bytes;
if( !p_sys->b_initialized )
{
msleep( THREAD_SLEEP );
continue;
}
/* Get the presentation date of the next write() operation. It /* Get the presentation date of the next write() operation. It
* is equal to the current date + latency */ * is equal to the current date + latency */
p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency, p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* esd.c : EsounD module * esd.c : EsounD module
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -46,7 +46,6 @@ struct aout_sys_t ...@@ -46,7 +46,6 @@ struct aout_sys_t
{ {
esd_format_t esd_format; esd_format_t esd_format;
int i_fd; int i_fd;
vlc_bool_t b_initialized;
mtime_t latency; mtime_t latency;
}; };
...@@ -56,8 +55,6 @@ struct aout_sys_t ...@@ -56,8 +55,6 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * ); static void Play ( aout_instance_t * );
static int ESDThread ( aout_instance_t * ); static int ESDThread ( aout_instance_t * );
...@@ -89,31 +86,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -89,31 +86,8 @@ static int Open( vlc_object_t *p_this )
p_aout->output.p_sys = p_sys; 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; 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 */ /* Initialize some variables */
p_sys->esd_format = ESD_BITS16 | ESD_STREAM | ESD_PLAY; p_sys->esd_format = ESD_BITS16 | ESD_STREAM | ESD_PLAY;
p_sys->esd_format &= ~ESD_MASK_CHAN; p_sys->esd_format &= ~ESD_MASK_CHAN;
...@@ -155,13 +129,20 @@ static int SetFormat( aout_instance_t *p_aout ) ...@@ -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_bytes_per_frame
/ p_aout->output.output.i_rate; / 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; return 0;
} }
/***************************************************************************** /*****************************************************************************
* Play: queue a buffer for playing by ESDThread * Play: nothing to do
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t *p_aout ) static void Play( aout_instance_t *p_aout )
{ {
...@@ -195,12 +176,6 @@ static int ESDThread( aout_instance_t * p_aout ) ...@@ -195,12 +176,6 @@ static int ESDThread( aout_instance_t * p_aout )
int i_tmp, i_size; int i_tmp, i_size;
byte_t * p_bytes; byte_t * p_bytes;
if( !p_sys->b_initialized )
{
msleep( THREAD_SLEEP );
continue;
}
/* Get the presentation date of the next write() operation. It /* Get the presentation date of the next write() operation. It
* is equal to the current date + buffered samples + esd latency */ * is equal to the current date + buffered samples + esd latency */
p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency, p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* file.c : audio output which writes the samples to a file * file.c : audio output which writes the samples to a file
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * ); static void Play ( aout_instance_t * );
/***************************************************************************** /*****************************************************************************
...@@ -82,37 +81,18 @@ static int Open( vlc_object_t * p_this ) ...@@ -82,37 +81,18 @@ static int Open( vlc_object_t * p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this; aout_instance_t * p_aout = (aout_instance_t *)p_this;
FILE * p_file; FILE * p_file;
char * psz_name = config_GetPsz( p_this, "path" ); 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_file = fopen( psz_name, "wb" );
p_aout->output.p_sys = (void *)p_file; p_aout->output.p_sys = (void *)p_file;
free( psz_name ); free( psz_name );
if ( p_file == NULL ) return -1; if ( p_file == NULL ) return -1;
p_aout->output.pf_setformat = SetFormat;
p_aout->output.pf_play = Play; 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 ) while ( *ppsz_compare != NULL )
{ {
if ( !strncmp( *ppsz_compare, psz_format, strlen(*ppsz_compare) ) ) if ( !strncmp( *ppsz_compare, psz_format, strlen(*ppsz_compare) ) )
...@@ -143,6 +123,16 @@ static int SetFormat( aout_instance_t * p_aout ) ...@@ -143,6 +123,16 @@ static int SetFormat( aout_instance_t * p_aout )
return 0; 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 * Play: pretend to play a sound
*****************************************************************************/ *****************************************************************************/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc * oss.c : OSS /dev/dsp module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2002 VideoLAN * 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> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
struct aout_sys_t struct aout_sys_t
{ {
int i_fd; int i_fd;
volatile vlc_bool_t b_initialized;
}; };
#define FRAME_SIZE 1024 #define FRAME_SIZE 1024
...@@ -75,7 +74,6 @@ struct aout_sys_t ...@@ -75,7 +74,6 @@ struct aout_sys_t
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * ); static void Play ( aout_instance_t * );
static int OSSThread ( aout_instance_t * ); static int OSSThread ( aout_instance_t * );
...@@ -102,6 +100,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -102,6 +100,10 @@ static int Open( vlc_object_t *p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this; aout_instance_t * p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys; struct aout_sys_t * p_sys;
char * psz_device; char * psz_device;
int i_format;
int i_rate;
int i_fragments;
vlc_bool_t b_stereo;
/* Allocate structure */ /* Allocate structure */
p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) ); p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
...@@ -129,42 +131,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -129,42 +131,8 @@ static int Open( vlc_object_t *p_this )
} }
free( psz_device ); free( psz_device );
/* Create OSS thread and wait for its readiness. */
p_sys->b_initialized = VLC_FALSE;
if( vlc_thread_create( p_aout, "aou