(see my last mail).
* aout: Rewrote our whole lock policy. The output thread now doesn't require
the mixer_lock, which might avoid delays. We will also be able to change
the filter pipelines at runtime.
* aout_internal.h : internal defines for audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.12 2002/08/25 09:39:59 sam Exp $
+ * $Id: aout_internal.h,v 1.13 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
*****************************************************************************/
struct aout_input_t
{
+ /* When this lock is taken, the pipeline cannot be changed by a
+ * third-party. */
+ vlc_mutex_t lock;
+
audio_sample_format_t input;
aout_alloc_t input_alloc;
{
VLC_COMMON_MEMBERS
+ /* Locks : please note that if you need several of these locks, it is
+ * mandatory (to avoid deadlocks) to take them in the following order :
+ * p_input->lock, mixer_lock, output_fifo_lock, input_fifo_lock.
+ * --Meuuh */
+ /* When input_fifos_lock is taken, none of the p_input->fifo structures
+ * can be read or modified by a third-party thread. */
+ vlc_mutex_t input_fifos_lock;
+ /* When mixer_lock is taken, all decoder threads willing to mix a
+ * buffer must wait until it is released. The output pipeline cannot
+ * be modified. No input stream can be added or removed. */
+ vlc_mutex_t mixer_lock;
+ /* When output_fifo_lock is taken, the p_aout->output.fifo structure
+ * cannot be read or written by a third-party thread. */
+ vlc_mutex_t output_fifo_lock;
+
/* Input streams & pre-filters */
- vlc_mutex_t input_lock;
- vlc_cond_t input_signal;
- int i_inputs_active;
- vlc_bool_t b_change_requested;
aout_input_t * pp_inputs[AOUT_MAX_INPUTS];
int i_nb_inputs;
/* Mixer */
- vlc_mutex_t mixer_lock;
aout_mixer_t mixer;
/* Output plug-in */
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: input_ext-dec.h,v 1.70 2002/08/26 23:00:22 massiot Exp $
+ * $Id: input_ext-dec.h,v 1.71 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
#ifndef _VLC_INPUT_EXT_DEC_H
#define _VLC_INPUT_EXT_DEC_H 1
-/* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers.
- * these values are used in src/input/mpeg_system.c, and in
- * the following plugins: mpeg_ts, mpeg_ts_dvbpsi, input_satellite. */
-#define MPEG1_VIDEO_ES 0x01
-#define MPEG2_VIDEO_ES 0x02
-#define MPEG1_AUDIO_ES 0x03
-#define MPEG2_AUDIO_ES 0x04
-#define A52_AUDIO_ES 0x81
-/* These ones might violate the norm : */
-#define DVD_SPU_ES 0x82
-#define LPCM_AUDIO_ES 0x83
-
/* Structures exported to the decoders */
/*****************************************************************************
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc_common.h,v 1.25 2002/08/29 23:53:22 massiot Exp $
+ * $Id: vlc_common.h,v 1.26 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
*****************************************************************************/
typedef u32 vlc_fourcc_t;
-#define VLC_FOURCC( a, b, c, d ) \
- ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
+#ifdef WORDS_BIGENDIAN
+# define VLC_FOURCC( a, b, c, d ) \
+ ( ((u32)d) | ( ((u32)c) << 8 ) | ( ((u32)b) << 16 ) | ( ((u32)a) << 24 ) )
+# define VLC_TWOCC( a, b ) \
+ ( (u16)(b) | ( (u16)(a) << 8 ) )
-#define VLC_TWOCC( a, b ) \
- ( (u16)(a) | ( (u16)(b) << 8 ) )
+#else
+# define VLC_FOURCC( a, b, c, d ) \
+ ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
+# define VLC_TWOCC( a, b ) \
+ ( (u16)(a) | ( (u16)(b) << 8 ) )
+
+#endif
/*****************************************************************************
* Classes declaration
/* es.c: functions to find and select ES
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: es.c,v 1.1 2002/08/04 17:23:41 sam Exp $
+ * $Id: es.c,v 1.2 2002/08/30 22:22:24 massiot Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
{
case 0x00: /* A52 */
ADDES( 0xbd, 0x80 + audio_status.i_position,
- VLC_FOURCC('a','5','2',' '), AUDIO_ES, i_lang, 0 );
+ VLC_FOURCC('a','5','2','b'), AUDIO_ES, i_lang, 0 );
strcat( p_es->psz_desc, " (A52)" );
break;
break;
case 0x04: /* LPCM */
ADDES( 0xbd, 0xa0 + audio_status.i_position,
- VLC_FOURCC('l','p','c','m'), AUDIO_ES, i_lang, 0 );
+ VLC_FOURCC('l','p','c','b'), AUDIO_ES, i_lang, 0 );
strcat( p_es->psz_desc, " (lpcm)" );
break;
case 0x06: /* DTS */
- i_id = ( ( 0x88 + audio_status.i_position ) << 8 ) | 0xbd;
- msg_Err( p_input, "DTS audio not handled yet (0x%x)", i_id );
+ ADDES( 0xbd, 0x88 + audio_status.i_position,
+ VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang, 0 );
+ strcat( p_es->psz_desc, " (dts)" );
+
break;
default:
i_id = 0;
if( vmg.title.pi_yuv_color )
{
- ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+ ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
vts.manager_inf.p_spu_attr[i-1].i_lang_code,
sizeof(int) + 16*sizeof(u32) );
*(int*)p_es->p_demux_data = 0xBeeF;
}
else
{
- ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+ ADDES( 0xbd, 0x20 + i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
vts.manager_inf.p_spu_attr[i-1].i_lang_code, 0 );
}
}
{
int i_a52 = i_audio;
while( ( p_input->stream.pp_es[i_a52]->i_fourcc !=
- VLC_FOURCC('a','5','2',' ') ) && ( i_a52 <=
+ VLC_FOURCC('a','5','2','b') ) && ( i_a52 <=
p_dvd->p_ifo->vts.manager_inf.i_audio_nb ) )
{
i_a52++;
}
if( p_input->stream.pp_es[i_a52]->i_fourcc
- == VLC_FOURCC('a','5','2',' ') )
+ == VLC_FOURCC('a','5','2','b') )
{
input_SelectES( p_input,
p_input->stream.pp_es[i_a52] );
for( i = 0; i < p_input->stream.i_es_number; i++ )
{
if ( p_input->stream.pp_es[i]->i_fourcc
- == VLC_FOURCC('s','p','u',' ') )
+ == VLC_FOURCC('s','p','u','b') )
{
j++;
if ( i_spu == j ) break;
* es.c: functions to handle elementary streams.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: es.c,v 1.2 2002/08/07 00:29:36 sam Exp $
+ * $Id: es.c,v 1.3 2002/08/30 22:22:24 massiot Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
switch( p_attr->audio_format )
{
case 0x00: /* A52 */
- ADDES( i_id, VLC_FOURCC('a','5','2',' '), AUDIO_ES, i_lang, 0 );
+ ADDES( i_id, VLC_FOURCC('a','5','2','b'), AUDIO_ES, i_lang, 0 );
strcat( p_es->psz_desc, " (A52)" );
break;
break;
case 0x04: /* LPCM */
- ADDES( i_id, VLC_FOURCC('l','p','c','m'), AUDIO_ES, i_lang, 0 );
+ ADDES( i_id, VLC_FOURCC('l','p','c','b'), AUDIO_ES, i_lang, 0 );
strcat( p_es->psz_desc, " (lpcm)" );
break;
case 0x05: /* SDDS */
- msg_Warn( p_input, "SDDS audio not handled" );
+ ADDES( i_id, VLC_FOURCC('s','d','d','b'), AUDIO_ES, i_lang, 0 );
+ strcat( p_es->psz_desc, " (sdds)" );
+
break;
case 0x06: /* DTS */
- msg_Warn( p_input, "DTS audio not handled yet"
- "(0x%x)", i_id );
+ ADDES( i_id, VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang, 0 );
+ strcat( p_es->psz_desc, " (dts)" );
+
break;
default:
i_id = 0;
if( pi_palette )
{
- ADDES( i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+ ADDES( i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
p_attr->lang_code, sizeof(int) + 16*sizeof(u32) );
*(int*)p_es->p_demux_data = 0xBeeF;
memcpy( (void*)p_es->p_demux_data + sizeof(int),
}
else
{
- ADDES( i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
+ ADDES( i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
p_attr->lang_code, 0 );
}
}
while( ( i_a52 < p_dvd->i_audio_nb ) &&
( p_input->stream.pp_es[i_a52]->i_fourcc !=
- VLC_FOURCC('a','5','2',' ') ) )
+ VLC_FOURCC('a','5','2','b') ) )
{
i_a52++;
}
if( p_input->stream.pp_es[i_a52]->i_fourcc ==
- VLC_FOURCC('a','5','2',' ') )
+ VLC_FOURCC('a','5','2','b') )
{
input_SelectES( p_input,
p_input->stream.pp_es[i_a52] );
* It depends on: libdvdread for ifo files and block reading.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: input.c,v 1.3 2002/08/29 23:53:22 massiot Exp $
+ * $Id: input.c,v 1.4 2002/08/30 22:22:24 massiot Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
i_id = ( ( 0x80 + i_position ) << 8 ) | 0xbd;
p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = 0xbd;
- p_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+ p_es->i_fourcc = VLC_FOURCC('a','5','2','b');
p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage(
p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) );
i_id = ( ( 0xa0 + i_position ) << 8 ) | 0xbd;
p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = i_id;
- p_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+ p_es->i_fourcc = VLC_FOURCC('l','p','c','b');
p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage(
p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) );
i_id = ( ( 0x20 + i_position ) << 8 ) | 0xbd;
p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = 0xbd;
- p_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+ p_es->i_fourcc = VLC_FOURCC('s','p','u','b');
p_es->i_cat = SPU_ES;
strcpy( p_es->psz_desc, DecodeLanguage(
p_vts->vtsi_mat->vts_subp_attr[i-1].lang_code ) );
{
int i_a52 = i_audio;
while( ( p_input->stream.pp_es[i_a52]->i_fourcc !=
- VLC_FOURCC('a','5','2',' ') ) && ( i_a52 <=
+ VLC_FOURCC('a','5','2','b') ) && ( i_a52 <=
p_dvd->p_vts_file->vtsi_mat->nr_of_vts_audio_streams ) )
{
i_a52++;
}
if( p_input->stream.pp_es[i_a52]->i_fourcc
- == VLC_FOURCC('a','5','2',' ') )
+ == VLC_FOURCC('a','5','2','b') )
{
input_SelectES( p_input,
p_input->stream.pp_es[i_a52] );
* file.c : audio output which writes the samples to a file
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: file.c,v 1.8 2002/08/19 23:12:57 massiot Exp $
+ * $Id: file.c,v 1.9 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
{
aout_buffer_t * p_buffer;
- /* We don't need the mixer lock, since Play is entered _with_ the
- * mixer lock. */
p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1,
* sdl.c : SDL audio output plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
- * $Id: sdl.c,v 1.7 2002/08/25 16:55:55 sam Exp $
+ * $Id: sdl.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* hardware latency, or the buffer state. So we just pop data and throw
* it at SDL's face. Nah. */
- vlc_mutex_lock( &p_aout->mixer_lock );
+ vlc_mutex_lock( &p_aout->output_fifo_lock );
p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
- vlc_mutex_unlock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
if ( p_buffer != NULL )
{
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: a52.c,v 1.7 2002/08/26 23:00:22 massiot Exp $
+ * $Id: a52.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr>
{
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
- if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') )
+ if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
+ && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
{
return VLC_EGENERIC;
}
* a52old.c: A52 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: a52old.c,v 1.5 2002/08/26 23:00:22 massiot Exp $
+ * $Id: a52old.c,v 1.6 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
{
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
- if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') )
+ if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
+ && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
{
return VLC_EGENERIC;
}
* lpcm.c: lpcm decoder module
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: lpcm.c,v 1.2 2002/08/11 21:59:46 massiot Exp $
+ * $Id: lpcm.c,v 1.3 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org>
{
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
- if( p_fifo->i_fourcc != VLC_FOURCC('l','p','c','m') )
+ if( p_fifo->i_fourcc != VLC_FOURCC('l','p','c','m')
+ && p_fifo->i_fourcc != VLC_FOURCC('l','p','c','b') )
{
return VLC_EGENERIC;
}
* spdif.c: A/52 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001-2002 VideoLAN
- * $Id: spdif.c,v 1.7 2002/08/26 23:00:22 massiot Exp $
+ * $Id: spdif.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
{
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
- if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') )
+ if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
+ && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
{
return VLC_EGENERIC;
}
* spudec.c : SPU decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: spudec.c,v 1.2 2002/08/16 03:07:56 sam Exp $
+ * $Id: spudec.c,v 1.3 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
{
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
- if( p_fifo->i_fourcc == VLC_FOURCC('s','p','u',' ') )
+ if( p_fifo->i_fourcc == VLC_FOURCC('s','p','u',' ')
+ && p_fifo->i_fourcc == VLC_FOURCC('s','p','u','b') )
{
p_fifo->pf_run = RunDecoder;
return VLC_SUCCESS;
* ps.c : Program Stream input module for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: ps.c,v 1.4 2002/08/12 22:48:18 massiot Exp $
+ * $Id: ps.c,v 1.5 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
break;
case VLC_FOURCC('a','5','2',' '):
+ case VLC_FOURCC('a','5','2','b'):
if( config_GetInt( p_input, "audio-channel" )
== ((p_es->i_id & 0xF00) >> 8) ||
( config_GetInt( p_input, "audio-channel" ) < 0
break;
case VLC_FOURCC('s','p','u',' '):
+ case VLC_FOURCC('s','p','u','b'):
if( config_GetInt( p_input, "spu-channel" )
== ((p_es->i_id & 0x1F00) >> 8) )
{
break;
case VLC_FOURCC('l','p','c','m'):
+ case VLC_FOURCC('l','p','c','b'):
if( config_GetInt( p_input, "audio-channel" )
== ((p_es->i_id & 0x1F00) >> 8) ||
( config_GetInt( p_input, "audio-channel" ) < 0
* system.c: helper module for TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: system.c,v 1.1 2002/08/07 00:29:36 sam Exp $
+ * $Id: system.c,v 1.2 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
break;
}
- if( p_es->i_stream_id == 0xbd )
+ /* Welcome to the kludge area ! --Meuuh */
+ if( p_es->i_fourcc == VLC_FOURCC('a','5','2','b') )
{
- /* With private stream 1, the first byte of the payload
- * is a stream_private_id, so skip it. */
- i_pes_header_size++;
+ /* With A/52 audio, we need to skip the first 4 bytes */
+ i_pes_header_size += 4;
}
-
- if( p_es->i_fourcc == VLC_FOURCC('a','5','2',' ') )
+ else if( p_es->i_fourcc == VLC_FOURCC('l','p','c','b')
+ || p_es->i_fourcc == VLC_FOURCC('s','p','u','b')
+ || p_es->i_fourcc == VLC_FOURCC('d','t','s','b')
+ || p_es->i_fourcc == VLC_FOURCC('s','d','d','b') )
{
- /* With A52 audio, we need to skip first 3 bytes */
- i_pes_header_size += 3;
+ /* With others, we need to skip the first byte */
+ i_pes_header_size += 1;
}
/* Now we've parsed the header, we just have to indicate in some
p_es->i_cat = VIDEO_ES;
break;
case DVD_SPU_ES:
- p_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+ p_es->i_fourcc = VLC_FOURCC('s','p','u','b');
p_es->i_cat = SPU_ES;
break;
case MPEG1_AUDIO_ES:
p_es->i_cat = AUDIO_ES;
break;
case A52_AUDIO_ES:
- p_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+ p_es->i_fourcc = VLC_FOURCC('a','5','2','b');
p_es->i_cat = AUDIO_ES;
break;
case LPCM_AUDIO_ES:
- p_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+ p_es->i_fourcc = VLC_FOURCC('l','p','c','b');
p_es->i_cat = AUDIO_ES;
break;
default:
else if( (i_id & 0xF0FF) == 0x80BD )
{
/* A52 audio (0x80->0x8F) */
- p_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+ p_es->i_fourcc = VLC_FOURCC('a','5','2','b');
p_es->i_cat = AUDIO_ES;
#ifdef AUTO_SPAWN
if( !p_input->stream.b_seekable )
else if( (i_id & 0xE0FF) == 0x20BD )
{
/* Subtitles video (0x20->0x3F) */
- p_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+ p_es->i_fourcc = VLC_FOURCC('s','p','u','b');
p_es->i_cat = SPU_ES;
#ifdef AUTO_SPAWN
if( config_GetInt( p_input, "spu-channel" )
else if( (i_id & 0xF0FF) == 0xA0BD )
{
/* LPCM audio (0xA0->0xAF) */
- p_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+ p_es->i_fourcc = VLC_FOURCC('l','p','c','b');
p_es->i_cat = AUDIO_ES;
}
else
* system.h: MPEG demultiplexing.
*****************************************************************************
* Copyright (C) 1999-2002 VideoLAN
- * $Id: system.h,v 1.1 2002/08/07 00:29:36 sam Exp $
+ * $Id: system.h,v 1.2 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
#define PSI_IS_PMT 0x01
#define UNKNOWN_PSI 0xff
+/* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers.
+ * these values are used in mpeg_system.c, and in
+ * the following plugins: mpeg_ts, mpeg_ts_dvbpsi, satellite. */
+#define MPEG1_VIDEO_ES 0x01
+#define MPEG2_VIDEO_ES 0x02
+#define MPEG1_AUDIO_ES 0x03
+#define MPEG2_AUDIO_ES 0x04
+#define A52_AUDIO_ES 0x81
+/* These ones might violate the usage : */
+#define DVD_SPU_ES 0x82
+#define LPCM_AUDIO_ES 0x83
+#define SDDS_AUDIO_ES 0x84
+#define DTS_AUDIO_ES 0x85
+/* These ones are only here to work around a bug in VLS - VLS doesn't
+ * skip the first bytes of the PES payload (stream private ID) when
+ * streaming. This is incompatible with all equipments. 'B' is for
+ * buggy. Please note that they are associated with FOURCCs '***b'.
+ * --Meuuh 2002-08-30
+ */
+#define A52B_AUDIO_ES 0x91
+#define DVDB_SPU_ES 0x92
+#define LPCMB_AUDIO_ES 0x93
+
/****************************************************************************
* psi_callback_t
****************************************************************************
* mpeg_ts.c : Transport Stream input module for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: ts.c,v 1.3 2002/08/08 22:28:22 sam Exp $
+ * $Id: ts.c,v 1.4 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Henri Fallon <henri@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a');
p_new_es->i_cat = AUDIO_ES;
break;
- case LPCM_AUDIO_ES:
- p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
+ case A52_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES;
break;
- case A52_AUDIO_ES:
- p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+ case LPCM_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES;
break;
- /* Not sure this one is fully specification-compliant */
case DVD_SPU_ES:
p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = SPU_ES;
break;
+ case SDDS_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('s','d','d','s');
+ p_new_es->i_stream_id = 0xBD;
+ p_new_es->i_cat = AUDIO_ES;
+ break;
+ case DTS_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('d','t','s',' ');
+ p_new_es->i_stream_id = 0xBD;
+ p_new_es->i_cat = AUDIO_ES;
+ break;
+ /* 'b' stands for 'buggy' */
+ case A52B_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('a','5','2','b');
+ p_new_es->i_stream_id = 0xBD;
+ p_new_es->i_cat = AUDIO_ES;
+ break;
+ case LPCMB_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('l','p','c','b');
+ p_new_es->i_stream_id = 0xBD;
+ p_new_es->i_cat = AUDIO_ES;
+ break;
+ case DVDB_SPU_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('s','p','u','b');
+ p_new_es->i_stream_id = 0xBD;
+ p_new_es->i_cat = SPU_ES;
+ break;
default :
p_new_es->i_fourcc = 0;
p_new_es->i_cat = UNKNOWN_ES;
p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a');
p_new_es->i_cat = AUDIO_ES;
break;
+ case A52_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+ p_new_es->i_cat = AUDIO_ES;
+ p_new_es->i_stream_id = 0xBD;
+ break;
+ case DVD_SPU_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+ p_new_es->i_cat = SPU_ES;
+ p_new_es->i_stream_id = 0xBD;
+ break;
case LPCM_AUDIO_ES:
p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
p_new_es->i_cat = AUDIO_ES;
p_new_es->i_stream_id = 0xBD;
break;
- case A52_AUDIO_ES:
- p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
+ case SDDS_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('s','d','d','s');
+ p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES;
+ break;
+ case DTS_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('d','t','s',' ');
p_new_es->i_stream_id = 0xBD;
+ p_new_es->i_cat = AUDIO_ES;
break;
- case DVD_SPU_ES:
- p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
+ case A52B_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('a','5','2','b');
+ p_new_es->i_cat = AUDIO_ES;
+ p_new_es->i_stream_id = 0xBD;
+ break;
+ case DVDB_SPU_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('s','p','u','b');
p_new_es->i_cat = SPU_ES;
p_new_es->i_stream_id = 0xBD;
break;
+ case LPCMB_AUDIO_ES:
+ p_new_es->i_fourcc = VLC_FOURCC('l','p','c','b');
+ p_new_es->i_cat = AUDIO_ES;
+ p_new_es->i_stream_id = 0xBD;
+ break;
default:
p_new_es->i_fourcc = 0;
p_new_es->i_cat = UNKNOWN_ES;
strcat( p_new_es->psz_desc, " (mpeg)" );
break;
case LPCM_AUDIO_ES:
+ case LPCMB_AUDIO_ES:
strcat( p_new_es->psz_desc, " (lpcm)" );
break;
case A52_AUDIO_ES:
+ case A52B_AUDIO_ES:
strcat( p_new_es->psz_desc, " (A52)" );
break;
}
* aout_dummy.c : dummy audio output plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: aout.c,v 1.6 2002/08/19 23:12:57 massiot Exp $
+ * $Id: aout.c,v 1.7 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
*****************************************************************************/
static void Play( aout_instance_t * p_aout )
{
- /* We don't need the mixer lock, since Play is entered _with_ the
- * mixer lock. */
aout_buffer_t * p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
aout_BufferFree( p_buffer );
}
* audio_output.c : audio output instance miscellaneous functions
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: audio_output.c,v 1.99 2002/08/21 22:41:59 massiot Exp $
+ * $Id: audio_output.c,v 1.100 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
}
/* Initialize members. */
- vlc_mutex_init( p_parent, &p_aout->input_lock );
- vlc_cond_init( p_parent, &p_aout->input_signal );
- p_aout->i_inputs_active = 0;
- p_aout->b_change_requested = 0;
- p_aout->i_nb_inputs = 0;
-
+ vlc_mutex_init( p_parent, &p_aout->input_fifos_lock );
vlc_mutex_init( p_parent, &p_aout->mixer_lock );
+ vlc_mutex_init( p_parent, &p_aout->output_fifo_lock );
+ p_aout->i_nb_inputs = 0;
vlc_object_attach( p_aout, p_parent->p_vlc );
*****************************************************************************/
void aout_DeleteInstance( aout_instance_t * p_aout )
{
- vlc_mutex_destroy( &p_aout->input_lock );
- vlc_cond_destroy( &p_aout->input_signal );
+ vlc_mutex_destroy( &p_aout->input_fifos_lock );
vlc_mutex_destroy( &p_aout->mixer_lock );
+ vlc_mutex_destroy( &p_aout->output_fifo_lock );
/* Free structure. */
vlc_object_destroy( p_aout );
* filters.c : audio output filters management
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: filters.c,v 1.7 2002/08/28 22:25:39 massiot Exp $
+ * $Id: filters.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
return 0;
}
- /* We'll have to split the conversion. We always to the downmixing
+ /* We'll have to split the conversion. We always do the downmixing
* before the resampling, and the upmixing after the resampling (to
* maximize the resampling efficiency). */
b_rate_first = (p_input_format->i_channels < p_output_format->i_channels);
* input.c : internal management of input streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: input.c,v 1.10 2002/08/28 22:25:39 massiot Exp $
+ * $Id: input.c,v 1.11 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
static aout_input_t * InputNew( aout_instance_t * p_aout,
audio_sample_format_t * p_format )
{
- aout_input_t * p_input = malloc(sizeof(aout_input_t));
-
- if ( p_input == NULL ) return NULL;
+ aout_input_t * p_input;
vlc_mutex_lock( &p_aout->mixer_lock );
+ if ( p_aout->i_nb_inputs >= AOUT_MAX_INPUTS )
+ {
+ msg_Err( p_aout, "too many inputs already (%d)", p_aout->i_nb_inputs );
+ vlc_mutex_unlock( &p_aout->mixer_lock );
+ return NULL;
+ }
+
+ p_input = malloc(sizeof(aout_input_t));
+ if ( p_input == NULL )
+ {
+ msg_Err( p_aout, "out of memory" );
+ vlc_mutex_unlock( &p_aout->mixer_lock );
+ return NULL;
+ }
+
+ vlc_mutex_init( p_aout, &p_input->lock );
+ vlc_mutex_lock( &p_input->lock );
+
if ( p_aout->i_nb_inputs == 0 )
{
/* Recreate the output using the new format. */
if ( aout_OutputNew( p_aout, p_format ) < 0 )
{
+ vlc_mutex_unlock( &p_input->lock );
+ vlc_mutex_destroy( &p_input->lock );
free( p_input );
+ vlc_mutex_unlock( &p_aout->mixer_lock );
return NULL;
}
}
aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
p_input->p_first_byte_to_mix = NULL;
- /* Create filters. */
- if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
- &p_input->i_nb_filters, &p_input->input,
- &p_aout->mixer.mixer ) < 0 )
- {
- msg_Err( p_aout, "couldn't set an input pipeline" );
-
- aout_FifoDestroy( p_aout, &p_input->fifo );
-
- free( p_input );
-
- if ( !p_aout->i_nb_inputs )
- {
- aout_OutputDelete( p_aout );
- }
- return NULL;
- }
-
p_aout->pp_inputs[p_aout->i_nb_inputs] = p_input;
p_aout->i_nb_inputs++;
p_input->i_nb_filters );
aout_FifoDestroy( p_aout, &p_input->fifo );
- free( p_input );
-
if ( !p_aout->i_nb_inputs )
{
aout_OutputDelete( p_aout );
{
aout_MixerNew( p_aout );
}
+ vlc_mutex_unlock( &p_input->lock );
+ vlc_mutex_destroy( &p_input->lock );
+ free( p_input );
vlc_mutex_unlock( &p_aout->mixer_lock );
return NULL;
vlc_mutex_unlock( &p_aout->mixer_lock );
+ /* Create filters. */
+ if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
+ &p_input->i_nb_filters, &p_input->input,
+ &p_aout->mixer.mixer ) < 0 )
+ {
+ msg_Err( p_aout, "couldn't set an input pipeline" );
+
+ aout_FifoDestroy( p_aout, &p_input->fifo );
+
+ vlc_mutex_unlock( &p_input->lock );
+ vlc_mutex_destroy( &p_input->lock );
+ free( p_input );
+ vlc_mutex_unlock( &p_aout->mixer_lock );
+
+ if ( !p_aout->i_nb_inputs )
+ {
+ aout_OutputDelete( p_aout );
+ }
+ return NULL;
+ }
+
/* Prepare hints for the buffer allocator. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
p_input->input_alloc.i_bytes_per_sec = -1;
/* Allocate in the heap, it is more convenient for the decoder. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
+ vlc_mutex_unlock( &p_input->lock );
+
msg_Dbg( p_aout, "input 0x%x created", p_input );
return p_input;
}
int i_input;
vlc_mutex_lock( &p_aout->mixer_lock );
+ vlc_mutex_lock( &p_input->lock );
for ( i_input = 0; i_input < p_aout->i_nb_inputs; i_input++ )
{
(AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) );
p_aout->i_nb_inputs--;
+ if ( !p_aout->i_nb_inputs )
+ {
+ aout_OutputDelete( p_aout );
+ aout_MixerDelete( p_aout );
+ }
+
vlc_mutex_unlock( &p_aout->mixer_lock );
aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
p_input->i_nb_filters );
aout_FifoDestroy( p_aout, &p_input->fifo );
+ vlc_mutex_unlock( &p_input->lock );
+ vlc_mutex_destroy( &p_input->lock );
free( p_input );
- if ( !p_aout->i_nb_inputs )
- {
- aout_OutputDelete( p_aout );
- aout_MixerDelete( p_aout );
- }
-
msg_Dbg( p_aout, "input 0x%x destroyed", p_input );
}
{
mtime_t start_date, duration;
- vlc_mutex_lock( &p_aout->input_lock );
- while( p_aout->b_change_requested )
- {
- vlc_cond_wait( &p_aout->input_signal, &p_aout->input_lock );
- }
- p_aout->i_inputs_active++;
- vlc_mutex_unlock( &p_aout->input_lock );
+ vlc_mutex_lock( &p_input->lock );
/* We don't care if someone changes the start date behind our back after
* this. We'll deal with that when pushing the buffer, and compensate
mdate() - p_buffer->start_date );
aout_BufferFree( p_buffer );
- vlc_mutex_lock( &p_aout->input_lock );
- p_aout->i_inputs_active--;
- vlc_cond_broadcast( &p_aout->input_signal );
- vlc_mutex_unlock( &p_aout->input_lock );
+ vlc_mutex_unlock( &p_input->lock );
return;
}
vlc_mutex_unlock( &p_aout->mixer_lock );
aout_BufferFree( p_buffer );
- vlc_mutex_lock( &p_aout->input_lock );
- p_aout->i_inputs_active--;
- vlc_cond_broadcast( &p_aout->input_signal );
- vlc_mutex_unlock( &p_aout->input_lock );
+ vlc_mutex_unlock( &p_input->lock );
return;
}
&p_buffer );
}
- vlc_mutex_lock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_input->lock );
+
+ vlc_mutex_lock( &p_aout->input_fifos_lock );
/* Adding the start date will be managed by aout_FifoPush(). */
p_buffer->start_date = start_date;
p_buffer->end_date = start_date + duration;
aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
- vlc_mutex_unlock( &p_aout->mixer_lock );
-
- vlc_mutex_lock( &p_aout->input_lock );
- p_aout->i_inputs_active--;
- vlc_cond_broadcast( &p_aout->input_signal );
- vlc_mutex_unlock( &p_aout->input_lock );
+ vlc_mutex_unlock( &p_aout->input_fifos_lock );
}
* mixer.c : audio output mixing operations
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: mixer.c,v 1.10 2002/08/26 23:00:23 massiot Exp $
+ * $Id: mixer.c,v 1.11 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
/*****************************************************************************
* aout_MixerNew: prepare a mixer plug-in
+ *****************************************************************************
+ * Please note that you must hold the mixer lock.
*****************************************************************************/
int aout_MixerNew( aout_instance_t * p_aout )
{
/*****************************************************************************
* aout_MixerDelete: delete the mixer
+ *****************************************************************************
+ * Please note that you must hold the mixer lock.
*****************************************************************************/
void aout_MixerDelete( aout_instance_t * p_aout )
{
audio_date_t exact_start_date;
vlc_mutex_lock( &p_aout->mixer_lock );
+ vlc_mutex_lock( &p_aout->output_fifo_lock );
+ vlc_mutex_lock( &p_aout->input_fifos_lock );
/* Retrieve the date of the next buffer. */
memcpy( &exact_start_date, &p_aout->output.fifo.end_date,
start_date = 0;
}
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
+
/* See if we have enough data to prepare a new buffer for the audio
* output. First : start date. */
if ( !start_date )
if ( i < p_aout->i_nb_inputs )
{
/* Interrupted before the end... We can't run. */
+ vlc_mutex_unlock( &p_aout->input_fifos_lock );
vlc_mutex_unlock( &p_aout->mixer_lock );
return -1;
}
if ( i < p_aout->i_nb_inputs )
{
/* Interrupted before the end... We can't run. */
+ vlc_mutex_unlock( &p_aout->input_fifos_lock );
vlc_mutex_unlock( &p_aout->mixer_lock );
return -1;
}
if ( p_output_buffer == NULL )
{
msg_Err( p_aout, "out of memory" );
+ vlc_mutex_unlock( &p_aout->input_fifos_lock );
vlc_mutex_unlock( &p_aout->mixer_lock );
return -1;
}
p_aout->mixer.pf_do_work( p_aout, p_output_buffer );
- vlc_mutex_unlock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_aout->input_fifos_lock );
aout_OutputPlay( p_aout, p_output_buffer );
+ vlc_mutex_unlock( &p_aout->mixer_lock );
+
return 0;
}
* output.c : internal management of output streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.12 2002/08/25 16:55:55 sam Exp $
+ * $Id: output.c,v 1.13 2002/08/30 22:22:24 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
/*****************************************************************************
* aout_OutputNew : allocate a new output and rework the filter pipeline
+ *****************************************************************************
+ * This function is entered with the mixer_lock.
*****************************************************************************/
int aout_OutputNew( aout_instance_t * p_aout,
audio_sample_format_t * p_format )
AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32;
}
+ vlc_mutex_lock( &p_aout->output_fifo_lock );
+
/* Find the best output format. */
if ( p_aout->output.pf_setformat( p_aout ) != 0 )
{
msg_Err( p_aout, "couldn't set an output format" );
module_Unneed( p_aout, p_aout->output.p_module );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
return -1;
}
aout_FormatPrepare( &p_aout->output.output );
/* Prepare FIFO. */
aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
+
msg_Dbg( p_aout, "output format=%d rate=%d channels=%d",
p_aout->output.output.i_format, p_aout->output.output.i_rate,
p_aout->output.output.i_channels );
/*****************************************************************************
* aout_OutputDelete : delete the output
+ *****************************************************************************
+ * This function is entered with the mixer_lock.
*****************************************************************************/
void aout_OutputDelete( aout_instance_t * p_aout )
{
/*****************************************************************************
* aout_OutputPlay : play a buffer
+ *****************************************************************************
+ * This function is entered with the mixer_lock.
*****************************************************************************/
void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{
p_aout->output.i_nb_filters,
&p_buffer );
- vlc_mutex_lock( &p_aout->mixer_lock );
+ vlc_mutex_lock( &p_aout->output_fifo_lock );
aout_FifoPush( p_aout, &p_aout->output.fifo, p_buffer );
p_aout->output.pf_play( p_aout );
- vlc_mutex_unlock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
}
/*****************************************************************************
{
aout_buffer_t * p_buffer;
- vlc_mutex_lock( &p_aout->mixer_lock );
+ vlc_mutex_lock( &p_aout->output_fifo_lock );
p_buffer = p_aout->output.fifo.p_first;
while ( p_buffer && p_buffer->start_date < start_date )
p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first;
/* Set date to 0, to allow the mixer to send a new buffer ASAP */
aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
- vlc_mutex_unlock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
msg_Dbg( p_aout,
"audio output is starving (no input), playing silence" );
return NULL;
if ( p_buffer->start_date > start_date
+ (p_buffer->end_date - p_buffer->start_date) )
{
- vlc_mutex_unlock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
msg_Dbg( p_aout, "audio output is starving (%lld), playing silence",
p_buffer->start_date - start_date );
return NULL;
msg_Warn( p_aout, "output date isn't PTS date, resampling (%lld)",
difference );
- /* Remember that we still own the mixer lock. */
+ vlc_mutex_lock( &p_aout->input_fifos_lock );
for ( i = 0; i < p_aout->i_nb_inputs; i++ )
{
aout_fifo_t * p_fifo = &p_aout->pp_inputs[i]->fifo;
}
aout_FifoMoveDates( p_aout, &p_aout->output.fifo, difference );
+ vlc_mutex_unlock( &p_aout->input_fifos_lock );
}
p_aout->output.fifo.p_first = p_buffer->p_next;
p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first;
}
- vlc_mutex_unlock( &p_aout->mixer_lock );
+ vlc_mutex_unlock( &p_aout->output_fifo_lock );
return p_buffer;
}