aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-12-13 19:48:36 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-12-14 06:24:14 +0000
commitfe715ce75779fcf689b52114659799fca2554c2d (patch)
tree0e6bfd5871422dd68cba4b81482f4bc9e909d2d6
parentabb035ab5b74757cd7577f493bc30e7aac0f5227 (diff)
binding: mediaplayer: fix connect/disconnect of a2dp/avrcp profiles
Bug-AGL: SPEC-1630 Change-Id: I38fc2c131b3d56a4b5a0a87f3bcd0eb27af5bb66 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/afm-mediaplayer-binding.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c
index 049fb2d..37cd85e 100644
--- a/binding/afm-mediaplayer-binding.c
+++ b/binding/afm-mediaplayer-binding.c
@@ -336,18 +336,24 @@ 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 = get_command_index(value), ret;
+ int cmd, ret;
json_object *response, *jresp = NULL;
- if (cmd < 0) {
- afb_req_fail(request, "failed", "unknown command");
- return;
- }
+ if (!g_strcmp0(value, "connect") || !g_strcmp0(value, "disconnect")) {
+ action = value;
+ } else {
+ cmd = get_command_index(value);
- action = avrcp_control_commands[cmd];
- if (!action) {
- afb_req_fail(request, "failed", "command not supported");
- return;
+ if (cmd < 0) {
+ afb_req_fail(request, "failed", "unknown command");
+ return;
+ }
+
+ action = avrcp_control_commands[cmd];
+ if (!action) {
+ afb_req_fail(request, "failed", "command not supported");
+ return;
+ }
}
jresp = json_object_new_object();
@@ -501,10 +507,13 @@ static void controls(afb_req_t request)
}
pthread_mutex_lock(&mutex);
- if (data.avrcp_connected)
+ if (data.avrcp_connected || !g_strcmp0(value, "connect")) {
+ pthread_mutex_unlock(&mutex);
avrcp_controls(request);
- else
- gstreamer_controls(request);
+ return;
+ }
+
+ gstreamer_controls(request);
pthread_mutex_unlock(&mutex);
}