summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-12-12 11:04:40 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-12-13 15:18:11 -0800
commite1ecc15a7649b0e8cdccbc288a7491ad0f12f23f (patch)
tree9f4fd8fe1329c8de3494402cfc244f1b9b2bfe93
parentc8728cc0cb5aa137d20d8c8c2601141ac3879e60 (diff)
mediaplayer: check for corking from PipeWire
Check if PipeWire is corking the audio stream and if so don't process signal-composer events till uncorked. Bug-AGL: SPEC-3023 Change-Id: Ib4d4de1f1627426d69e3f19501d38ff2d3c88a62 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/afm-mediaplayer-binding.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index b2e73d9..6b487d1 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -66,6 +66,7 @@ typedef struct _CustomData {
GstElement *playbin, *fake_sink, *audio_sink;
gboolean playing;
int loop_state;
+ gboolean corked;
gboolean one_time;
long int volume;
gint64 position;
@@ -78,6 +79,7 @@ typedef struct _CustomData {
CustomData data = {
.volume = 50,
+ .corked = FALSE,
.position = GST_CLOCK_TIME_NONE,
.duration = GST_CLOCK_TIME_NONE,
};
@@ -805,6 +807,23 @@ static gboolean handle_message(GstBus *bus, GstMessage *msg, CustomData *data)
break;
}
+ case GST_MESSAGE_REQUEST_STATE: {
+ GstState state;
+
+ gst_message_parse_request_state(msg, &state);
+
+ g_mutex_lock(&mutex);
+
+ if (state == GST_STATE_PAUSED) {
+ data->corked = TRUE;
+ } else if (state == GST_STATE_PLAYING) {
+ data->corked = FALSE;
+ }
+
+ g_mutex_unlock(&mutex);
+
+ break;
+ }
default:
break;
}
@@ -1001,6 +1020,7 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object
json_object *tmp = NULL;
const char *uid;
const char *value;
+ int corked;
json_object_object_get_ex(object, "uid", &tmp);
if (tmp == NULL)
@@ -1010,6 +1030,14 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object
if (strncmp(uid, "event.media.", 12))
return;
+ g_mutex_lock(&mutex);
+ corked = data.corked;
+ g_mutex_unlock(&mutex);
+
+ // drop events if we are in corked state
+ if (corked)
+ return;
+
json_object_object_get_ex(object, "value", &tmp);
if (tmp == NULL)
return;