From 25d5c0af09a9d2107bccabfd8d2832f41553f434 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 3 Apr 2009 17:41:03 +0000 Subject: [PATCH] - Avoid disconnecting audio devices straight after they're connected --- bluez-fix-audio-service-disconnect.patch | 90 ++++++++++++++++++++++++ bluez.spec | 8 ++- 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 bluez-fix-audio-service-disconnect.patch diff --git a/bluez-fix-audio-service-disconnect.patch b/bluez-fix-audio-service-disconnect.patch new file mode 100644 index 0000000..00d0558 --- /dev/null +++ b/bluez-fix-audio-service-disconnect.patch @@ -0,0 +1,90 @@ +diff --git a/audio/device.c b/audio/device.c +index f66cd61..84659d3 100644 +--- a/audio/device.c ++++ b/audio/device.c +@@ -257,7 +257,7 @@ static gboolean headset_connect_timeout(gpointer user_data) + dev->priv->headset_timer = 0; + + if (dev->headset) +- headset_config_stream(dev, NULL, NULL); ++ headset_config_stream(dev, FALSE, NULL, NULL); + + return FALSE; + } +@@ -437,7 +437,7 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg, + dev->auto_connect = TRUE; + + if (dev->headset) +- headset_config_stream(dev, NULL, NULL); ++ headset_config_stream(dev, FALSE, NULL, NULL); + else if (dev->sink) { + struct avdtp *session = avdtp_get(&dev->src, &dev->dst); + +diff --git a/audio/headset.c b/audio/headset.c +index 4d70b4a..e1d1cb5 100644 +--- a/audio/headset.c ++++ b/audio/headset.c +@@ -2259,6 +2259,7 @@ unsigned int headset_request_stream(struct audio_device *dev, + } + + unsigned int headset_config_stream(struct audio_device *dev, ++ gboolean auto_dc, + headset_stream_cb_t cb, + void *user_data) + { +@@ -2280,7 +2281,7 @@ unsigned int headset_config_stream(struct audio_device *dev, + if (rfcomm_connect(dev, cb, user_data, &id) < 0) + return 0; + +- hs->auto_dc = TRUE; ++ hs->auto_dc = auto_dc; + hs->pending->target_state = HEADSET_STATE_CONNECTED; + + return id; +diff --git a/audio/headset.h b/audio/headset.h +index dbe1923..73c8a25 100644 +--- a/audio/headset.h ++++ b/audio/headset.h +@@ -65,6 +65,7 @@ void headset_update(struct audio_device *dev, uint16_t svc, + const char *uuidstr); + + unsigned int headset_config_stream(struct audio_device *dev, ++ gboolean auto_dc, + headset_stream_cb_t cb, + void *user_data); + unsigned int headset_request_stream(struct audio_device *dev, +diff --git a/audio/sink.c b/audio/sink.c +index 7f8286d..afdfde6 100644 +--- a/audio/sink.c ++++ b/audio/sink.c +@@ -507,6 +507,8 @@ gboolean sink_setup_stream(struct sink *sink, struct avdtp *session) + if (!sink->session) + return FALSE; + ++ avdtp_set_auto_disconnect(sink->session, FALSE); ++ + if (avdtp_discover(sink->session, discovery_complete, sink) < 0) + return FALSE; + +@@ -538,8 +540,6 @@ static DBusMessage *sink_connect(DBusConnection *conn, + ".AlreadyConnected", + "Device Already Connected"); + +- avdtp_set_auto_disconnect(sink->session, FALSE); +- + if (!sink_setup_stream(sink, NULL)) + return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", + "Failed to create a stream"); +diff --git a/audio/unix.c b/audio/unix.c +index 0cebcec..7aca7ef 100644 +--- a/audio/unix.c ++++ b/audio/unix.c +@@ -904,7 +904,7 @@ static void start_config(struct audio_device *dev, struct unix_client *client) + goto failed; + } + +- id = headset_config_stream(dev, headset_setup_complete, ++ id = headset_config_stream(dev, TRUE, headset_setup_complete, + client); + client->cancel = headset_cancel_stream; + break; diff --git a/bluez.spec b/bluez.spec index b9ce099..83b240e 100644 --- a/bluez.spec +++ b/bluez.spec @@ -1,7 +1,7 @@ Summary: Bluetooth utilities Name: bluez Version: 4.34 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ Group: Applications/System Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz @@ -16,6 +16,8 @@ Patch2: bluez-try-utf8-harder.patch Patch3: bluez-activate-wacom-mode2.patch # http://git.kernel.org/?p=bluetooth/bluez.git;a=commit;h=457056310229911e820357470ee8fb30c82516da Patch4: bluez-fix-audio-service-crasher.patch +# http://git.kernel.org/?p=bluetooth/bluez.git;a=commit;h=1200c9362b09dcc0cd362c046b93c560a7a47256 +Patch5: bluez-fix-audio-service-disconnect.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root URL: http://www.bluez.org/ @@ -105,6 +107,7 @@ use in Bluetooth applications. %patch2 -p1 -b .non-utf8-name %patch3 -p1 -b .wacom %patch4 -p1 -b .audio-service-crasher +%patch5 -p1 -b .audio-service-disconnect %build %configure --enable-cups --enable-hid2hci --enable-dfutool --enable-tools --enable-bccmd --enable-gstreamer --enable-hidd --enable-pand --enable-dund @@ -197,6 +200,9 @@ fi %{_libdir}/alsa-lib/*.so %changelog +* Fri Apr 03 2009 - Bastien Nocera - 4.34-3 +- Avoid disconnecting audio devices straight after they're connected + * Fri Apr 03 2009 - Bastien Nocera - 4.34-2 - Don't crash when audio devices are registered and the adapter is removed