aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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) {