From fad9257588d12f10e68cd1841b6144c868c556c3 Mon Sep 17 00:00:00 2001 From: Daniel Orstadius 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 file changed, 9 insertions(+), 3 deletions(-) diff --git a/audio/headset.c b/audio/headset.c index dff10d15e..c605e9d31 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); -- 2.47.3