summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-02-16 19:58:15 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-02-16 19:58:15 +0000
commitbc6af96cbd6f8b073c9049e812b6f4a082c66a81 (patch)
tree60c842df60b99d7e501fc9d74fe88b4692d0b13a /audio
parent6a37133f8c7cecb74d84b4f4f81fea90892ae652 (diff)
Disconnect SCO if RFCOMM gets disconnected
Diffstat (limited to 'audio')
-rw-r--r--audio/headset.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/audio/headset.c b/audio/headset.c
index 489cb09c..107cab47 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -273,6 +273,23 @@ static headset_event_t parse_headset_event(const char *buf, char *rsp, int rsp_l
return HEADSET_EVENT_UNKNOWN;
}
+static void close_sco(struct headset *hs)
+{
+ g_io_channel_close(hs->sco);
+ g_io_channel_unref(hs->sco);
+ hs->sco = NULL;
+ if (hs->audio_output) {
+ g_io_channel_unref(hs->audio_output);
+ hs->audio_output = NULL;
+ }
+ if (hs->audio_input)
+ audio_headset_close_input(hs);
+ assert(hs->rfcomm);
+ hs->state = HEADSET_STATE_CONNECTED;
+ hs_signal(hs, "Stopped");
+}
+
+
static gboolean rfcomm_io_cb(GIOChannel *chan, GIOCondition cond,
struct headset *hs)
{
@@ -364,6 +381,8 @@ static gboolean rfcomm_io_cb(GIOChannel *chan, GIOCondition cond,
return TRUE;
failed:
+ if (hs->sco)
+ close_sco(hs);
hs_disconnect(hs, NULL);
return FALSE;
@@ -476,22 +495,6 @@ failed:
return FALSE;
}
-static void close_sco(struct headset *hs)
-{
- g_io_channel_close(hs->sco);
- g_io_channel_unref(hs->sco);
- hs->sco = NULL;
- if (hs->audio_output) {
- g_io_channel_unref(hs->audio_output);
- hs->audio_output = NULL;
- }
- if (hs->audio_input)
- audio_headset_close_input(hs);
- assert(hs->rfcomm);
- hs->state = HEADSET_STATE_CONNECTED;
- hs_signal(hs, "Stopped");
-}
-
static gboolean sco_input_to_audio_output_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
{
struct headset *hs = data;
@@ -536,7 +539,8 @@ static gboolean sco_input_to_audio_output_cb(GIOChannel *chan, GIOCondition cond
disconn:
error("Audio connection got disconnected");
- close_sco(hs);
+ if (hs->sco)
+ close_sco(hs);
return FALSE;
}