diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-12-14 16:46:39 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-12-17 04:14:18 +0000 |
commit | 27eaf032ab679bc077a3ee9a143f03417d97c4b0 (patch) | |
tree | c3f189d9094dce9cd55013b354502d91ec8f88b8 | |
parent | fe715ce75779fcf689b52114659799fca2554c2d (diff) |
binding: mediaplayer: fix reporting to mediaplayer UI
1) local media wasn't stopping playback when a2dp transport was connected
2) when disconnecting a2dp the local media metadata wasn't being displayed
3) pausing wasn't sending an event to the UI subscriber
Bug-AGL: SPEC-1630
Change-Id: I67eee3af44169c8138d03aff591200884f1dd6ae
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r-- | binding/afm-mediaplayer-binding.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index 37cd85e..7358f95 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -40,6 +40,8 @@ static GList *playlist = NULL; static GList *metadata_track = NULL; static GList *current_track = NULL; +static json_object *populate_json_metadata(void); + typedef struct _CustomData { GstElement *playbin, *fake_sink, *alsa_sink; gboolean playing; @@ -406,10 +408,18 @@ static void gstreamer_controls(afb_req_t request) break; } case PAUSE_CMD: - jresp = json_object_new_object(); gst_element_set_state(data.playbin, GST_STATE_PAUSED); AFB_DEBUG("GSTREAMER playbin.state = GST_STATE_PAUSED"); data.playing = FALSE; + + /* metadata event */ + jresp = populate_json_metadata(); + json_object_object_add(jresp, "status", + json_object_new_string("stopped")); + afb_event_push(metadata_event, jresp); + + /* status returned */ + jresp = json_object_new_object(); json_object_object_add(jresp, "playing", json_object_new_boolean(FALSE)); break; case PREVIOUS_CMD: @@ -923,8 +933,15 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object gboolean state = json_object_get_boolean(val); data.avrcp_connected = state; - if (state) + if (state) { + data.playing = FALSE; gst_element_set_state(data.playbin, GST_STATE_PAUSED); + } else { + json_object *jresp = populate_json_metadata(); + json_object_object_add(jresp, "status", + json_object_new_string("stopped")); + afb_event_push(metadata_event, jresp); + } } pthread_mutex_unlock(&mutex); |