[vlc-devel] [PATCH 6/9] dbus: Correctly detect the 'stopped' playback state

Mirsal Ennaime mirsal at mirsal.fr
Tue Feb 8 22:36:01 CET 2011


From: Mirsal Ennaime <mirsal.ennaime at gmail.com>

 * Use input events to detect when the input thread stops playback
 * Use an enum for mpris playback statuses instead of hardcoded values
---
 modules/control/dbus/dbus.c        |    6 +++++-
 modules/control/dbus/dbus_common.h |    7 +++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index e997266..9cda60a 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -913,7 +913,11 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
     else if( !strcmp( "intf-event", psz_var ) )
     {
         dbus_int32_t state;
-        state = (var_GetInteger(p_this, "state") == PAUSE_S) ? 1 : 0;
+        if( INPUT_EVENT_DEAD == newval.i_int )
+            state = PLAYBACK_STATE_STOPPED;
+        else
+            state = (var_GetInteger(p_this, "state") == PAUSE_S) ?
+                    PLAYBACK_STATE_PAUSED : PLAYBACK_STATE_PLAYING;
 
         if( state == p_intf->p_sys->i_playing_state )
         {
diff --git a/modules/control/dbus/dbus_common.h b/modules/control/dbus/dbus_common.h
index 0767edd..1eacc86 100644
--- a/modules/control/dbus/dbus_common.h
+++ b/modules/control/dbus/dbus_common.h
@@ -109,6 +109,13 @@ enum
     SIGNAL_STATE
 };
 
+enum
+{
+    PLAYBACK_STATE_PLAYING = 0,
+    PLAYBACK_STATE_PAUSED  = 1,
+    PLAYBACK_STATE_STOPPED = 2
+};
+
 int GetInputMeta  ( input_item_t* p_input, DBusMessageIter *args );
 int UpdateCaps    ( intf_thread_t* );
 
-- 
1.7.1




More information about the vlc-devel mailing list