aboutsummaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-12-14 14:59:40 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-12-17 13:36:41 -0800
commit26c1a6bd4217e479695453b0142631244491eaff (patch)
tree162aa762f259f80d825ccda36beff7da8d289e6d /binding
parent62a60ac4bb17422f7c4718a6e7c355f4d357c282 (diff)
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 <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r--binding/afm-mediaplayer-binding.c28
1 files 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);