aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-12-16 20:07:55 -0500
committerScott Murray <scott.murray@konsulko.com>2019-12-17 00:56:30 +0000
commit62a60ac4bb17422f7c4718a6e7c355f4d357c282 (patch)
tree353527b18b224b904b2adf4869cfd66c03fb29de
parentff6e4a14062aae6cfa0e381d186185287cd838cd (diff)
Add workaround for Wireplumber policy implementation
Add hopefully temporary workarounds for current Wireplumber policy implementation that requires taking gstreamer state to READY or STOPPED to trigger policy. Bug-AGL: SPEC-3061 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I9ade3615945b6821ce78c22ffea292b16a4fb93c
-rw-r--r--binding/afm-mediaplayer-binding.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 6b487d1..25ec708 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -32,6 +32,10 @@
#define AFB_BINDING_VERSION 3
#include <afb/afb-binding.h>
+// Flag to enable using GST_STATE_READY instead of GST_STATE_PAUSED to trigger
+// Wireplumber policy mechanism. Hopefully temporary.
+#define WIREPLUMBER_WORKAROUND
+
static afb_event_t playlist_event;
static afb_event_t metadata_event;
static GMutex mutex;
@@ -223,8 +227,13 @@ static int set_media_uri(struct playlist_item *item, int state)
g_object_set(data.playbin, "audio-sink", data.fake_sink, NULL);
AFB_DEBUG("GSTREAMER playbin.audio-sink = fake-sink");
+#ifdef WIREPLUMBER_WORKAROUND
+ gst_element_set_state(data.playbin, GST_STATE_READY);
+ AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_READY");
+#else
gst_element_set_state(data.playbin, GST_STATE_PAUSED);
AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_PAUSED");
+#endif
}
double vol = (double) data.volume / 100.0;
@@ -456,8 +465,13 @@ static void gstreamer_controls(afb_req_t request)
break;
}
case PAUSE_CMD:
+#ifdef WIREPLUMBER_WORKAROUND
+ mediaplayer_set_role_state(api, GST_STATE_READY);
+ AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_READY");
+#else
mediaplayer_set_role_state(api, GST_STATE_PAUSED);
AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_PAUSED");
+#endif
data.playing = FALSE;
/* metadata event */
@@ -919,8 +933,13 @@ static void gstreamer_init(afb_api_t api)
g_object_set(data.playbin, "audio-sink", data.fake_sink, NULL);
AFB_DEBUG("GSTREAMER playbin.audio-sink = fake-sink");
+#ifdef WIREPLUMBER_WORKAROUND
+ gst_element_set_state(data.playbin, GST_STATE_READY);
+ AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_READY");
+#else
gst_element_set_state(data.playbin, GST_STATE_PAUSED);
AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_PAUSED");
+#endif
bus = gst_element_get_bus(data.playbin);
gst_bus_add_watch(bus, (GstBusFunc) handle_message, &data);
@@ -997,7 +1016,11 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object
data.avrcp_connected = state;
if (state) {
+#ifdef WIREPLUMBER_WORKAROUND
+ mediaplayer_set_role_state(api, GST_STATE_READY);
+#else
mediaplayer_set_role_state(api, GST_STATE_PAUSED);
+#endif
} else {
json_object *jresp = populate_json_metadata();