From: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
Subject: [PATCH v2 3/9] Use state change callback from media interface
Date: Mon, 22 Aug 2011 17:30:41 +0200 [thread overview]
Message-ID: <1314027047-5476-4-git-send-email-frederic.dalleau@linux.intel.com> (raw)
In-Reply-To: <1314027047-5476-1-git-send-email-frederic.dalleau@linux.intel.com>
When a HFPHS endpoint is created, media will start to watch for
HandsfreeGateway state changes. media call SetConfiguration upon
connection and ClearConfiguration upon disconnection.
---
audio/media.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/audio/media.c b/audio/media.c
index 2076d04..ae2b471 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -43,6 +43,7 @@
#include "transport.h"
#include "a2dp.h"
#include "headset.h"
+#include "gateway.h"
#include "manager.h"
#ifndef DBUS_TYPE_UNIX_FD
@@ -78,6 +79,7 @@ struct media_endpoint {
uint8_t *capabilities; /* Endpoint property capabilities */
size_t size; /* Endpoint capabilities size */
guint hs_watch;
+ guint ag_watch;
guint watch;
struct endpoint_request *request;
struct media_transport *transport;
@@ -118,6 +120,9 @@ static void media_endpoint_destroy(struct media_endpoint *endpoint)
if (endpoint->hs_watch)
headset_remove_state_cb(endpoint->hs_watch);
+ if (endpoint->ag_watch)
+ gateway_remove_state_cb(endpoint->ag_watch);
+
if (endpoint->request)
media_endpoint_cancel(endpoint);
@@ -553,6 +558,46 @@ static void a2dp_destroy_endpoint(void *user_data)
release_endpoint(endpoint);
}
+static void gateway_setconf_cb(struct media_endpoint *endpoint, void *ret,
+ int size, void *user_data)
+{
+ struct audio_device *dev = user_data;
+
+ if (ret != NULL)
+ return;
+
+ gateway_set_state(dev, GATEWAY_STATE_DISCONNECTED);
+}
+
+static void gateway_state_changed(struct audio_device *dev,
+ gateway_state_t old_state,
+ gateway_state_t new_state,
+ void *user_data)
+{
+ struct media_endpoint *endpoint = user_data;
+
+ DBG("");
+
+ switch (new_state) {
+ case GATEWAY_STATE_DISCONNECTED:
+ if (endpoint->transport &&
+ media_transport_get_dev(endpoint->transport) == dev) {
+
+ DBG("Clear endpoint %p", endpoint);
+ clear_configuration(endpoint);
+ }
+ break;
+ case GATEWAY_STATE_CONNECTING:
+ set_configuration(endpoint, dev, NULL, 0,
+ gateway_setconf_cb, dev, NULL);
+ break;
+ case GATEWAY_STATE_CONNECTED:
+ break;
+ case GATEWAY_STATE_PLAYING:
+ break;
+ }
+}
+
static struct media_endpoint *media_endpoint_create(struct media_adapter *adapter,
const char *sender,
const char *path,
@@ -604,6 +649,17 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adapte
if (dev)
set_configuration(endpoint, dev, NULL, 0,
headset_setconf_cb, dev, NULL);
+ } else if (strcasecmp(uuid, HFP_HS_UUID) == 0 ||
+ strcasecmp(uuid, HSP_HS_UUID) == 0) {
+ struct audio_device *dev;
+
+ endpoint->ag_watch = gateway_add_state_cb(gateway_state_changed,
+ endpoint);
+ dev = manager_find_device(NULL, &adapter->src, BDADDR_ANY,
+ AUDIO_GATEWAY_INTERFACE, TRUE);
+ if (dev)
+ set_configuration(endpoint, dev, NULL, 0,
+ gateway_setconf_cb, dev, NULL);
} else {
if (err)
*err = -EINVAL;
--
1.7.1
next prev parent reply other threads:[~2011-08-22 15:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-22 15:30 [PATCH v2 0/9] Add support for HandsfreeGateway to Media Frédéric Dalleau
2011-08-22 15:30 ` [PATCH v2 1/9] Fix double free in error case in endpoint_reply Frédéric Dalleau
2011-08-24 10:48 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 2/9] Add state change callback to HandsfreeGateway Frédéric Dalleau
2011-08-24 10:51 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` Frédéric Dalleau [this message]
2011-08-24 10:53 ` [PATCH v2 3/9] Use state change callback from media interface Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 4/9] Update g_strcmp0 to strcasecmp Frédéric Dalleau
2011-08-24 10:53 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 5/9] Fix RFCOMM disconnect on suspend request Frédéric Dalleau
2011-08-24 10:54 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 6/9] Set state to "connecting" when AG connects Frédéric Dalleau
2011-08-24 10:54 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 7/9] Fix invalid state at SCO disconnect in gateway Frédéric Dalleau
2011-08-24 10:57 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 8/9] Introduce gateway locking mechanism Frédéric Dalleau
2011-08-24 10:55 ` Luiz Augusto von Dentz
2011-08-22 15:30 ` [PATCH v2 9/9] Implement media_transport for HFP_HS_UUID Frédéric Dalleau
2011-08-24 10:59 ` Luiz Augusto von Dentz
2011-08-24 11:24 ` [PATCH v2 0/9] Add support for HandsfreeGateway to Media Johan Hedberg
2011-08-24 12:06 ` Dalleau, Frederic
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=1314027047-5476-4-git-send-email-frederic.dalleau@linux.intel.com \
--to=frederic.dalleau@linux.intel.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