summaryrefslogtreecommitdiffstats
path: root/binding
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-16 20:09:11 -0500
commit46ee77dcbee299e260440d92b33273c78acea79a (patch)
tree8fc6775935e8b22dc3658047a68d0b01d295f895 /binding
parente1ecc15a7649b0e8cdccbc288a7491ad0f12f23f (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
Diffstat (limited to 'binding')
-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();