linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC 16/20] audio/manager: Remove dependency on struct audio_device
Date: Wed,  3 Jul 2013 18:15:37 +0300	[thread overview]
Message-ID: <1372864541-10763-17-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1372864541-10763-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This is part of the work necessary to completely remove
struct audio_device
---
 profiles/audio/manager.c | 132 +++++++++++++----------------------------------
 profiles/audio/manager.h |  10 ----
 2 files changed, 37 insertions(+), 105 deletions(-)

diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 4aaf960..785d165 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -50,13 +50,12 @@
 
 #include "lib/uuid.h"
 #include "glib-helper.h"
-#include "../src/adapter.h"
-#include "../src/device.h"
-#include "../src/profile.h"
-#include "../src/service.h"
+#include "src/adapter.h"
+#include "src/device.h"
+#include "src/profile.h"
+#include "src/service.h"
 
 #include "log.h"
-#include "device.h"
 #include "error.h"
 #include "avdtp.h"
 #include "media.h"
@@ -69,107 +68,71 @@
 #include "sdpd.h"
 
 static GKeyFile *config = NULL;
-static GSList *devices = NULL;
 
-static struct audio_device *get_audio_dev(struct btd_device *device)
-{
-	return manager_get_audio_device(device, TRUE);
-}
-
-static struct audio_device *manager_find_device(struct btd_device *device)
+static int a2dp_source_probe(struct btd_service *service)
 {
-	GSList *l;
+	struct btd_device *dev = btd_service_get_device(service);
 
-	for (l = devices; l != NULL; l = l->next) {
-		struct audio_device *dev = l->data;
+	DBG("path %s", device_get_path(dev));
 
-		if (dev->btd_dev == device)
-			return dev;
-	}
+	source_init(service);
 
-	return NULL;
+	return 0;
 }
 
-static void audio_remove(struct btd_service *service)
+static void a2dp_source_remove(struct btd_service *service)
 {
-	struct btd_device *device = btd_service_get_device(service);
-	struct audio_device *dev;
-
-	dev = manager_find_device(device);
-	if (dev == NULL)
-		return;
-
-	devices = g_slist_remove(devices, dev);
-	audio_device_unregister(dev);
+	source_unregister(service);
 }
 
-static int a2dp_source_probe(struct btd_service *service)
+static int a2dp_sink_probe(struct btd_service *service)
 {
-	struct btd_device *device = btd_service_get_device(service);
-	struct audio_device *audio_dev;
+	struct btd_device *dev = btd_service_get_device(service);
 
-	audio_dev = get_audio_dev(device);
-	if (!audio_dev) {
-		DBG("unable to get a device object");
-		return -1;
-	}
+	DBG("path %s", device_get_path(dev));
 
-	audio_dev->source = source_init(service);
+	sink_init(service);
 
 	return 0;
 }
 
-static int a2dp_sink_probe(struct btd_service *service)
+static void a2dp_sink_remove(struct btd_service *service)
 {
-	struct btd_device *device = btd_service_get_device(service);
-	struct audio_device *audio_dev;
-
-	audio_dev = get_audio_dev(device);
-	if (!audio_dev) {
-		DBG("unable to get a device object");
-		return -1;
-	}
-
-	audio_dev->sink = sink_init(service);
-
-	return 0;
+	sink_unregister(service);
 }
 
 static int avrcp_target_probe(struct btd_service *service)
 {
-	struct btd_device *device = btd_service_get_device(service);
-	struct audio_device *audio_dev;
-
-	audio_dev = get_audio_dev(device);
-	if (!audio_dev) {
-		DBG("unable to get a device object");
-		return -1;
-	}
+	struct btd_device *dev = btd_service_get_device(service);
 
-	audio_dev->control = control_init_target(service);
+	DBG("path %s", device_get_path(dev));
 
-	if (audio_dev->sink && sink_is_active(audio_dev->sink))
-		avrcp_connect(audio_dev->btd_dev);
+	control_init_target(service);
 
 	return 0;
 }
 
+static void avrcp_target_remove(struct btd_service *service)
+{
+	control_unregister(service);
+}
+
 static int avrcp_remote_probe(struct btd_service *service)
 {
-	struct btd_device *device = btd_service_get_device(service);
-	struct audio_device *audio_dev;
+	struct btd_device *dev = btd_service_get_device(service);
 
-	audio_dev = get_audio_dev(device);
-	if (!audio_dev) {
-		DBG("unable to get a device object");
-		return -1;
-	}
+	DBG("path %s", device_get_path(dev));
 
-	audio_dev->control = control_init_remote(service);
+	control_init_remote(service);
 
 	return 0;
 }
 
+static void avrcp_remote_remove(struct btd_service *service)
+{
+	control_unregister(service);
+}
+
 static int a2dp_source_connect(struct btd_service *service)
 {
 	struct btd_device *dev = btd_service_get_device(service);
@@ -314,7 +277,7 @@ static struct btd_profile a2dp_source_profile = {
 
 	.remote_uuid	= A2DP_SOURCE_UUID,
 	.device_probe	= a2dp_source_probe,
-	.device_remove	= audio_remove,
+	.device_remove	= a2dp_source_remove,
 
 	.auto_connect	= true,
 	.connect	= a2dp_source_connect,
@@ -330,7 +293,7 @@ static struct btd_profile a2dp_sink_profile = {
 
 	.remote_uuid	= A2DP_SINK_UUID,
 	.device_probe	= a2dp_sink_probe,
-	.device_remove	= audio_remove,
+	.device_remove	= a2dp_sink_remove,
 
 	.auto_connect	= true,
 	.connect	= a2dp_sink_connect,
@@ -345,7 +308,7 @@ static struct btd_profile avrcp_target_profile = {
 
 	.remote_uuid	= AVRCP_TARGET_UUID,
 	.device_probe	= avrcp_target_probe,
-	.device_remove	= audio_remove,
+	.device_remove	= avrcp_target_remove,
 
 	.connect	= avrcp_target_connect,
 	.disconnect	= avrcp_target_disconnect,
@@ -359,7 +322,7 @@ static struct btd_profile avrcp_remote_profile = {
 
 	.remote_uuid	= AVRCP_REMOTE_UUID,
 	.device_probe	= avrcp_remote_probe,
-	.device_remove	= audio_remove,
+	.device_remove	= avrcp_remote_remove,
 
 	.adapter_probe	= avrcp_remote_server_probe,
 	.adapter_remove = avrcp_remote_server_remove,
@@ -401,27 +364,6 @@ void audio_manager_exit(void)
 	btd_unregister_adapter_driver(&media_driver);
 }
 
-struct audio_device *manager_get_audio_device(struct btd_device *device,
-							gboolean create)
-{
-	struct audio_device *dev;
-
-	dev = manager_find_device(device);
-	if (dev)
-		return dev;
-
-	if (!create)
-		return NULL;
-
-	dev = audio_device_register(device);
-	if (!dev)
-		return NULL;
-
-	devices = g_slist_append(devices, dev);
-
-	return dev;
-}
-
 static void set_fast_connectable(struct btd_adapter *adapter,
 							gpointer user_data)
 {
diff --git a/profiles/audio/manager.h b/profiles/audio/manager.h
index b8d8ef7..de8d791 100644
--- a/profiles/audio/manager.h
+++ b/profiles/audio/manager.h
@@ -22,19 +22,9 @@
  *
  */
 
-struct enabled_interfaces {
-	gboolean sink;
-	gboolean source;
-	gboolean control;
-	gboolean media_player;
-};
-
 int audio_manager_init(GKeyFile *config);
 void audio_manager_exit(void);
 
-struct audio_device *manager_get_audio_device(struct btd_device *device,
-							gboolean create);
-
 /* TRUE to enable fast connectable and FALSE to disable fast connectable for all
  * audio adapters. */
 void manager_set_fast_connectable(gboolean enable);
-- 
1.8.1.4


  parent reply	other threads:[~2013-07-03 15:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 15:15 [RFC 00/20] Remove audio_device and introduce policy plugin Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 01/20] audio/sink: Use service user_data for private data Luiz Augusto von Dentz
2013-07-04  6:36   ` Mikel Astiz
2013-07-04  6:49     ` Luiz Augusto von Dentz
2013-07-04 14:28   ` Vinicius Costa Gomes
2013-07-05  6:38     ` Mikel Astiz
2013-07-08 10:00       ` Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 02/20] audio/source: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 03/20] audio/control: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 04/20] audio/sink: Reduce dependency on struct audio_device Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 05/20] audio/source: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 06/20] audio/control: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 07/20] audio/AVCTP: Remove " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 08/20] audio/AVDTP: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 09/20] audio/AVRCP: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 10/20] audio/control: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 11/20] audio/A2DP: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 12/20] audio/sink: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 13/20] audio/source: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 14/20] audio/media: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 15/20] audio/transport: " Luiz Augusto von Dentz
2013-07-03 15:15 ` Luiz Augusto von Dentz [this message]
2013-07-03 15:15 ` [RFC 17/20] audio/main: " Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 18/20] plugins/policy: Reword audio policy code in a simple plugin Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 19/20] audio/sink: Fix not notifying service about connection state Luiz Augusto von Dentz
2013-07-04  7:05   ` Mikel Astiz
2013-07-04  7:17     ` Luiz Augusto von Dentz
2013-07-03 15:15 ` [RFC 20/20] audio/source: " Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372864541-10763-17-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).