- if( p_input->b_can_pace_control && cl->b_master )
- {
- /* Wait a while before delivering the packets to the decoder.
- * In case of multiple programs, we arbitrarily follow the
- * clock of the selected program. */
- if( !p_input->p->b_out_pace_control )
- {
- mtime_t i_wakeup = ClockToSysdate( p_input, cl, i_clock );
- while( (i_wakeup - mdate()) / CLOCK_FREQ > 1 )
- {
- msleep( CLOCK_FREQ );
- if( p_input->b_die ) i_wakeup = mdate();
- }
- mwait( i_wakeup );
- }
- }
- else if ( mdate() - cl->last_sysdate > 200000 )
- {
- /* Smooth clock reference variations. */
- mtime_t i_extrapoled_clock = ClockCurrent( p_input, cl );
- mtime_t delta_cr;
-
- /* Bresenham algorithm to smooth variations. */
- delta_cr = ( cl->delta_cr * (cl->i_cr_average - 1)
- + ( i_extrapoled_clock - i_clock )
- + cl->i_delta_cr_residue )
- / cl->i_cr_average;
- cl->i_delta_cr_residue = ( cl->delta_cr * (cl->i_cr_average - 1)
- + ( i_extrapoled_clock - i_clock )
- + cl->i_delta_cr_residue )
- % cl->i_cr_average;
- cl->delta_cr = delta_cr;
- cl->last_sysdate = mdate();
- }
+ if( !b_synchronize && i_ck_system - cl->last_update > 200000 )
+ {
+ /* Smooth clock reference variations. */
+ const mtime_t i_extrapoled_clock = ClockCurrent( cl );
+ /* Bresenham algorithm to smooth variations. */
+ const mtime_t i_tmp = cl->delta_cr * (cl->i_cr_average - 1) +
+ ( i_extrapoled_clock - i_ck_stream ) * 1 +
+ cl->i_delta_cr_residue;
+
+ cl->i_delta_cr_residue = i_tmp % cl->i_cr_average;
+ cl->delta_cr = i_tmp / cl->i_cr_average;
+
+ cl->last_update = i_ck_system;