[PATCH] Fix check for valid SCO socket before shutdown

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

 



From 7070265aabd5c497df095e13dfbafe582db70eea Mon Sep 17 00:00:00 2001
From: Daniel Orstadius <daniel.orstadius@xxxxxxxxx>
Date: Fri, 1 Apr 2011 16:53:09 +0300
Subject: [PATCH] Fix check for valid SCO socket before shutdown

To prevent a crash in the event that there is a request to remove
the audio connection when it has already been disconnected by the
remote.

Set headset state to connected directly if there is no SCO socket.
---
 audio/headset.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/audio/headset.c b/audio/headset.c
index dff10d1..c605e9d 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -2397,10 +2397,16 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
 		hs->dc_timer = 0;
 	}
 
-	sock = g_io_channel_unix_get_fd(hs->sco);
+	if (hs->sco) {
+		sock = g_io_channel_unix_get_fd(hs->sco);
 
-	/* shutdown but leave the socket open and wait for hup */
-	shutdown(sock, SHUT_RDWR);
+		/* shutdown but leave the socket open and wait for hup */
+		shutdown(sock, SHUT_RDWR);
+	} else {
+		headset_set_state(dev, HEADSET_STATE_CONNECTED);
+
+		g_idle_add((GSourceFunc) dummy_connect_complete, dev);
+	}
 
 	id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data);
 
-- 
1.6.0.4


[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