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 13/20] audio/source: Remove dependency on struct audio_device
Date: Wed,  3 Jul 2013 18:15:34 +0300	[thread overview]
Message-ID: <1372864541-10763-14-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 |  2 +-
 profiles/audio/source.c  | 23 +++++++++--------------
 profiles/audio/source.h  |  3 +--
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 12c7b10..4aaf960 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -114,7 +114,7 @@ static int a2dp_source_probe(struct btd_service *service)
 		return -1;
 	}
 
-	audio_dev->source = source_init(audio_dev, service);
+	audio_dev->source = source_init(service);
 
 	return 0;
 }
diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index 87b7309..64570a6 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
@@ -40,11 +40,10 @@
 
 #include "log.h"
 
-#include "../src/adapter.h"
-#include "../src/device.h"
-#include "../src/service.h"
+#include "src/adapter.h"
+#include "src/device.h"
+#include "src/service.h"
 
-#include "device.h"
 #include "avdtp.h"
 #include "media.h"
 #include "a2dp.h"
@@ -56,7 +55,6 @@
 #define STREAM_SETUP_RETRY_TIMER 2
 
 struct source {
-	struct audio_device *dev;
 	struct btd_service *service;
 	struct avdtp *session;
 	struct avdtp_stream *stream;
@@ -88,13 +86,13 @@ static char *str_state[] = {
 
 static void source_set_state(struct source *source, source_state_t new_state)
 {
-	struct audio_device *dev = source->dev;
+	struct btd_device *dev = btd_service_get_device(source->service);
 	source_state_t old_state = source->state;
 	GSList *l;
 
 	source->state = new_state;
 
-	DBG("State changed %s: %s -> %s", device_get_path(dev->btd_dev),
+	DBG("State changed %s: %s -> %s", device_get_path(dev),
 				str_state[old_state], str_state[new_state]);
 
 	for (l = source_callbacks; l != NULL; l = l->next) {
@@ -345,7 +343,6 @@ int source_connect(struct btd_service *service)
 static void source_free(struct btd_service *service)
 {
 	struct source *source = btd_service_get_user_data(service);
-	struct audio_device *dev = source->dev;
 
 	if (source->cb_id)
 		avdtp_stream_remove_cb(source->session, source->stream,
@@ -373,7 +370,6 @@ static void source_free(struct btd_service *service)
 	btd_service_unref(source->service);
 
 	g_free(source);
-	dev->source = NULL;
 }
 
 void source_unregister(struct btd_service *service)
@@ -385,19 +381,18 @@ void source_unregister(struct btd_service *service)
 	source_free(service);
 }
 
-struct btd_service *source_init(struct audio_device *dev,
-						struct btd_service *service)
+struct btd_service *source_init(struct btd_service *service)
 {
+	struct btd_device *dev = btd_service_get_device(service);
 	struct source *source;
 
-	DBG("%s", device_get_path(dev->btd_dev));
+	DBG("%s", device_get_path(dev));
 
 	source = g_new0(struct source, 1);
 
-	source->dev = dev;
 	source->service = btd_service_ref(service);
 
-	source->avdtp_callback_id = avdtp_add_state_cb(dev->btd_dev,
+	source->avdtp_callback_id = avdtp_add_state_cb(dev,
 							avdtp_state_callback,
 							source);
 
diff --git a/profiles/audio/source.h b/profiles/audio/source.h
index b9d4707..4012154 100644
--- a/profiles/audio/source.h
+++ b/profiles/audio/source.h
@@ -41,8 +41,7 @@ unsigned int source_add_state_cb(struct btd_service *service,
 					source_state_cb cb, void *user_data);
 gboolean source_remove_state_cb(unsigned int id);
 
-struct btd_service *source_init(struct audio_device *dev,
-						struct btd_service *service);
+struct btd_service *source_init(struct btd_service *service);
 void source_unregister(struct btd_service *service);
 int source_connect(struct btd_service *service);
 gboolean source_new_stream(struct btd_service *service, struct avdtp *session,
-- 
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 ` Luiz Augusto von Dentz [this message]
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 ` [RFC 16/20] audio/manager: " Luiz Augusto von Dentz
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-14-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).