aboutsummaryrefslogtreecommitdiffstats
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:37:58 -0800
commit3c0329781bd24849dc054516762c8ad1e27927e0 (patch)
tree3d67d92a68511e3aca1821ea9e48ab499fbedeab
parent46ee77dcbee299e260440d92b33273c78acea79a (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>
-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);