From 26c1a6bd4217e479695453b0142631244491eaff Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Sat, 14 Dec 2019 14:59:40 -0800 Subject: steering-wheel: add AVRCP controls to signal-composer events Add Previous/Next AVRCP controls to respective events from signal-composer. Bug-AGL: SPEC-3047 Change-Id: I3f8d2576508ce03d667273f273202726aea50ceb Signed-off-by: Matt Ranostay --- binding/afm-mediaplayer-binding.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index 25ec708..36b2ad0 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -390,13 +390,27 @@ static int seek_track(int cmd) return 0; } +static int avrcp_cmd(afb_api_t api, const char *action) +{ + int ret; + json_object *jresp, *response; + + jresp = json_object_new_object(); + json_object_object_add(jresp, "action", json_object_new_string(action)); + + ret = afb_api_call_sync(api, "Bluetooth-Manager", + "avrcp_controls", jresp, &response, NULL, NULL); + json_object_put(response); + + return ret; +} + static void avrcp_controls(afb_req_t request) { const char *value = afb_req_value(request, "value"); const char *action = NULL; afb_api_t api = afb_req_get_api(request); int cmd, ret; - json_object *response, *jresp = NULL; if (!g_strcmp0(value, "connect") || !g_strcmp0(value, "disconnect")) { action = value; @@ -415,13 +429,7 @@ static void avrcp_controls(afb_req_t request) } } - jresp = json_object_new_object(); - json_object_object_add(jresp, "action", json_object_new_string(action)); - - ret = afb_api_call_sync(api, "Bluetooth-Manager", - "avrcp_controls", jresp, &response, NULL, NULL); - json_object_put(response); - + ret = avrcp_cmd(api, action); if (ret < 0) { afb_req_fail(request, "failed", "cannot request avrcp_control"); return; @@ -1075,7 +1083,7 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object if (!data.avrcp_connected) seek_track(NEXT_CMD); else - AFB_WARNING("currently '%s' not supported for AVRCP controls", uid); + avrcp_cmd(api, "Next"); g_mutex_unlock(&mutex); json_object_get(object); @@ -1087,7 +1095,7 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object if (!data.avrcp_connected) seek_track(PREVIOUS_CMD); else - AFB_WARNING("currently %s not supported for AVRCP controls", uid); + avrcp_cmd(api, "Previous"); g_mutex_unlock(&mutex); json_object_get(object); -- cgit 1.2.3-korg