X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Finhibit.c;h=b2c590fd471a9b4b3fd56e9000984d8f822cca03;hb=be378fbc80c384e2541517d6853b59411b7e67de;hp=fa374b2df18bdbb18d6396a1e1987ebf20a41733;hpb=87bc70075835e1b2f22b611e63f251dd8cb153af;p=vlc diff --git a/modules/misc/inhibit.c b/modules/misc/inhibit.c index fa374b2df1..b2c590fd47 100644 --- a/modules/misc/inhibit.c +++ b/modules/misc/inhibit.c @@ -30,7 +30,12 @@ * Preamble *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include @@ -58,7 +63,7 @@ struct intf_sys_t * Module descriptor *****************************************************************************/ vlc_module_begin(); - set_description( _("Power Management Inhibiter") ); + set_description( N_("Power Management Inhibitor") ); set_capability( "interface", 0 ); set_callbacks( Activate, Deactivate ); vlc_module_end(); @@ -109,7 +114,7 @@ static void Deactivate( vlc_object_t *p_this ) * Inhibit: Notify the power management daemon that it shouldn't suspend * the computer because of inactivity * - * returns VLC_FALSE if Out of memory, else VLC_TRUE + * returns false if Out of memory, else true *****************************************************************************/ static int Inhibit( intf_thread_t *p_intf ) { @@ -126,7 +131,7 @@ static int Inhibit( intf_thread_t *p_intf ) p_msg = dbus_message_new_method_call( PM_SERVICE, PM_PATH, PM_INTERFACE, "Inhibit" ); if( !p_msg ) - return VLC_FALSE; + return false; dbus_message_iter_init_append( p_msg, &args ); @@ -135,7 +140,7 @@ static int Inhibit( intf_thread_t *p_intf ) { free( psz_app ); dbus_message_unref( p_msg ); - return VLC_FALSE; + return false; } free( psz_app ); @@ -143,14 +148,14 @@ static int Inhibit( intf_thread_t *p_intf ) if( !psz_inhibit_reason ) { dbus_message_unref( p_msg ); - return VLC_FALSE; + return false; } if( !dbus_message_iter_append_basic( &args, DBUS_TYPE_STRING, &psz_inhibit_reason ) ) { free( psz_inhibit_reason ); dbus_message_unref( p_msg ); - return VLC_FALSE; + return false; } free( psz_inhibit_reason ); @@ -160,7 +165,7 @@ static int Inhibit( intf_thread_t *p_intf ) dbus_message_unref( p_msg ); if( p_reply == NULL ) { /* g-p-m is not active, or too slow. Better luck next time? */ - return VLC_TRUE; + return true; } /* extract the cookie from the reply */ @@ -168,18 +173,18 @@ static int Inhibit( intf_thread_t *p_intf ) DBUS_TYPE_UINT32, &i_cookie, DBUS_TYPE_INVALID ) == FALSE ) { - return VLC_FALSE; + return false; } /* Save the cookie */ p_intf->p_sys->i_cookie = i_cookie; - return VLC_TRUE; + return true; } /***************************************************************************** * UnInhibit: Notify the power management daemon that we aren't active anymore * - * returns VLC_FALSE if Out of memory, else VLC_TRUE + * returns false if Out of memory, else true *****************************************************************************/ static int UnInhibit( intf_thread_t *p_intf ) { @@ -195,7 +200,7 @@ static int UnInhibit( intf_thread_t *p_intf ) p_msg = dbus_message_new_method_call( PM_SERVICE, PM_PATH, PM_INTERFACE, "UnInhibit" ); if( !p_msg ) - return VLC_FALSE; + return false; dbus_message_iter_init_append( p_msg, &args ); @@ -203,17 +208,17 @@ static int UnInhibit( intf_thread_t *p_intf ) if( !dbus_message_iter_append_basic( &args, DBUS_TYPE_UINT32, &i_cookie ) ) { dbus_message_unref( p_msg ); - return VLC_FALSE; + return false; } if( !dbus_connection_send( p_conn, p_msg, NULL ) ) - return VLC_FALSE; + return false; dbus_connection_flush( p_conn ); dbus_message_unref( p_msg ); p_intf->p_sys->i_cookie = 0; - return VLC_TRUE; + return true; } /***************************************************************************** @@ -221,18 +226,13 @@ static int UnInhibit( intf_thread_t *p_intf ) *****************************************************************************/ static void Run( intf_thread_t *p_intf ) { - for(;;) + vlc_object_lock( p_intf ); + while( vlc_object_alive( p_intf ) ) { input_thread_t *p_input; - vlc_bool_t b_quit; /* Check playing state every 30 seconds */ - vlc_object_lock( p_intf ); - b_quit = vlc_object_timedwait( p_intf, mdate() + 30000000 ) < 0; - vlc_object_unlock( p_intf ); - - if( b_quit ) - break; + vlc_object_timedwait( p_intf, mdate() + 30000000 ); p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) @@ -242,7 +242,7 @@ static void Run( intf_thread_t *p_intf ) if( !Inhibit( p_intf ) ) { vlc_object_release( p_input ); - return; + goto end; } } else if( p_intf->p_sys->i_cookie ) @@ -250,7 +250,7 @@ static void Run( intf_thread_t *p_intf ) if( !UnInhibit( p_intf ) ) { vlc_object_release( p_input ); - return; + goto end; } } vlc_object_release( p_input ); @@ -258,7 +258,10 @@ static void Run( intf_thread_t *p_intf ) else if( p_intf->p_sys->i_cookie ) { if( !UnInhibit( p_intf ) ) - return; + goto end; } } + +end: + vlc_object_unlock( p_intf ); }