Re: Media API with more than one headset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Peter,

Can you try attached patch ?
At least you should not lose audio on all the headsets when
disconnecting one of them.

\Lukasz
From 85be2ecd2f6d769f7a6fd51f2556eeaac38e85a0 Mon Sep 17 00:00:00 2001
From: Lukasz Rymanowski <lukasz.rymanowski@xxxxxxxxx>
Date: Tue, 28 Jun 2011 19:08:48 +0200
Subject: [PATCH] Fix for media callback handling

---
 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 bbb77cf..eb5fed9 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -166,7 +166,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,
-- 
1.7.0.4


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux