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 @@
* 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;
......
......@@ -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 );
......
......@@ -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,
......
......@@ -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,
......
......@@ -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
*****************************************************************************/
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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,
......
......@@ -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.
......
......@@ -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 )
{
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 )
{
......
......@@ -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>
*
......@@ -40,20 +40,11 @@
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;
}
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment