Commit 9629dd8a authored by Michel Kaempf's avatar Michel Kaempf

IMPORTANT :

* ce commit devrait corriger les probl�mes de fermeture du vlc, commentaires
souhait�s (et obligatoires) ;
* le probl�me de la synkro initiale de l'audio devrait �tre corrig� : reports
souhait�s (et obligatoires) gr�ce aux messages "aout debug" ;
* en clair FAITES PETER UN MAIL avec vos messages "aout debug" et vos coups
de gueule/coups de coeur quant � la fermeture du vlc ;-)

* ac3_decoder/ac3_decoder.c, audio_decoder/audio_decoder.c :
- rajout d'un msleep() en d�but de fonction RunThread() afin de
contrebalancer le d�lai entre la r�ception d'un paquet TS et la
pr�sentation de son contenu (INPUT_PTS_DELAY) ;
- rajout d'un cond_signal() dans la fonction EndThread() ;

* audio_output/audio_output.c :
- activation des messages de debug ;
- r��criture de la fonction NextFrame() ;
parent a57bfee7
...@@ -123,6 +123,7 @@ void ac3dec_DestroyThread( ac3dec_thread_t * p_ac3dec ) ...@@ -123,6 +123,7 @@ void ac3dec_DestroyThread( ac3dec_thread_t * p_ac3dec )
/* Ask thread to kill itself */ /* Ask thread to kill itself */
p_ac3dec->b_die = 1; p_ac3dec->b_die = 1;
/* Make sure the decoder thread leaves the GetByte() function */ /* Make sure the decoder thread leaves the GetByte() function */
vlc_mutex_lock( &(p_ac3dec->fifo.data_lock) ); vlc_mutex_lock( &(p_ac3dec->fifo.data_lock) );
vlc_cond_signal( &(p_ac3dec->fifo.data_wait) ); vlc_cond_signal( &(p_ac3dec->fifo.data_wait) );
...@@ -214,12 +215,10 @@ static int InitThread( ac3dec_thread_t * p_ac3dec ) ...@@ -214,12 +215,10 @@ static int InitThread( ac3dec_thread_t * p_ac3dec )
*****************************************************************************/ *****************************************************************************/
static void RunThread( ac3dec_thread_t * p_ac3dec ) static void RunThread( ac3dec_thread_t * p_ac3dec )
{ {
/*
mtime_t mdate = 0;
*/
intf_DbgMsg( "ac3dec debug: running ac3 decoder thread (%p) (pid == %i)\n", p_ac3dec, getpid() ); intf_DbgMsg( "ac3dec debug: running ac3 decoder thread (%p) (pid == %i)\n", p_ac3dec, getpid() );
msleep( (3 * INPUT_PTS_DELAY) / 4 );
/* Initializing the ac3 decoder thread */ /* Initializing the ac3 decoder thread */
if ( InitThread(p_ac3dec) ) if ( InitThread(p_ac3dec) )
{ {
...@@ -227,16 +226,13 @@ static void RunThread( ac3dec_thread_t * p_ac3dec ) ...@@ -227,16 +226,13 @@ static void RunThread( ac3dec_thread_t * p_ac3dec )
} }
/* ac3 decoder thread's main loop */ /* ac3 decoder thread's main loop */
/* FIXME : do we have enough room to store the decoded frames ? */
while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) ) while ( (!p_ac3dec->b_die) && (!p_ac3dec->b_error) )
{ {
p_ac3dec->b_invalid = 0; p_ac3dec->b_invalid = 0;
decode_find_sync( p_ac3dec ); decode_find_sync( p_ac3dec );
/*
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = mdate;
mdate += 32000;
*/
if ( DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts ) if ( DECODER_FIFO_START(p_ac3dec->fifo)->b_has_pts )
{ {
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts; p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts;
...@@ -445,6 +441,11 @@ static void EndThread( ac3dec_thread_t * p_ac3dec ) ...@@ -445,6 +441,11 @@ static void EndThread( ac3dec_thread_t * p_ac3dec )
if ( p_ac3dec->p_aout_fifo != NULL ) if ( p_ac3dec->p_aout_fifo != NULL )
{ {
aout_DestroyFifo( p_ac3dec->p_aout_fifo ); aout_DestroyFifo( p_ac3dec->p_aout_fifo );
/* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock( &(p_ac3dec->p_aout_fifo->data_lock) );
vlc_cond_signal( &(p_ac3dec->p_aout_fifo->data_wait) );
vlc_mutex_unlock( &(p_ac3dec->p_aout_fifo->data_lock) );
} }
/* Destroy descriptor */ /* Destroy descriptor */
......
...@@ -143,6 +143,7 @@ void adec_DestroyThread( adec_thread_t * p_adec ) ...@@ -143,6 +143,7 @@ void adec_DestroyThread( adec_thread_t * p_adec )
/* Ask thread to kill itself */ /* Ask thread to kill itself */
p_adec->b_die = 1; p_adec->b_die = 1;
/* Make sure the decoder thread leaves the GetByte() function */ /* Make sure the decoder thread leaves the GetByte() function */
vlc_mutex_lock( &(p_adec->fifo.data_lock) ); vlc_mutex_lock( &(p_adec->fifo.data_lock) );
vlc_cond_signal( &(p_adec->fifo.data_wait) ); vlc_cond_signal( &(p_adec->fifo.data_wait) );
...@@ -799,6 +800,8 @@ static void RunThread( adec_thread_t * p_adec ) ...@@ -799,6 +800,8 @@ static void RunThread( adec_thread_t * p_adec )
intf_DbgMsg("adec debug: running audio decoder thread (%p) (pid == %i)\n", p_adec, getpid()); intf_DbgMsg("adec debug: running audio decoder thread (%p) (pid == %i)\n", p_adec, getpid());
msleep( (3 * INPUT_PTS_DELAY) / 4 );
/* Initializing the audio decoder thread */ /* Initializing the audio decoder thread */
if ( InitThread(p_adec) ) if ( InitThread(p_adec) )
{ {
...@@ -861,18 +864,23 @@ static void RunThread( adec_thread_t * p_adec ) ...@@ -861,18 +864,23 @@ static void RunThread( adec_thread_t * p_adec )
/* Frame 1 */ /* Frame 1 */
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
/* Frame 2 */ /* Frame 2 */
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE; p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
/* Frame 3 */ /* Frame 3 */
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE; p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
/* Frame 4 */ /* Frame 4 */
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE; p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
/* Frame 5 */ /* Frame 5 */
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE; p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
/* Frame 6 */ /* Frame 6 */
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE; p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
...@@ -961,6 +969,11 @@ static void EndThread( adec_thread_t *p_adec ) ...@@ -961,6 +969,11 @@ static void EndThread( adec_thread_t *p_adec )
if ( p_adec->p_aout_fifo != NULL ) if ( p_adec->p_aout_fifo != NULL )
{ {
aout_DestroyFifo( p_adec->p_aout_fifo ); aout_DestroyFifo( p_adec->p_aout_fifo );
/* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock( &(p_adec->p_aout_fifo->data_lock) );
vlc_cond_signal( &(p_adec->p_aout_fifo->data_wait) );
vlc_mutex_unlock( &(p_adec->p_aout_fifo->data_lock) );
} }
/* Destroy descriptor */ /* Destroy descriptor */
free( p_adec ); free( p_adec );
......
...@@ -457,6 +457,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -457,6 +457,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
} }
p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE; p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
} }
if ( p_fifo->l_start_frame == p_fifo->l_end_frame ) if ( p_fifo->l_start_frame == p_fifo->l_end_frame )
{ {
vlc_mutex_unlock( &p_fifo->data_lock ); vlc_mutex_unlock( &p_fifo->data_lock );
...@@ -465,7 +466,8 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -465,7 +466,8 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
} }
/* We are looking for the next dated frame */ /* We are looking for the next dated frame */
while ( 1 ) /* FIXME : is the output fifo full ? */
while ( !p_fifo->b_next_frame )
{ {
while ( p_fifo->l_next_frame != p_fifo->l_end_frame ) while ( p_fifo->l_next_frame != p_fifo->l_end_frame )
{ {
...@@ -474,42 +476,24 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -474,42 +476,24 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
p_fifo->b_next_frame = 1; p_fifo->b_next_frame = 1;
break; break;
} }
else
{
p_fifo->l_next_frame = (p_fifo->l_next_frame + 1) & AOUT_FIFO_SIZE; p_fifo->l_next_frame = (p_fifo->l_next_frame + 1) & AOUT_FIFO_SIZE;
} }
}
if ( p_fifo->b_next_frame == 1 ) while ( p_fifo->l_next_frame == p_fifo->l_end_frame )
{
break;
}
else
{ {
if ( (((p_fifo->l_end_frame + 1) - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) == 0 ) vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
if ( p_fifo->b_die )
{ {
p_fifo->l_start_frame = 0;
p_fifo->b_start_frame = 0;
/* p_fifo->l_next_frame = 0; */
/* p_fifo->b_next_frame = 0; */
p_fifo->l_end_frame = 0;
vlc_mutex_unlock( &p_fifo->data_lock ); vlc_mutex_unlock( &p_fifo->data_lock );
return( -1 ); return( -1 );
} }
else
{
while ( p_fifo->l_next_frame == p_fifo->l_end_frame )
{
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
}
} }
} }
l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> p_fifo->b_stereo); l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> p_fifo->b_stereo);
l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256); l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256);
// fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate ); fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate );
InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->dsp.l_rate ); InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->dsp.l_rate );
......
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