2011-07-08 06:12:49

by Lukasz Rymanowski

[permalink] [raw]
Subject: [PATCH] Fix for headset state callback

From: Lukasz Rymanowski <[email protected]>

Headset watch is not registered per device.
Therefore, when headset disconnects, there is need to
check for which audio device it is called.
---
audio/media.c | 7 ++++++-
audio/transport.c | 5 +++++
audio/transport.h | 1 +
3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/audio/media.c b/audio/media.c
index 3978a17..57bf7c9 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -167,7 +167,12 @@ static void headset_state_changed(struct audio_device *dev,

switch (new_state) {
case HEADSET_STATE_DISCONNECTED:
- media_endpoint_clear_configuration(endpoint);
+ if (endpoint->transport &&
+ media_transport_get_dev(endpoint->transport) == dev) {
+
+ DBG("Clear endpoint %p", endpoint);
+ media_endpoint_clear_configuration(endpoint);
+ }
break;
case HEADSET_STATE_CONNECTING:
media_endpoint_set_configuration(endpoint, dev, NULL, 0,
diff --git a/audio/transport.c b/audio/transport.c
index 7c99207..cd2de37 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -918,3 +918,8 @@ void media_transport_update_delay(struct media_transport *transport,
MEDIA_TRANSPORT_INTERFACE, "Delay",
DBUS_TYPE_UINT16, &transport->delay);
}
+
+struct audio_device *media_transport_get_dev(struct media_transport *transport)
+{
+ return transport->device;
+}
\ No newline at end of file
diff --git a/audio/transport.h b/audio/transport.h
index be4d666..1f86cde 100644
--- a/audio/transport.h
+++ b/audio/transport.h
@@ -32,6 +32,7 @@ struct media_transport *media_transport_create(DBusConnection *conn,

void media_transport_destroy(struct media_transport *transport);
const char *media_transport_get_path(struct media_transport *transport);
+struct audio_device *media_transport_get_dev(struct media_transport *transport);
void media_transport_update_delay(struct media_transport *transport,
uint16_t delay);
void transport_get_properties(struct media_transport *transport,
--




2011-07-10 07:58:43

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Fix for headset state callback

Hi Lucasz,

On Fri, Jul 08, 2011, [email protected] wrote:
> Headset watch is not registered per device. Therefore, when headset
> disconnects, there is need to check for which audio device it is
> called.
> ---
> audio/media.c | 7 ++++++-
> audio/transport.c | 5 +++++
> audio/transport.h | 1 +
> 3 files changed, 12 insertions(+), 1 deletions(-)

Applied. Thanks.

Johan