Changeset 253ac451cadf69a9ee788d4f640d294957b877f7

Show
Ignore:
Timestamp:
07/09/08 22:21:41 (3 months ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1220818901 +0200
git-parent:

[9ea2d78d6b4507764373bcfd07ec054596f9edf2]

git-author:
Laurent Aimar <fenrir@videolan.org> 1220818773 +0200
Message:

Removed the need to msleep to handle input pause.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/input/input.c

    r9ea2d78 r253ac45  
    6565static void             MainLoop( input_thread_t *p_input ); 
    6666 
    67 static inline int ControlPopNoLock( input_thread_t *, int *, vlc_value_t * ); 
     67static inline int ControlPopNoLock( input_thread_t *, int *, vlc_value_t *, mtime_t i_deadline ); 
    6868static void       ControlReduce( input_thread_t * ); 
    6969static bool Control( input_thread_t *, int, vlc_value_t ); 
     
    224224    /* Init control buffer */ 
    225225    vlc_mutex_init( &p_input->p->lock_control ); 
     226    vlc_cond_init( &p_input->p->wait_control ); 
    226227    p_input->p->i_control = 0; 
    227228 
     
    338339    vlc_mutex_destroy( &p_input->p->counters.counters_lock ); 
    339340 
     341    vlc_cond_destroy( &p_input->p->wait_control ); 
    340342    vlc_mutex_destroy( &p_input->p->lock_control ); 
    341343    free( p_input->p ); 
     
    731733        vlc_value_t val; 
    732734        mtime_t i_current; 
    733  
    734         /* Do the read */ 
     735        mtime_t i_deadline; 
     736 
     737        /* Demux data */ 
     738        b_force_update = false; 
    735739        if( p_input->i_state != PAUSE_S ) 
    736         { 
    737740            MainLoopDemux( p_input, &b_force_update, &i_start_mdate ); 
    738         } 
    739         else 
    740         { 
    741             /* Small wait */ 
    742             b_force_update = false; 
    743             msleep( 10*1000 ); 
    744         } 
     741 
     742        /* */ 
     743        i_deadline = 0; 
     744        if( p_input->i_state == PAUSE_S ) 
     745            i_deadline = __MIN( i_intf_update, i_statistic_update ); 
    745746 
    746747        /* Handle control */ 
    747748        vlc_mutex_lock( &p_input->p->lock_control ); 
    748749        ControlReduce( p_input ); 
    749         while( !ControlPopNoLock( p_input, &i_type, &val ) ) 
     750        while( !ControlPopNoLock( p_input, &i_type, &val, i_deadline ) ) 
    750751        { 
    751752            msg_Dbg( p_input, "control type=%d", i_type ); 
     
    13971398 *****************************************************************************/ 
    13981399static inline int ControlPopNoLock( input_thread_t *p_input, 
    1399                                     int *pi_type, vlc_value_t *p_val ) 
    1400 
    1401     if( p_input->p->i_control <= 0 ) 
    1402     { 
    1403         return VLC_EGENERIC; 
     1400                                    int *pi_type, vlc_value_t *p_val, 
     1401                                    mtime_t i_deadline ) 
     1402
     1403 
     1404    while( p_input->p->i_control <= 0 ) 
     1405    { 
     1406        if( i_deadline <= 0 ) 
     1407            return VLC_EGENERIC; 
     1408 
     1409        if( vlc_cond_timedwait( &p_input->p->wait_control, &p_input->p->lock_control, i_deadline ) ) 
     1410            return VLC_EGENERIC; 
    14041411    } 
    14051412 
  • src/input/input_internal.h

    rc35c18a r253ac45  
    148148    /* Buffer of pending actions */ 
    149149    vlc_mutex_t lock_control; 
     150    vlc_cond_t  wait_control; 
    150151    int i_control; 
    151152    struct 
     
    212213        memset( &p_input->p->control[0].val, 0, sizeof( vlc_value_t ) ); 
    213214    } 
    214     else 
    215     if( p_input->p->i_control >= INPUT_CONTROL_FIFO_SIZE ) 
     215    else if( p_input->p->i_control >= INPUT_CONTROL_FIFO_SIZE ) 
    216216    { 
    217217        msg_Err( p_input, "input control fifo overflow, trashing type=%d", 
     
    229229        p_input->p->i_control++; 
    230230    } 
     231    vlc_cond_signal( &p_input->p->wait_control ); 
    231232    vlc_mutex_unlock( &p_input->p->lock_control ); 
    232233}