Commit 7b5259e0 authored by Stéphane Borel's avatar Stéphane Borel

*Fixed a bug in synchro reinitialisation: we no longer have a shift each

time we restart the synchro (for scr discontinuity for instance)

*In DVD mode, we reinit the synchro only if the scr are not continuous
(instead of each cell)

*Try to improve ac3 spdif to prevent from desynchronization.
parent 0c6f4bc9
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.38 2001/05/30 17:03:11 sam Exp $
* $Id: input_ext-intf.h,v 1.39 2001/06/09 17:01:21 stef Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -125,6 +125,7 @@ typedef struct pgrm_descriptor_s
mtime_t cr_ref, sysdate_ref;
mtime_t last_cr; /* reference to detect unexpected stream
* discontinuities */
mtime_t last_syscr;
count_t c_average_count;
/* counter used to compute dynamic average values */
int i_synchro_state;
......
......@@ -10,7 +10,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.68 2001/06/07 22:25:42 sam Exp $
* $Id: input_dvd.c,v 1.69 2001/06/09 17:01:22 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -796,6 +796,12 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
DVDFindSector( p_dvd );
p_dvd->i_cell += p_dvd->i_angle_cell;
if( p_input->stream.pp_programs[0]->i_synchro_state == SYNCHRO_OK )
{
p_input->stream.pp_programs[0]->i_synchro_state =
SYNCHRO_REINIT;
}
}
else
{
......@@ -809,7 +815,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_input->stream.b_seekable = 1;
p_input->stream.b_changed = 1;
p_input->stream.pp_programs[0]->i_synchro_state = SYNCHRO_REINIT;
return 0;
}
......@@ -899,7 +904,7 @@ static int DVDRead( input_thread_t * p_input,
p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
/* the synchro has to be reinitialized when we change cell */
p_input->stream.pp_programs[0]->i_synchro_state = SYNCHRO_REINIT;
// p_input->stream.pp_programs[0]->i_synchro_state = SYNCHRO_REINIT;
vlc_mutex_unlock( &p_input->stream.stream_lock );
......
......@@ -2,7 +2,7 @@
* ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ac3_spdif.c,v 1.7 2001/05/31 01:37:08 sam Exp $
* $Id: ac3_spdif.c,v 1.8 2001/06/09 17:01:22 stef Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
......@@ -190,10 +190,9 @@ static void RunThread( ac3_spdif_thread_t * p_spdif )
while( !p_spdif->p_fifo->b_die && !p_spdif->p_fifo->b_error )
{
/* Handle the dates */
if(DECODER_FIFO_START(*p_spdif->p_fifo)->i_pts)
if( p_spdif->i_pts != m_last_pts )
{
m_last_pts = DECODER_FIFO_START(*p_spdif->p_fifo)->i_pts;
DECODER_FIFO_START(*p_spdif->p_fifo)->i_pts = 0;
m_last_pts = p_spdif->i_pts;
}
else
{
......@@ -306,8 +305,16 @@ static void EndThread( ac3_spdif_thread_t * p_spdif )
static void BitstreamCallback ( bit_stream_t * p_bit_stream,
boolean_t b_new_pes)
{
ac3_spdif_thread_t * p_spdif;
if( b_new_pes )
{
p_spdif = (ac3_spdif_thread_t *)p_bit_stream->p_callback_arg;
p_bit_stream->p_byte += 3;
p_spdif->i_pts =
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts;
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts = 0;
}
}
......@@ -2,7 +2,7 @@
* ac3_spdif.h: header for ac3 pass-through
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ac3_spdif.h,v 1.3 2001/05/06 18:32:30 stef Exp $
* $Id: ac3_spdif.h,v 1.4 2001/06/09 17:01:22 stef Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
*
......@@ -56,6 +56,9 @@ typedef struct ac3_spdif_thread_s
u8 * p_ac3;
u8 * p_iec;
/* current pes date */
mtime_t i_pts;
/*
* Output properties
*/
......
......@@ -2,7 +2,7 @@
* aout_spdif: ac3 passthrough output
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aout_spdif.c,v 1.11 2001/05/31 16:10:05 stef Exp $
* $Id: aout_spdif.c,v 1.12 2001/06/09 17:01:22 stef Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr>
......@@ -74,6 +74,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
/* variable used to compute the nnumber of blank frames since the
* last significant frame */
i_blank = 0;
mdelta = 0;
/* Compute the theorical duration of an ac3 frame */
......@@ -104,7 +105,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
l_start_frame];
mdelta = mplay - mdate();
if( mdelta < ( 2 * SLEEP_TIME ) )
if( mdelta < ( 3 * SLEEP_TIME ) )
{
intf_WarnMsg( 12, "spdif out (%d):"
"playing frame %lld (%lld)",
......@@ -126,6 +127,11 @@ void aout_SpdifThread( aout_thread_t * p_aout )
i_frame++;
i_blank = 0;
}
else
{
intf_WarnMsg( 12, "spdif out (%d): early frame %lld",
i_fifo, mdelta );
}
vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
}
else
......@@ -137,16 +143,23 @@ void aout_SpdifThread( aout_thread_t * p_aout )
if( i_frame )
{
/* we leave some time for aout fifo to fill and not to stress
* the external decoder too much */
msleep( SLEEP_TIME );
if( mdelta > 0 )
{
/* we leave some time for aout fifo to fill and not to stress
* the external decoder too much */
msleep( mdelta + SLEEP_TIME );
}
else if( mdelta > -SLEEP_TIME )
{
msleep( SLEEP_TIME );
}
}
else
{
/* insert blank frame for stream continuity to
* the external decoder */
intf_WarnMsg( 6, "spdif warning: blank frame" );
p_aout->pf_play( p_aout, pi_blank, SPDIF_FRAME_SIZE/4 );
p_aout->pf_play( p_aout, pi_blank, SPDIF_FRAME_SIZE );
/* we kill the output if we don't have any stream */
if( ++i_blank > BLANK_FRAME_MAX )
......
......@@ -2,7 +2,7 @@
* input_clock.c: Clock/System date convertions, stream management
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_clock.c,v 1.16 2001/05/08 14:53:31 bozo Exp $
* $Id: input_clock.c,v 1.17 2001/06/09 17:01:22 stef Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -123,7 +123,7 @@ static void ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
mtime_t i_clock, mtime_t i_sysdate )
{
p_pgrm->cr_ref = i_clock;
p_pgrm->sysdate_ref = i_sysdate;
p_pgrm->sysdate_ref = p_pgrm->last_syscr ? p_pgrm->last_syscr : i_sysdate;
}
/*****************************************************************************
......@@ -133,6 +133,7 @@ static void ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
void input_ClockInit( pgrm_descriptor_t * p_pgrm )
{
p_pgrm->last_cr = 0;
p_pgrm->last_syscr = 0;
p_pgrm->cr_ref = 0;
p_pgrm->sysdate_ref = 0;
p_pgrm->delta_cr = 0;
......@@ -145,7 +146,7 @@ void input_ClockInit( pgrm_descriptor_t * p_pgrm )
void input_ClockManageRef( input_thread_t * p_input,
pgrm_descriptor_t * p_pgrm, mtime_t i_clock )
{
if( p_pgrm->i_synchro_state != SYNCHRO_OK )
if( ( p_pgrm->i_synchro_state != SYNCHRO_OK ) || ( i_clock == 0 ) )
{
/* Feed synchro with a new reference point. */
ClockNewRef( p_input, p_pgrm, i_clock, mdate() );
......@@ -160,6 +161,7 @@ void input_ClockManageRef( input_thread_t * p_input,
else
{
p_pgrm->last_cr = 0;
p_pgrm->last_syscr = 0;
p_pgrm->delta_cr = 0;
p_pgrm->c_average_count = 0;
}
......@@ -187,7 +189,8 @@ void input_ClockManageRef( input_thread_t * p_input,
/* Wait a while before delivering the packets to the decoder.
* In case of multiple programs, we arbitrarily follow the
* clock of the first program. */
mwait( ClockToSysdate( p_input, p_pgrm, i_clock ) );
p_pgrm->last_syscr = ClockToSysdate( p_input, p_pgrm, i_clock );
mwait( p_pgrm->last_syscr );
/* Now take into account interface changes. */
vlc_mutex_lock( &p_input->stream.stream_lock );
......
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