[PATCH v2 7/7] android/audio: Add audio_ipc_cleanup function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 android/hal-audio.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 3b94e62..49cc375 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -46,6 +46,14 @@ struct a2dp_audio_dev {
 	struct audio_stream_out *out;
 };
 
+static void audio_ipc_cleanup(void)
+{
+	if (audio_sk >= 0) {
+		shutdown(audio_sk, SHUT_RDWR);
+		audio_sk = -1;
+	}
+}
+
 static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len,
 			void *param, size_t *rsp_len, void *rsp, int *fd)
 {
@@ -188,8 +196,7 @@ static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len,
 
 failed:
 	/* Some serious issue happen on IPC - recover */
-	shutdown(audio_sk, SHUT_RDWR);
-	audio_sk = -1;
+	audio_ipc_cleanup();
 	return AUDIO_STATUS_FAILED;
 }
 
@@ -575,7 +582,7 @@ static int audio_close(hw_device_t *device)
 	DBG("");
 
 	pthread_mutex_lock(&close_mutex);
-	shutdown(audio_sk, SHUT_RDWR);
+	audio_ipc_cleanup();
 	close_thread = true;
 	pthread_mutex_unlock(&close_mutex);
 
@@ -609,7 +616,7 @@ static void *ipc_handler(void *data)
 
 		if (ipc_open_cmd() == AUDIO_STATUS_FAILED) {
 			error("audio: Failed to open endpoint, recover");
-			shutdown(audio_sk, SHUT_RDWR);
+			audio_ipc_cleanup();
 			continue;
 		}
 
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux