* a52.c: A/52 basic parser
*****************************************************************************
* Copyright (C) 2001-2002 VideoLAN
- * $Id: a52.c,v 1.9 2002/09/02 23:17:05 massiot Exp $
+ * $Id: a52.c,v 1.12 2002/09/20 23:27:03 massiot Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Christophe Massiot <massiot@via.ecp.fr>
#define A52_FRAME_NB 1536
/*****************************************************************************
- * spdif_thread_t : A52 pass-through thread descriptor
+ * dec_thread_t : A52 pass-through thread descriptor
*****************************************************************************/
-typedef struct spdif_thread_s
+typedef struct dec_thread_t
{
/*
* Thread properties
* Input properties
*/
decoder_fifo_t * p_fifo; /* stores the PES stream data */
-
- /* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream;
/*
aout_instance_t * p_aout; /* opaque */
aout_input_t * p_aout_input; /* opaque */
audio_sample_format_t output_format;
-} spdif_thread_t;
+} dec_thread_t;
/****************************************************************************
* Local prototypes
static int OpenDecoder ( vlc_object_t * );
static int RunDecoder ( decoder_fifo_t * );
-static int InitThread ( spdif_thread_t *, decoder_fifo_t * );
-static void EndThread ( spdif_thread_t * );
+static void EndThread ( dec_thread_t * );
static int SyncInfo ( const byte_t *, int *, int *, int * );
*****************************************************************************/
vlc_module_begin();
set_description( _("A/52 parser") );
- set_capability( "decoder", 0 );
+ set_capability( "decoder", 100 );
set_callbacks( OpenDecoder, NULL );
- add_shortcut( "pass_through" );
- add_shortcut( "pass" );
vlc_module_end();
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
- *****************************************************************************
- * Tries to launch a decoder and return score so that the interface is able
- * to chose.
*****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
{
****************************************************************************/
static int RunDecoder( decoder_fifo_t *p_fifo )
{
- spdif_thread_t * p_dec;
+ dec_thread_t * p_dec;
audio_date_t end_date;
/* Allocate the memory needed to store the thread's structure */
- p_dec = malloc( sizeof(spdif_thread_t) );
+ p_dec = malloc( sizeof(dec_thread_t) );
if( p_dec == NULL )
{
msg_Err( p_fifo, "out of memory" );
return -1;
}
- if ( InitThread( p_dec, p_fifo ) )
- {
-
- msg_Err( p_fifo, "could not initialize thread" );
- DecoderError( p_fifo );
- free( p_dec );
- return -1;
- }
+ /* Initialize the thread properties */
+ p_dec->p_aout = NULL;
+ p_dec->p_aout_input = NULL;
+ p_dec->p_fifo = p_fifo;
+ p_dec->output_format.i_format = AOUT_FMT_A52;
+
+ /* Init the bitstream */
+ InitBitstream( &p_dec->bit_stream, p_dec->p_fifo,
+ NULL, NULL );
/* decoder thread's main loop */
while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
{
int i_frame_size, i_channels, i_rate, i_bit_rate;
mtime_t pts;
- /* Temporary buffer to store the raw frame to be decoded */
byte_t p_header[7];
aout_buffer_t * p_buffer;
memcpy( p_buffer->p_buffer, p_header, 7 );
GetChunk( &p_dec->bit_stream, p_buffer->p_buffer + 7,
i_frame_size - 7 );
- if( p_dec->p_fifo->b_die ) break;
+ if( p_dec->p_fifo->b_die )
+ {
+ aout_BufferDelete( p_dec->p_aout, p_dec->p_aout_input,
+ p_buffer );
+ break;
+ }
/* Send the buffer to the mixer. */
aout_BufferPlay( p_dec->p_aout, p_dec->p_aout_input, p_buffer );
return 0;
}
-/****************************************************************************
- * InitThread: initialize thread data and create output fifo
- ****************************************************************************/
-static int InitThread( spdif_thread_t * p_dec, decoder_fifo_t * p_fifo )
-{
- /* Initialize the thread properties */
- p_dec->p_aout = NULL;
- p_dec->p_aout_input = NULL;
- p_dec->p_fifo = p_fifo;
- p_dec->output_format.i_format = AOUT_FMT_A52;
-
- /* Init the Bitstream */
- InitBitstream( &p_dec->bit_stream, p_dec->p_fifo,
- NULL, NULL );
-
- return 0;
-}
-
/*****************************************************************************
* EndThread : spdif thread destruction
*****************************************************************************/
-static void EndThread( spdif_thread_t * p_dec )
+static void EndThread( dec_thread_t * p_dec )
{
if ( p_dec->p_aout_input != NULL )
{