/* Ask thread to kill itself */
p_ac3dec->b_die = 1;
+
/* Make sure the decoder thread leaves the GetByte() function */
vlc_mutex_lock( &(p_ac3dec->fifo.data_lock) );
vlc_cond_signal( &(p_ac3dec->fifo.data_wait) );
*****************************************************************************/
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() );
+ msleep( (3 * INPUT_PTS_DELAY) / 4 );
+
/* Initializing the ac3 decoder thread */
if ( InitThread(p_ac3dec) )
{
}
/* 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) )
{
p_ac3dec->b_invalid = 0;
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 )
{
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_ac3dec->fifo)->i_pts;
if ( p_ac3dec->p_aout_fifo != NULL )
{
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 */
/* Ask thread to kill itself */
p_adec->b_die = 1;
+
/* Make sure the decoder thread leaves the GetByte() function */
vlc_mutex_lock( &(p_adec->fifo.data_lock) );
vlc_cond_signal( &(p_adec->fifo.data_wait) );
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 */
if ( InitThread(p_adec) )
{
/* Frame 1 */
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->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->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->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->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->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
if ( p_adec->p_aout_fifo != NULL )
{
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 */
free( p_adec );
}
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 )
{
vlc_mutex_unlock( &p_fifo->data_lock );
}
/* 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 )
{
p_fifo->b_next_frame = 1;
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 )
- {
- break;
- }
- else
+ while ( p_fifo->l_next_frame == p_fifo->l_end_frame )
{
- 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 );
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_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 );