From f5ab22bbfa00862e60d232648f1674fc9181ceb8 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 8 Oct 2008 17:50:59 +0200 Subject: Check for headset connected state when unregistering In theory a headset could be in a connected state when the driver for it gets unregistered. Do proper cleanup in this case (call headset_set_state(hs, DISCONNECTED)). Currently this happens even in practice due to a bug where we incorrectly assume that a device has removed a profile when in fact it's just hiding it while it's connected. --- audio/headset.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'audio') diff --git a/audio/headset.c b/audio/headset.c index a4fe84fe..a0b7af54 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1899,6 +1899,12 @@ static void headset_free(struct audio_device *dev) static void path_unregister(void *data) { struct audio_device *dev = data; + struct headset *hs = dev->headset; + + if (hs->state > HEADSET_STATE_DISCONNECTED) { + debug("Headset unregistered while device was connected!"); + headset_set_state(hs, HEADSET_STATE_DISCONNECTED); + } info("Unregistered interface %s on path %s", AUDIO_HEADSET_INTERFACE, dev->path); -- cgit