* 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>
*
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;
* 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
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
*****************************************************************************/
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 * );
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 )
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" );
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 )
{
{
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 );
* 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>
struct aout_sys_t
{
arts_stream_t stream;
- vlc_bool_t b_initialized;
mtime_t latency;
int i_size;
*****************************************************************************/
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 * );
msg_Err( p_aout, "out of memory" );
return -1;
}
+ p_aout->output.p_sys = p_sys;
i_err = arts_init();
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 );
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 )
{
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,
* 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>
*
{
esd_format_t esd_format;
int i_fd;
- vlc_bool_t b_initialized;
mtime_t latency;
};
*****************************************************************************/
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 * );
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;
/ 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 )
{
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,
* 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>
*
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
-static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * );
/*****************************************************************************
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) ) )
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
*****************************************************************************/
* 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>
struct aout_sys_t
{
int i_fd;
- volatile vlc_bool_t b_initialized;
};
#define FRAME_SIZE 1024
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 * );
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 ) );
}
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 )
{
}
}
- 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 )
{
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 );
* 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>
*****************************************************************************/
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 );
/*****************************************************************************
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;
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;
* 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>
*
*****************************************************************************/
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 */
return 1;
}
- p_aout->output.pf_setformat = SetFormat;
p_aout->output.pf_play = Play;
/* calculate the frame size in bytes */
/* 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,
* 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>
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
/*****************************************************************************
* 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;
free( p_sys->p_format );
free( p_sys );
return -1;
-
}
- p_aout->output.pf_setformat = SetFormat;
p_aout->output.pf_play = Play;
return 0;
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 )
{
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.
* 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>
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static int SetFormat ( aout_instance_t *p_aout );
static void Play ( aout_instance_t *p_aout );
static OSStatus IOCallback ( AudioDeviceID inDevice,
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,
}
/*****************************************************************************
- * Play: queue a buffer for playing by IOCallback
+ * Play: nothing to do
*****************************************************************************/
static void Play( aout_instance_t * p_aout )
{
int i_device;
byte_t * p_silent_buffer;
- vlc_bool_t b_initialized;
};
#define DEFAULT_FRAME_SIZE 2048
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 * );
{
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 ) );
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) );
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 );
}
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;
* 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>
*
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static int SetFormat ( aout_instance_t * );
static void Play ( aout_instance_t * );
/*****************************************************************************
{
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;
* 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>
*
};
-/*****************************************************************************
- * 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 */
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 */
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) );
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 */
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 )
{
* 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;
= (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;
}
* 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>
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);
}
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);
}