return rsp.id;
}
+static int ipc_close_cmd(uint8_t endpoint_id)
+{
+ struct audio_cmd_close cmd;
+ int result;
+
+ DBG("");
+
+ cmd.id = endpoint_id;
+
+ result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_CLOSE,
+ sizeof(cmd), &cmd, NULL, NULL, NULL);
+
+ return result;
+}
+
static int register_endpoints(void)
{
struct audio_endpoint *ep = &audio_endpoints[0];
return AUDIO_STATUS_SUCCESS;
}
+static void unregister_endpoints(void)
+{
+ size_t i;
+
+ for (i = 0; i < MAX_AUDIO_ENDPOINTS; i++) {
+ struct audio_endpoint *ep = &audio_endpoints[i];
+
+ if (ep->id) {
+ ipc_close_cmd(ep->id);
+ memset(ep, 0, sizeof(*ep));
+ }
+ }
+}
+
static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
size_t bytes)
{
if (register_endpoints() != AUDIO_STATUS_SUCCESS) {
error("audio: Failed to register endpoints");
+ unregister_endpoints();
+
shutdown(audio_sk, SHUT_RDWR);
continue;
}
pthread_mutex_unlock(&close_mutex);
}
+ unregister_endpoints();
+
info("Closing Audio IPC thread");
return NULL;
}