[vlc-devel] [PATCH 2/2] dbus: notify previous/next state changes
Romain Vimont
rom1v at videolabs.io
Tue Apr 6 16:16:39 UTC 2021
Changes of state indicating if "previous" and "next" actions are enabled
must be signaled to D-Bus.
Fixes #23603
---
modules/control/dbus/dbus.c | 30 ++++++++++++++++++++++++++++++
modules/control/dbus/dbus_common.h | 2 ++
modules/control/dbus/dbus_player.c | 2 ++
3 files changed, 34 insertions(+)
diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index 52a675f16f..5d56a8747a 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -139,6 +139,10 @@ static void playlist_on_playback_order_changed(vlc_playlist_t *,
void *);
static void playlist_on_current_index_changed(vlc_playlist_t *,
ssize_t, void *);
+static void playlist_on_has_prev_changed(vlc_playlist_t *playlist,
+ bool has_prev, void *data);
+static void playlist_on_has_next_changed(vlc_playlist_t *playlist,
+ bool has_next, void *data);
static void player_on_state_changed(vlc_player_t *,
enum vlc_player_state, void *);
@@ -266,6 +270,8 @@ static int Open( vlc_object_t *p_this )
.on_playback_repeat_changed = playlist_on_playback_repeat_changed,
.on_playback_order_changed = playlist_on_playback_order_changed,
.on_current_index_changed = playlist_on_current_index_changed,
+ .on_has_prev_changed = playlist_on_has_prev_changed,
+ .on_has_next_changed = playlist_on_has_next_changed,
};
p_sys->playlist_listener =
vlc_playlist_AddListener(playlist, &playlist_cbs, p_intf, false);
@@ -680,6 +686,12 @@ static void ProcessEvents( intf_thread_t *p_intf,
case SIGNAL_SEEK:
SeekedEmit( p_intf );
break;
+ case SIGNAL_CAN_GO_PREVIOUS:
+ vlc_dictionary_insert( &player_properties, "CanGoPrevious", NULL );
+ break;
+ case SIGNAL_CAN_GO_NEXT:
+ vlc_dictionary_insert( &player_properties, "CanGoNext", NULL );
+ break;
default:
vlc_assert_unreachable();
}
@@ -1032,6 +1044,24 @@ playlist_on_current_index_changed(vlc_playlist_t *playlist,
(void) playlist; (void) index;
}
+static void
+playlist_on_has_prev_changed(vlc_playlist_t *playlist, bool has_prev,
+ void *data)
+{
+ add_event_signal(data,
+ &(callback_info_t){ .signal = SIGNAL_CAN_GO_PREVIOUS });
+ (void) playlist; (void) has_prev;
+}
+
+static void
+playlist_on_has_next_changed(vlc_playlist_t *playlist, bool has_next,
+ void *data)
+{
+ add_event_signal(data,
+ &(callback_info_t){ .signal = SIGNAL_CAN_GO_NEXT });
+ (void) playlist; (void) has_next;
+}
+
static void
player_on_state_changed(vlc_player_t *player, enum vlc_player_state state,
void *data)
diff --git a/modules/control/dbus/dbus_common.h b/modules/control/dbus/dbus_common.h
index 7cb82212bc..28c60d509d 100644
--- a/modules/control/dbus/dbus_common.h
+++ b/modules/control/dbus/dbus_common.h
@@ -128,6 +128,8 @@ enum
SIGNAL_SEEK,
SIGNAL_CAN_SEEK,
SIGNAL_CAN_PAUSE,
+ SIGNAL_CAN_GO_PREVIOUS,
+ SIGNAL_CAN_GO_NEXT,
SIGNAL_VOLUME_CHANGE,
SIGNAL_VOLUME_MUTED,
SIGNAL_FULLSCREEN
diff --git a/modules/control/dbus/dbus_player.c b/modules/control/dbus/dbus_player.c
index 0fb8e62d7f..c56de9d745 100644
--- a/modules/control/dbus/dbus_player.c
+++ b/modules/control/dbus/dbus_player.c
@@ -837,6 +837,8 @@ PropertiesChangedSignal( intf_thread_t *p_intf,
PROPERTY_ENTRY( CanSeek, "b" )
PROPERTY_ENTRY( CanPlay, "b" )
PROPERTY_ENTRY( CanPause, "b" )
+ PROPERTY_ENTRY( CanGoPrevious, "b" )
+ PROPERTY_ENTRY( CanGoNext, "b" )
PROPERTY_MAPPING_END
free( ppsz_properties[i] );
--
2.31.0
More information about the vlc-devel
mailing list