X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcontrol%2Fshowintf.c;h=c93fa3f567c04b02e1057baabb8247d85ad27c4c;hb=eb5d8fada5ec07e3a8f4cb2b2cd6df4f7af2b9fd;hp=a9321c9689dbb08030183a394c369b0a669ec06a;hpb=70ac3d928c9437f704f6130f67db50678661c089;p=vlc diff --git a/modules/control/showintf.c b/modules/control/showintf.c index a9321c9689..c93fa3f567 100644 --- a/modules/control/showintf.c +++ b/modules/control/showintf.c @@ -29,7 +29,8 @@ # include "config.h" #endif -#include +#include +#include #include #include #include @@ -43,17 +44,18 @@ *****************************************************************************/ struct intf_sys_t { + vlc_mutex_t lock; vlc_object_t * p_vout; - vlc_bool_t b_button_pressed; - vlc_bool_t b_triggered; + bool b_button_pressed; + bool b_triggered; int i_threshold; }; /***************************************************************************** * Local prototypes. *****************************************************************************/ -int E_(Open) ( vlc_object_t * ); -void E_(Close)( vlc_object_t * ); +int Open ( vlc_object_t * ); +void Close( vlc_object_t * ); static void RunIntf( intf_thread_t *p_intf ); static int InitThread( intf_thread_t *p_intf ); static int MouseEvent( vlc_object_t *, char const *, @@ -65,19 +67,19 @@ static int MouseEvent( vlc_object_t *, char const *, #define THRESHOLD_TEXT N_( "Threshold" ) #define THRESHOLD_LONGTEXT N_( "Height of the zone triggering the interface." ) -vlc_module_begin(); - set_shortname( "Showintf" ); - add_integer( "showintf-threshold", 10, NULL, THRESHOLD_TEXT, THRESHOLD_LONGTEXT, VLC_TRUE ); - set_description( _("Show interface with mouse") ); +vlc_module_begin () + set_shortname( "Showintf" ) + add_integer( "showintf-threshold", 10, NULL, THRESHOLD_TEXT, THRESHOLD_LONGTEXT, true ) + set_description( N_("Show interface with mouse") ) - set_capability( "interface", 0 ); - set_callbacks( E_(Open), E_(Close) ); -vlc_module_end(); + set_capability( "interface", 0 ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Open: initialize interface *****************************************************************************/ -int E_(Open)( vlc_object_t *p_this ) +int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; @@ -88,6 +90,7 @@ int E_(Open)( vlc_object_t *p_this ) return( 1 ); }; + vlc_mutex_init( &p_intf->p_sys->lock ); p_intf->pf_run = RunIntf; return( 0 ); @@ -96,11 +99,12 @@ int E_(Open)( vlc_object_t *p_this ) /***************************************************************************** * Close: destroy interface *****************************************************************************/ -void E_(Close)( vlc_object_t *p_this ) +void Close( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; /* Destroy structure */ + vlc_mutex_destroy( &p_intf->p_sys->lock ); free( p_intf->p_sys ); } @@ -110,6 +114,7 @@ void E_(Close)( vlc_object_t *p_this ) *****************************************************************************/ static void RunIntf( intf_thread_t *p_intf ) { + int canc = vlc_savecancel( ); p_intf->p_sys->p_vout = NULL; if( InitThread( p_intf ) < 0 ) @@ -119,24 +124,22 @@ static void RunIntf( intf_thread_t *p_intf ) } /* Main loop */ - while( !intf_ShouldDie( p_intf ) ) + while( vlc_object_alive( p_intf ) ) { - vlc_mutex_lock( &p_intf->change_lock ); + vlc_mutex_lock( &p_intf->p_sys->lock ); /* Notify the interfaces */ if( p_intf->p_sys->b_triggered ) { - playlist_t *p_playlist = pl_Yield( p_intf ); - var_SetBool( p_playlist, "intf-show", VLC_TRUE ); - vlc_object_release( p_playlist ); - p_intf->p_sys->b_triggered = VLC_FALSE; + var_SetBool( p_intf->p_libvlc, "intf-show", true ); + p_intf->p_sys->b_triggered = false; } - vlc_mutex_unlock( &p_intf->change_lock ); + vlc_mutex_unlock( &p_intf->p_sys->lock ); /* Take care of the video output */ - if( p_intf->p_sys->p_vout && p_intf->p_sys->p_vout->b_die ) + if( p_intf->p_sys->p_vout && !vlc_object_alive (p_intf->p_sys->p_vout) ) { var_DelCallback( p_intf->p_sys->p_vout, "mouse-moved", MouseEvent, p_intf ); @@ -171,6 +174,7 @@ static void RunIntf( intf_thread_t *p_intf ) MouseEvent, p_intf ); vlc_object_release( p_intf->p_sys->p_vout ); } + vlc_restorecancel( canc ); } /***************************************************************************** @@ -178,16 +182,16 @@ static void RunIntf( intf_thread_t *p_intf ) *****************************************************************************/ static int InitThread( intf_thread_t * p_intf ) { - if( !intf_ShouldDie( p_intf ) ) + if( vlc_object_alive( p_intf ) ) { - vlc_mutex_lock( &p_intf->change_lock ); + vlc_mutex_lock( &p_intf->p_sys->lock ); - p_intf->p_sys->b_triggered = VLC_FALSE; - p_intf->p_sys->b_button_pressed = VLC_FALSE; + p_intf->p_sys->b_triggered = false; + p_intf->p_sys->b_button_pressed = false; p_intf->p_sys->i_threshold = config_GetInt( p_intf, "showintf-threshold" ); - vlc_mutex_unlock( &p_intf->change_lock ); + vlc_mutex_unlock( &p_intf->p_sys->lock ); return 0; } @@ -218,7 +222,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, if( !val.i_int ) return VLC_SUCCESS; - vlc_mutex_lock( &p_intf->change_lock ); + vlc_mutex_lock( &p_intf->p_sys->lock ); if( !strcmp( psz_var, "mouse-moved" ) && !p_intf->p_sys->b_button_pressed ) { var_Get( p_intf->p_sys->p_vout, "mouse-x", &val ); @@ -230,7 +234,7 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, if ( i_mouse_y < p_intf->p_sys->i_threshold ) { msg_Dbg( p_intf, "interface showing requested" ); - p_intf->p_sys->b_triggered = VLC_TRUE; + p_intf->p_sys->b_triggered = true; } } @@ -239,15 +243,15 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, if( !p_intf->p_sys->b_button_pressed && !strcmp( psz_var, "mouse-button-down" ) ) { - p_intf->p_sys->b_button_pressed = VLC_TRUE; + p_intf->p_sys->b_button_pressed = true; } if( p_intf->p_sys->b_button_pressed && !strcmp( psz_var, "mouse-button-down" ) ) { - p_intf->p_sys->b_button_pressed = VLC_FALSE; + p_intf->p_sys->b_button_pressed = false; } - vlc_mutex_unlock( &p_intf->change_lock ); + vlc_mutex_unlock( &p_intf->p_sys->lock ); return VLC_SUCCESS; }