Commit 0b88e775 authored by Christophe Massiot's avatar Christophe Massiot

* demuxes: Worked around a bug in old VLC and VLS by changing TS stream types

  (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.
parent b7d33a0d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output * aout_internal.h : internal defines for audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: aout_internal.h,v 1.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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -126,6 +126,10 @@ typedef struct aout_mixer_t ...@@ -126,6 +126,10 @@ typedef struct aout_mixer_t
*****************************************************************************/ *****************************************************************************/
struct aout_input_t 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; audio_sample_format_t input;
aout_alloc_t input_alloc; aout_alloc_t input_alloc;
...@@ -166,16 +170,26 @@ struct aout_instance_t ...@@ -166,16 +170,26 @@ struct aout_instance_t
{ {
VLC_COMMON_MEMBERS 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 */ /* 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]; aout_input_t * pp_inputs[AOUT_MAX_INPUTS];
int i_nb_inputs; int i_nb_inputs;
/* Mixer */ /* Mixer */
vlc_mutex_t mixer_lock;
aout_mixer_t mixer; aout_mixer_t mixer;
/* Output plug-in */ /* Output plug-in */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders * input_ext-dec.h: structures exported to the VideoLAN decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr> * Michel Kaempf <maxx@via.ecp.fr>
...@@ -25,18 +25,6 @@ ...@@ -25,18 +25,6 @@
#ifndef _VLC_INPUT_EXT_DEC_H #ifndef _VLC_INPUT_EXT_DEC_H
#define _VLC_INPUT_EXT_DEC_H 1 #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 */ /* Structures exported to the decoders */
/***************************************************************************** /*****************************************************************************
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -133,12 +133,20 @@ typedef s64 mtime_t; ...@@ -133,12 +133,20 @@ typedef s64 mtime_t;
*****************************************************************************/ *****************************************************************************/
typedef u32 vlc_fourcc_t; typedef u32 vlc_fourcc_t;
#define VLC_FOURCC( a, b, c, d ) \ #ifdef WORDS_BIGENDIAN
( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) ) # 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 ) \ #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 ) ) ( (u16)(a) | ( (u16)(b) << 8 ) )
#endif
/***************************************************************************** /*****************************************************************************
* Classes declaration * Classes declaration
*****************************************************************************/ *****************************************************************************/
......
/* es.c: functions to find and select ES /* es.c: functions to find and select ES
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * 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: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -137,7 +137,7 @@ void DVDReadAudio( input_thread_t * p_input ) ...@@ -137,7 +137,7 @@ void DVDReadAudio( input_thread_t * p_input )
{ {
case 0x00: /* A52 */ case 0x00: /* A52 */
ADDES( 0xbd, 0x80 + audio_status.i_position, 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)" ); strcat( p_es->psz_desc, " (A52)" );
break; break;
...@@ -150,13 +150,15 @@ void DVDReadAudio( input_thread_t * p_input ) ...@@ -150,13 +150,15 @@ void DVDReadAudio( input_thread_t * p_input )
break; break;
case 0x04: /* LPCM */ case 0x04: /* LPCM */
ADDES( 0xbd, 0xa0 + audio_status.i_position, 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)" ); strcat( p_es->psz_desc, " (lpcm)" );
break; break;
case 0x06: /* DTS */ case 0x06: /* DTS */
i_id = ( ( 0x88 + audio_status.i_position ) << 8 ) | 0xbd; ADDES( 0xbd, 0x88 + audio_status.i_position,
msg_Err( p_input, "DTS audio not handled yet (0x%x)", i_id ); VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang, 0 );
strcat( p_es->psz_desc, " (dts)" );
break; break;
default: default:
i_id = 0; i_id = 0;
...@@ -219,7 +221,7 @@ void DVDReadSPU( input_thread_t * p_input ) ...@@ -219,7 +221,7 @@ void DVDReadSPU( input_thread_t * p_input )
if( vmg.title.pi_yuv_color ) 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, vts.manager_inf.p_spu_attr[i-1].i_lang_code,
sizeof(int) + 16*sizeof(u32) ); sizeof(int) + 16*sizeof(u32) );
*(int*)p_es->p_demux_data = 0xBeeF; *(int*)p_es->p_demux_data = 0xBeeF;
...@@ -228,7 +230,7 @@ void DVDReadSPU( input_thread_t * p_input ) ...@@ -228,7 +230,7 @@ void DVDReadSPU( input_thread_t * p_input )
} }
else 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 ); vts.manager_inf.p_spu_attr[i-1].i_lang_code, 0 );
} }
} }
...@@ -273,13 +275,13 @@ void DVDLaunchDecoders( input_thread_t * p_input ) ...@@ -273,13 +275,13 @@ void DVDLaunchDecoders( input_thread_t * p_input )
{ {
int i_a52 = i_audio; int i_a52 = i_audio;
while( ( p_input->stream.pp_es[i_a52]->i_fourcc != 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 ) ) p_dvd->p_ifo->vts.manager_inf.i_audio_nb ) )
{ {
i_a52++; i_a52++;
} }
if( p_input->stream.pp_es[i_a52]->i_fourcc 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, input_SelectES( p_input,
p_input->stream.pp_es[i_a52] ); p_input->stream.pp_es[i_a52] );
...@@ -308,7 +310,7 @@ void DVDLaunchDecoders( input_thread_t * p_input ) ...@@ -308,7 +310,7 @@ void DVDLaunchDecoders( input_thread_t * p_input )
for( i = 0; i < p_input->stream.i_es_number; i++ ) for( i = 0; i < p_input->stream.i_es_number; i++ )
{ {
if ( p_input->stream.pp_es[i]->i_fourcc if ( p_input->stream.pp_es[i]->i_fourcc
== VLC_FOURCC('s','p','u',' ') ) == VLC_FOURCC('s','p','u','b') )
{ {
j++; j++;
if ( i_spu == j ) break; if ( i_spu == j ) break;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* es.c: functions to handle elementary streams. * es.c: functions to handle elementary streams.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -143,7 +143,7 @@ void dvdplay_Audio( input_thread_t * p_input ) ...@@ -143,7 +143,7 @@ void dvdplay_Audio( input_thread_t * p_input )
switch( p_attr->audio_format ) switch( p_attr->audio_format )
{ {
case 0x00: /* A52 */ 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)" ); strcat( p_es->psz_desc, " (A52)" );
break; break;
...@@ -154,16 +154,19 @@ void dvdplay_Audio( input_thread_t * p_input ) ...@@ -154,16 +154,19 @@ void dvdplay_Audio( input_thread_t * p_input )
break; break;
case 0x04: /* LPCM */ 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)" ); strcat( p_es->psz_desc, " (lpcm)" );
break; break;
case 0x05: /* SDDS */ 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; break;
case 0x06: /* DTS */ case 0x06: /* DTS */
msg_Warn( p_input, "DTS audio not handled yet" ADDES( i_id, VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang, 0 );
"(0x%x)", i_id ); strcat( p_es->psz_desc, " (dts)" );
break; break;
default: default:
i_id = 0; i_id = 0;
...@@ -203,7 +206,7 @@ void dvdplay_Subp( input_thread_t * p_input ) ...@@ -203,7 +206,7 @@ void dvdplay_Subp( input_thread_t * p_input )
if( pi_palette ) 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) ); p_attr->lang_code, sizeof(int) + 16*sizeof(u32) );
*(int*)p_es->p_demux_data = 0xBeeF; *(int*)p_es->p_demux_data = 0xBeeF;
memcpy( (void*)p_es->p_demux_data + sizeof(int), memcpy( (void*)p_es->p_demux_data + sizeof(int),
...@@ -211,7 +214,7 @@ void dvdplay_Subp( input_thread_t * p_input ) ...@@ -211,7 +214,7 @@ void dvdplay_Subp( input_thread_t * p_input )
} }
else 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 ); p_attr->lang_code, 0 );
} }
} }
...@@ -250,12 +253,12 @@ void dvdplay_LaunchDecoders( input_thread_t * p_input ) ...@@ -250,12 +253,12 @@ void dvdplay_LaunchDecoders( input_thread_t * p_input )
while( ( i_a52 < p_dvd->i_audio_nb ) && while( ( i_a52 < p_dvd->i_audio_nb ) &&
( p_input->stream.pp_es[i_a52]->i_fourcc != ( p_input->stream.pp_es[i_a52]->i_fourcc !=
VLC_FOURCC('a','5','2',' ') ) ) VLC_FOURCC('a','5','2','b') ) )
{ {
i_a52++; i_a52++;
} }
if( p_input->stream.pp_es[i_a52]->i_fourcc == 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, input_SelectES( p_input,
p_input->stream.pp_es[i_a52] ); p_input->stream.pp_es[i_a52] );
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* It depends on: libdvdread for ifo files and block reading. * It depends on: libdvdread for ifo files and block reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -679,7 +679,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -679,7 +679,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area )
i_id = ( ( 0x80 + i_position ) << 8 ) | 0xbd; i_id = ( ( 0x80 + i_position ) << 8 ) | 0xbd;
p_es = input_AddES( p_input, NULL, i_id, 0 ); p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = 0xbd; 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; p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage( strcpy( p_es->psz_desc, DecodeLanguage(
p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) ); p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) );
...@@ -703,7 +703,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -703,7 +703,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area )
i_id = ( ( 0xa0 + i_position ) << 8 ) | 0xbd; i_id = ( ( 0xa0 + i_position ) << 8 ) | 0xbd;
p_es = input_AddES( p_input, NULL, i_id, 0 ); p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = i_id; 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; p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage( strcpy( p_es->psz_desc, DecodeLanguage(
p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) ); p_vts->vtsi_mat->vts_audio_attr[i-1].lang_code ) );
...@@ -766,7 +766,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -766,7 +766,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area )
i_id = ( ( 0x20 + i_position ) << 8 ) | 0xbd; i_id = ( ( 0x20 + i_position ) << 8 ) | 0xbd;
p_es = input_AddES( p_input, NULL, i_id, 0 ); p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = 0xbd; 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; p_es->i_cat = SPU_ES;
strcpy( p_es->psz_desc, DecodeLanguage( strcpy( p_es->psz_desc, DecodeLanguage(
p_vts->vtsi_mat->vts_subp_attr[i-1].lang_code ) ); p_vts->vtsi_mat->vts_subp_attr[i-1].lang_code ) );
...@@ -1226,13 +1226,13 @@ static void DvdReadLauchDecoders( input_thread_t * p_input ) ...@@ -1226,13 +1226,13 @@ static void DvdReadLauchDecoders( input_thread_t * p_input )
{ {
int i_a52 = i_audio; int i_a52 = i_audio;
while( ( p_input->stream.pp_es[i_a52]->i_fourcc != 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 ) ) p_dvd->p_vts_file->vtsi_mat->nr_of_vts_audio_streams ) )
{ {
i_a52++; i_a52++;
} }
if( p_input->stream.pp_es[i_a52]->i_fourcc 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, input_SelectES( p_input,
p_input->stream.pp_es[i_a52] ); p_input->stream.pp_es[i_a52] );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* file.c : audio output which writes the samples to a file * file.c : audio output which writes the samples to a file
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: file.c,v 1.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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -150,8 +150,6 @@ static void Play( aout_instance_t * p_aout ) ...@@ -150,8 +150,6 @@ static void Play( aout_instance_t * p_aout )
{ {
aout_buffer_t * p_buffer; 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 ); p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1, if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sdl.c : SDL audio output plugin for vlc * sdl.c : SDL audio output plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2002 VideoLAN * 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> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -167,9 +167,9 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len ) ...@@ -167,9 +167,9 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len )
* hardware latency, or the buffer state. So we just pop data and throw * hardware latency, or the buffer state. So we just pop data and throw
* it at SDL's face. Nah. */ * 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 ); 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 ) if ( p_buffer != NULL )
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* (http://liba52.sf.net/). * (http://liba52.sf.net/).
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -118,7 +118,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -118,7 +118,8 @@ static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 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; return VLC_EGENERIC;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* a52old.c: A52 decoder module main file * a52old.c: A52 decoder module main file
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Michel Lespinasse <walken@zoy.org>
* *
...@@ -77,7 +77,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -77,7 +77,8 @@ static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 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; return VLC_EGENERIC;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lpcm.c: lpcm decoder module * lpcm.c: lpcm decoder module
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
...@@ -64,7 +64,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -64,7 +64,8 @@ static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 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; return VLC_EGENERIC;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spdif.c: A/52 pass-through to external decoder with enabled soundcard * spdif.c: A/52 pass-through to external decoder with enabled soundcard
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2002 VideoLAN * 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: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi> * Juha Yrjola <jyrjola@cc.hut.fi>
...@@ -100,7 +100,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -100,7 +100,8 @@ static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 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; return VLC_EGENERIC;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spudec.c : SPU decoder thread * spudec.c : SPU decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -68,7 +68,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -68,7 +68,8 @@ static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; 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; p_fifo->pf_run = RunDecoder;
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ps.c : Program Stream input module for vlc * ps.c : Program Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -227,6 +227,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -227,6 +227,7 @@ static int Activate( vlc_object_t * p_this )
break; break;
case VLC_FOURCC('a','5','2',' '): case VLC_FOURCC('a','5','2',' '):
case VLC_FOURCC('a','5','2','b'):
if( config_GetInt( p_input, "audio-channel" ) if( config_GetInt( p_input, "audio-channel" )
== ((p_es->i_id & 0xF00) >> 8) || == ((p_es->i_id & 0xF00) >> 8) ||
( config_GetInt( p_input, "audio-channel" ) < 0 ( config_GetInt( p_input, "audio-channel" ) < 0
...@@ -240,6 +241,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -240,6 +241,7 @@ static int Activate( vlc_object_t * p_this )
break; break;
case VLC_FOURCC('s','p','u',' '): case VLC_FOURCC('s','p','u',' '):
case VLC_FOURCC('s','p','u','b'):
if( config_GetInt( p_input, "spu-channel" ) if( config_GetInt( p_input, "spu-channel" )
== ((p_es->i_id & 0x1F00) >> 8) ) == ((p_es->i_id & 0x1F00) >> 8) )
{ {
...@@ -248,6 +250,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -248,6 +250,7 @@ static int Activate( vlc_object_t * p_this )
break; break;
case VLC_FOURCC('l','p','c','m'): case VLC_FOURCC('l','p','c','m'):
case VLC_FOURCC('l','p','c','b'):
if( config_GetInt( p_input, "audio-channel" ) if( config_GetInt( p_input, "audio-channel" )
== ((p_es->i_id & 0x1F00) >> 8) || == ((p_es->i_id & 0x1F00) >> 8) ||
( config_GetInt( p_input, "audio-channel" ) < 0 ( config_GetInt( p_input, "audio-channel" ) < 0
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* system.c: helper module for TS, PS and PES management * system.c: helper module for TS, PS and PES management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -363,17 +363,19 @@ static void ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -363,17 +363,19 @@ static void ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
break; 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 /* With A/52 audio, we need to skip the first 4 bytes */
* is a stream_private_id, so skip it. */ i_pes_header_size += 4;
i_pes_header_size++;
} }
else if( p_es->i_fourcc == VLC_FOURCC('l','p','c','b')
if( p_es->i_fourcc == VLC_FOURCC('a','5','2',' ') ) || 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 */ /* With others, we need to skip the first byte */
i_pes_header_size += 3; i_pes_header_size += 1;
} }
/* Now we've parsed the header, we just have to indicate in some /* Now we've parsed the header, we just have to indicate in some
...@@ -642,7 +644,7 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -642,7 +644,7 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
p_es->i_cat = VIDEO_ES; p_es->i_cat = VIDEO_ES;
break; break;
case DVD_SPU_ES: 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; p_es->i_cat = SPU_ES;
break; break;
case MPEG1_AUDIO_ES: case MPEG1_AUDIO_ES:
...@@ -651,11 +653,11 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -651,11 +653,11 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
p_es->i_cat = AUDIO_ES; p_es->i_cat = AUDIO_ES;
break; break;
case A52_AUDIO_ES: 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; p_es->i_cat = AUDIO_ES;
break; break;
case LPCM_AUDIO_ES: 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; p_es->i_cat = AUDIO_ES;
break; break;
default: default:
...@@ -876,7 +878,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input, ...@@ -876,7 +878,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input,
else if( (i_id & 0xF0FF) == 0x80BD ) else if( (i_id & 0xF0FF) == 0x80BD )
{ {
/* A52 audio (0x80->0x8F) */ /* 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; p_es->i_cat = AUDIO_ES;
#ifdef AUTO_SPAWN #ifdef AUTO_SPAWN
if( !p_input->stream.b_seekable ) if( !p_input->stream.b_seekable )
...@@ -895,7 +897,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input, ...@@ -895,7 +897,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input,
else if( (i_id & 0xE0FF) == 0x20BD ) else if( (i_id & 0xE0FF) == 0x20BD )
{ {
/* Subtitles video (0x20->0x3F) */ /* 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; p_es->i_cat = SPU_ES;
#ifdef AUTO_SPAWN #ifdef AUTO_SPAWN
if( config_GetInt( p_input, "spu-channel" ) if( config_GetInt( p_input, "spu-channel" )
...@@ -909,7 +911,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input, ...@@ -909,7 +911,7 @@ static es_descriptor_t * ParsePS( input_thread_t * p_input,
else if( (i_id & 0xF0FF) == 0xA0BD ) else if( (i_id & 0xF0FF) == 0xA0BD )
{ {
/* LPCM audio (0xA0->0xAF) */ /* 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; p_es->i_cat = AUDIO_ES;
} }
else else
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* system.h: MPEG demultiplexing. * system.h: MPEG demultiplexing.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -39,6 +39,29 @@ ...@@ -39,6 +39,29 @@
#define PSI_IS_PMT 0x01 #define PSI_IS_PMT 0x01
#define UNKNOWN_PSI 0xff #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 * psi_callback_t
**************************************************************************** ****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_ts.c : Transport Stream input module for vlc * mpeg_ts.c : Transport Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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> * Authors: Henri Fallon <henri@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr> * Johan Bilien <jobi@via.ecp.fr>
...@@ -624,22 +624,47 @@ static void TSDecodePMT( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -624,22 +624,47 @@ static void TSDecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a'); p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a');
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
break; break;
case LPCM_AUDIO_ES: case A52_AUDIO_ES:
p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m'); p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' ');
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
break; break;
case A52_AUDIO_ES: case LPCM_AUDIO_ES:
p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' '); p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
break; break;
/* Not sure this one is fully specification-compliant */
case DVD_SPU_ES: case DVD_SPU_ES:
p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' '); p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' ');
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = SPU_ES; p_new_es->i_cat = SPU_ES;
break; 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 : default :
p_new_es->i_fourcc = 0; p_new_es->i_fourcc = 0;
p_new_es->i_cat = UNKNOWN_ES; p_new_es->i_cat = UNKNOWN_ES;
...@@ -857,21 +882,46 @@ void TS_DVBPSI_HandlePMT( input_thread_t * p_input, dvbpsi_pmt_t * p_new_pmt ) ...@@ -857,21 +882,46 @@ void TS_DVBPSI_HandlePMT( input_thread_t * p_input, dvbpsi_pmt_t * p_new_pmt )
p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a'); p_new_es->i_fourcc = VLC_FOURCC('m','p','g','a');
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
break; 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: case LPCM_AUDIO_ES:
p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m'); p_new_es->i_fourcc = VLC_FOURCC('l','p','c','m');
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
break; break;
case A52_AUDIO_ES: case SDDS_AUDIO_ES:
p_new_es->i_fourcc = VLC_FOURCC('a','5','2',' '); 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; 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_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES;
break; break;
case DVD_SPU_ES: case A52B_AUDIO_ES:
p_new_es->i_fourcc = VLC_FOURCC('s','p','u',' '); 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_cat = SPU_ES;
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
break; 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: default:
p_new_es->i_fourcc = 0; p_new_es->i_fourcc = 0;
p_new_es->i_cat = UNKNOWN_ES; p_new_es->i_cat = UNKNOWN_ES;
...@@ -914,9 +964,11 @@ void TS_DVBPSI_HandlePMT( input_thread_t * p_input, dvbpsi_pmt_t * p_new_pmt ) ...@@ -914,9 +964,11 @@ void TS_DVBPSI_HandlePMT( input_thread_t * p_input, dvbpsi_pmt_t * p_new_pmt )
strcat( p_new_es->psz_desc, " (mpeg)" ); strcat( p_new_es->psz_desc, " (mpeg)" );
break; break;
case LPCM_AUDIO_ES: case LPCM_AUDIO_ES:
case LPCMB_AUDIO_ES:
strcat( p_new_es->psz_desc, " (lpcm)" ); strcat( p_new_es->psz_desc, " (lpcm)" );
break; break;
case A52_AUDIO_ES: case A52_AUDIO_ES:
case A52B_AUDIO_ES:
strcat( p_new_es->psz_desc, " (A52)" ); strcat( p_new_es->psz_desc, " (A52)" );
break; break;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_dummy.c : dummy audio output plugin * aout_dummy.c : dummy audio output plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -77,8 +77,6 @@ static int SetFormat( aout_instance_t * p_aout ) ...@@ -77,8 +77,6 @@ static int SetFormat( aout_instance_t * p_aout )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t * p_aout ) 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_buffer_t * p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_output.c : audio output instance miscellaneous functions * audio_output.c : audio output instance miscellaneous functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -55,13 +55,10 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent ) ...@@ -55,13 +55,10 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent )
} }
/* Initialize members. */ /* Initialize members. */
vlc_mutex_init( p_parent, &p_aout->input_lock ); vlc_mutex_init( p_parent, &p_aout->input_fifos_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->mixer_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 ); vlc_object_attach( p_aout, p_parent->p_vlc );
...@@ -73,9 +70,9 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent ) ...@@ -73,9 +70,9 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent )
*****************************************************************************/ *****************************************************************************/
void aout_DeleteInstance( aout_instance_t * p_aout ) void aout_DeleteInstance( aout_instance_t * p_aout )
{ {
vlc_mutex_destroy( &p_aout->input_lock ); vlc_mutex_destroy( &p_aout->input_fifos_lock );
vlc_cond_destroy( &p_aout->input_signal );
vlc_mutex_destroy( &p_aout->mixer_lock ); vlc_mutex_destroy( &p_aout->mixer_lock );
vlc_mutex_destroy( &p_aout->output_fifo_lock );
/* Free structure. */ /* Free structure. */
vlc_object_destroy( p_aout ); vlc_object_destroy( p_aout );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* filters.c : audio output filters management * filters.c : audio output filters management
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -183,7 +183,7 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout, ...@@ -183,7 +183,7 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
return 0; 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 * before the resampling, and the upmixing after the resampling (to
* maximize the resampling efficiency). */ * maximize the resampling efficiency). */
b_rate_first = (p_input_format->i_channels < p_output_format->i_channels); b_rate_first = (p_input_format->i_channels < p_output_format->i_channels);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input.c : internal management of input streams for the audio output * input.c : internal management of input streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -42,18 +42,37 @@ ...@@ -42,18 +42,37 @@
static aout_input_t * InputNew( aout_instance_t * p_aout, static aout_input_t * InputNew( aout_instance_t * p_aout,
audio_sample_format_t * p_format ) audio_sample_format_t * p_format )
{ {
aout_input_t * p_input = malloc(sizeof(aout_input_t)); aout_input_t * p_input;
if ( p_input == NULL ) return NULL;
vlc_mutex_lock( &p_aout->mixer_lock ); 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 ) if ( p_aout->i_nb_inputs == 0 )
{ {
/* Recreate the output using the new format. */ /* Recreate the output using the new format. */
if ( aout_OutputNew( p_aout, p_format ) < 0 ) if ( aout_OutputNew( p_aout, p_format ) < 0 )
{ {
vlc_mutex_unlock( &p_input->lock );
vlc_mutex_destroy( &p_input->lock );
free( p_input ); free( p_input );
vlc_mutex_unlock( &p_aout->mixer_lock );
return NULL; return NULL;
} }
} }
...@@ -70,24 +89,6 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -70,24 +89,6 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate ); aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
p_input->p_first_byte_to_mix = NULL; 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->pp_inputs[p_aout->i_nb_inputs] = p_input;
p_aout->i_nb_inputs++; p_aout->i_nb_inputs++;
...@@ -98,8 +99,6 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -98,8 +99,6 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
p_input->i_nb_filters ); p_input->i_nb_filters );
aout_FifoDestroy( p_aout, &p_input->fifo ); aout_FifoDestroy( p_aout, &p_input->fifo );
free( p_input );
if ( !p_aout->i_nb_inputs ) if ( !p_aout->i_nb_inputs )
{ {
aout_OutputDelete( p_aout ); aout_OutputDelete( p_aout );
...@@ -108,6 +107,9 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -108,6 +107,9 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
{ {
aout_MixerNew( 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 ); vlc_mutex_unlock( &p_aout->mixer_lock );
return NULL; return NULL;
...@@ -115,6 +117,27 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -115,6 +117,27 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
vlc_mutex_unlock( &p_aout->mixer_lock ); 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. */ /* Prepare hints for the buffer allocator. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
p_input->input_alloc.i_bytes_per_sec = -1; p_input->input_alloc.i_bytes_per_sec = -1;
...@@ -132,6 +155,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -132,6 +155,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
/* Allocate in the heap, it is more convenient for the decoder. */ /* Allocate in the heap, it is more convenient for the decoder. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; 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 ); msg_Dbg( p_aout, "input 0x%x created", p_input );
return p_input; return p_input;
} }
...@@ -170,6 +195,7 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ) ...@@ -170,6 +195,7 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
int i_input; int i_input;
vlc_mutex_lock( &p_aout->mixer_lock ); 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++ ) for ( i_input = 0; i_input < p_aout->i_nb_inputs; i_input++ )
{ {
...@@ -190,20 +216,22 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ) ...@@ -190,20 +216,22 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
(AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) ); (AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) );
p_aout->i_nb_inputs--; 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 ); vlc_mutex_unlock( &p_aout->mixer_lock );
aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters, aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
p_input->i_nb_filters ); p_input->i_nb_filters );
aout_FifoDestroy( p_aout, &p_input->fifo ); aout_FifoDestroy( p_aout, &p_input->fifo );
vlc_mutex_unlock( &p_input->lock );
vlc_mutex_destroy( &p_input->lock );
free( p_input ); 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 ); msg_Dbg( p_aout, "input 0x%x destroyed", p_input );
} }
...@@ -215,13 +243,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -215,13 +243,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
{ {
mtime_t start_date, duration; mtime_t start_date, duration;
vlc_mutex_lock( &p_aout->input_lock ); vlc_mutex_lock( &p_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 );
/* We don't care if someone changes the start date behind our back after /* 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 * this. We'll deal with that when pushing the buffer, and compensate
...@@ -249,10 +271,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -249,10 +271,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
mdate() - p_buffer->start_date ); mdate() - p_buffer->start_date );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
vlc_mutex_lock( &p_aout->input_lock ); vlc_mutex_unlock( &p_input->lock );
p_aout->i_inputs_active--;
vlc_cond_broadcast( &p_aout->input_signal );
vlc_mutex_unlock( &p_aout->input_lock );
return; return;
} }
...@@ -306,10 +325,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -306,10 +325,7 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
vlc_mutex_lock( &p_aout->input_lock ); vlc_mutex_unlock( &p_input->lock );
p_aout->i_inputs_active--;
vlc_cond_broadcast( &p_aout->input_signal );
vlc_mutex_unlock( &p_aout->input_lock );
return; return;
} }
...@@ -348,15 +364,12 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -348,15 +364,12 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
&p_buffer ); &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(). */ /* Adding the start date will be managed by aout_FifoPush(). */
p_buffer->start_date = start_date; p_buffer->start_date = start_date;
p_buffer->end_date = start_date + duration; p_buffer->end_date = start_date + duration;
aout_FifoPush( p_aout, &p_input->fifo, p_buffer ); aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->input_fifos_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 );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mixer.c : audio output mixing operations * mixer.c : audio output mixing operations
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
/***************************************************************************** /*****************************************************************************
* aout_MixerNew: prepare a mixer plug-in * aout_MixerNew: prepare a mixer plug-in
*****************************************************************************
* Please note that you must hold the mixer lock.
*****************************************************************************/ *****************************************************************************/
int aout_MixerNew( aout_instance_t * p_aout ) int aout_MixerNew( aout_instance_t * p_aout )
{ {
...@@ -52,6 +54,8 @@ int aout_MixerNew( aout_instance_t * p_aout ) ...@@ -52,6 +54,8 @@ int aout_MixerNew( aout_instance_t * p_aout )
/***************************************************************************** /*****************************************************************************
* aout_MixerDelete: delete the mixer * aout_MixerDelete: delete the mixer
*****************************************************************************
* Please note that you must hold the mixer lock.
*****************************************************************************/ *****************************************************************************/
void aout_MixerDelete( aout_instance_t * p_aout ) void aout_MixerDelete( aout_instance_t * p_aout )
{ {
...@@ -69,6 +73,8 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -69,6 +73,8 @@ static int MixBuffer( aout_instance_t * p_aout )
audio_date_t exact_start_date; audio_date_t exact_start_date;
vlc_mutex_lock( &p_aout->mixer_lock ); 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. */ /* Retrieve the date of the next buffer. */
memcpy( &exact_start_date, &p_aout->output.fifo.end_date, memcpy( &exact_start_date, &p_aout->output.fifo.end_date,
...@@ -87,6 +93,8 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -87,6 +93,8 @@ static int MixBuffer( aout_instance_t * p_aout )
start_date = 0; 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 /* See if we have enough data to prepare a new buffer for the audio
* output. First : start date. */ * output. First : start date. */
if ( !start_date ) if ( !start_date )
...@@ -114,6 +122,7 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -114,6 +122,7 @@ static int MixBuffer( aout_instance_t * p_aout )
if ( i < p_aout->i_nb_inputs ) if ( i < p_aout->i_nb_inputs )
{ {
/* Interrupted before the end... We can't run. */ /* Interrupted before the end... We can't run. */
vlc_mutex_unlock( &p_aout->input_fifos_lock );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
return -1; return -1;
} }
...@@ -231,6 +240,7 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -231,6 +240,7 @@ static int MixBuffer( aout_instance_t * p_aout )
if ( i < p_aout->i_nb_inputs ) if ( i < p_aout->i_nb_inputs )
{ {
/* Interrupted before the end... We can't run. */ /* Interrupted before the end... We can't run. */
vlc_mutex_unlock( &p_aout->input_fifos_lock );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
return -1; return -1;
} }
...@@ -246,6 +256,7 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -246,6 +256,7 @@ static int MixBuffer( aout_instance_t * p_aout )
if ( p_output_buffer == NULL ) if ( p_output_buffer == NULL )
{ {
msg_Err( p_aout, "out of memory" ); msg_Err( p_aout, "out of memory" );
vlc_mutex_unlock( &p_aout->input_fifos_lock );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->mixer_lock );
return -1; return -1;
} }
...@@ -262,10 +273,12 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -262,10 +273,12 @@ static int MixBuffer( aout_instance_t * p_aout )
p_aout->mixer.pf_do_work( p_aout, p_output_buffer ); 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 ); aout_OutputPlay( p_aout, p_output_buffer );
vlc_mutex_unlock( &p_aout->mixer_lock );
return 0; return 0;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* output.c : internal management of output streams for the audio output * output.c : internal management of output streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
/***************************************************************************** /*****************************************************************************
* aout_OutputNew : allocate a new output and rework the filter pipeline * 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, int aout_OutputNew( aout_instance_t * p_aout,
audio_sample_format_t * p_format ) audio_sample_format_t * p_format )
...@@ -67,11 +69,14 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -67,11 +69,14 @@ int aout_OutputNew( aout_instance_t * p_aout,
AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32; AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32;
} }
vlc_mutex_lock( &p_aout->output_fifo_lock );
/* Find the best output format. */ /* Find the best output format. */
if ( p_aout->output.pf_setformat( p_aout ) != 0 ) if ( p_aout->output.pf_setformat( p_aout ) != 0 )
{ {
msg_Err( p_aout, "couldn't set an output format" ); msg_Err( p_aout, "couldn't set an output format" );
module_Unneed( p_aout, p_aout->output.p_module ); module_Unneed( p_aout, p_aout->output.p_module );
vlc_mutex_unlock( &p_aout->output_fifo_lock );
return -1; return -1;
} }
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->output.output );
...@@ -79,6 +84,8 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -79,6 +84,8 @@ int aout_OutputNew( aout_instance_t * p_aout,
/* Prepare FIFO. */ /* Prepare FIFO. */
aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate ); 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", 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_format, p_aout->output.output.i_rate,
p_aout->output.output.i_channels ); p_aout->output.output.i_channels );
...@@ -130,6 +137,8 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -130,6 +137,8 @@ int aout_OutputNew( aout_instance_t * p_aout,
/***************************************************************************** /*****************************************************************************
* aout_OutputDelete : delete the output * aout_OutputDelete : delete the output
*****************************************************************************
* This function is entered with the mixer_lock.
*****************************************************************************/ *****************************************************************************/
void aout_OutputDelete( aout_instance_t * p_aout ) void aout_OutputDelete( aout_instance_t * p_aout )
{ {
...@@ -142,6 +151,8 @@ void aout_OutputDelete( aout_instance_t * p_aout ) ...@@ -142,6 +151,8 @@ void aout_OutputDelete( aout_instance_t * p_aout )
/***************************************************************************** /*****************************************************************************
* aout_OutputPlay : play a buffer * 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 ) void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{ {
...@@ -149,10 +160,10 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) ...@@ -149,10 +160,10 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
p_aout->output.i_nb_filters, p_aout->output.i_nb_filters,
&p_buffer ); &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 ); aout_FifoPush( p_aout, &p_aout->output.fifo, p_buffer );
p_aout->output.pf_play( p_aout ); p_aout->output.pf_play( p_aout );
vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_unlock( &p_aout->output_fifo_lock );
} }
/***************************************************************************** /*****************************************************************************
...@@ -168,7 +179,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -168,7 +179,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
{ {
aout_buffer_t * p_buffer; 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; p_buffer = p_aout->output.fifo.p_first;
while ( p_buffer && p_buffer->start_date < start_date ) while ( p_buffer && p_buffer->start_date < start_date )
...@@ -185,7 +196,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -185,7 +196,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first; 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 */ /* Set date to 0, to allow the mixer to send a new buffer ASAP */
aout_FifoSet( p_aout, &p_aout->output.fifo, 0 ); 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, msg_Dbg( p_aout,
"audio output is starving (no input), playing silence" ); "audio output is starving (no input), playing silence" );
return NULL; return NULL;
...@@ -196,7 +207,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -196,7 +207,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
if ( p_buffer->start_date > start_date if ( p_buffer->start_date > start_date
+ (p_buffer->end_date - p_buffer->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", msg_Dbg( p_aout, "audio output is starving (%lld), playing silence",
p_buffer->start_date - start_date ); p_buffer->start_date - start_date );
return NULL; return NULL;
...@@ -212,7 +223,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -212,7 +223,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
msg_Warn( p_aout, "output date isn't PTS date, resampling (%lld)", msg_Warn( p_aout, "output date isn't PTS date, resampling (%lld)",
difference ); 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++ ) for ( i = 0; i < p_aout->i_nb_inputs; i++ )
{ {
aout_fifo_t * p_fifo = &p_aout->pp_inputs[i]->fifo; aout_fifo_t * p_fifo = &p_aout->pp_inputs[i]->fifo;
...@@ -221,6 +232,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -221,6 +232,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
} }
aout_FifoMoveDates( p_aout, &p_aout->output.fifo, difference ); 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.p_first = p_buffer->p_next;
...@@ -229,6 +241,6 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, ...@@ -229,6 +241,6 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first; 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; return p_buffer;
} }
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