diff options
author | Daniel Orstadius <daniel.orstadius@nokia.com> | 2011-04-01 16:53:09 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2011-04-04 19:47:23 -0700 |
commit | fad9257588d12f10e68cd1841b6144c868c556c3 (patch) | |
tree | a5e9b287707a74a58c507e75d638e8947882a6f2 /audio | |
parent | 6110861065742136fce50ba4d137db72f38db422 (diff) | |
download | bluez-fad9257588d12f10e68cd1841b6144c868c556c3.tar.gz |
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.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/headset.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/audio/headset.c b/audio/headset.c index dff10d15..c605e9d3 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); |