summaryrefslogtreecommitdiffstats
path: root/module-4a-client.c
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2018-07-19 15:25:59 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2018-08-28 12:14:12 +0300
commita33fecab27f30f1479e435828fa1a2ac39a7e1c8 (patch)
tree5e734ea0ff780d8fdb8f314adfdd7b9038cfdd99 /module-4a-client.c
parent4bb6999d991b2a64eed96e54adf25cc978a580cf (diff)
close the 4a "device" if the alsa device string didn't work out
sometimes 4a returns an empty device string and then it thinks that we are using it, so it doesn't allow re-opening it Change-Id: I60034c47bddc574c67d89d016b5590418e7c70d5 Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Diffstat (limited to 'module-4a-client.c')
-rw-r--r--module-4a-client.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/module-4a-client.c b/module-4a-client.c
index 8dead4c..3e519ca 100644
--- a/module-4a-client.c
+++ b/module-4a-client.c
@@ -216,6 +216,15 @@ static void device_open_cb(enum m4a_afb_reply r,
pa_semaphore_post(stream->semaphore);
}
+/* invoked in the afb communication thread */
+static void device_close_cb(enum m4a_afb_reply r,
+ json_object *response,
+ m4a_stream *stream) {
+ pa_log_debug("4A replied: %s",
+ (r == M4A_AFB_REPLY_OK) ? "OK" : "ERROR");
+ m4a_stream_free(stream);
+}
+
static pa_hook_result_t sink_input_put_cb(pa_core *core,
pa_sink_input *i,
pa_module *self) {
@@ -259,6 +268,13 @@ static pa_hook_result_t sink_input_put_cb(pa_core *core,
} else {
pa_xfree(stream->device_uri);
stream->device_uri = NULL;
+
+ jparams = json_object_new_object();
+ json_object_object_add(jparams, "action",
+ json_object_new_string("close"));
+
+ m4a_afb_call_async(d->comm, role, jparams,
+ (m4a_afb_done_cb_t) device_close_cb, stream);
}
}
@@ -274,15 +290,6 @@ static pa_hook_result_t sink_input_put_cb(pa_core *core,
return PA_HOOK_OK;
}
-/* invoked in the afb communication thread */
-static void device_close_cb(enum m4a_afb_reply r,
- json_object *response,
- m4a_stream *stream) {
- pa_log_debug("4A replied: %s",
- (r == M4A_AFB_REPLY_OK) ? "OK" : "ERROR");
- m4a_stream_free(stream);
-}
-
static pa_hook_result_t sink_input_unlink_post_cb(pa_core *core,
pa_sink_input *i,
pa_module *self) {