From: Mikel Astiz <[email protected]>
v1 proposes TryAcquire() instead of Acquire(TRUE), as suggested by Johan.
>From original cover-letter:
The accessrights used in the Acquire() method are not very useful and can thus be removed. This simplifies both the D-Bus API and the internal implementation significantly.
Mikel Astiz (6):
media: Remove transport access type from D-Bus API
media: Remove internal transport locks
media: Remove transport owner list
media: Add MediaTransport.TryAcquire()
media: Trivial style fix
media: Add version suffix to all media interfaces
doc/audio-telephony-design.txt | 4 +-
doc/media-api.txt | 46 +++----
profiles/audio/media.c | 8 +-
profiles/audio/player.c | 2 +-
profiles/audio/transport.c | 264 ++++++++++++-----------------------------
test/mpris-player.c | 14 +--
6 files changed, 108 insertions(+), 230 deletions(-)
--
1.7.11.7
Hi Mikel,
On Wed, Dec 05, 2012, Mikel Astiz wrote:
> v1 proposes TryAcquire() instead of Acquire(TRUE), as suggested by
> Johan.
>
> From original cover-letter:
>
> The accessrights used in the Acquire() method are not very useful and
> can thus be removed. This simplifies both the D-Bus API and the
> internal implementation significantly.
>
> Mikel Astiz (6):
> media: Remove transport access type from D-Bus API
> media: Remove internal transport locks
> media: Remove transport owner list
> media: Add MediaTransport.TryAcquire()
> media: Trivial style fix
> media: Add version suffix to all media interfaces
>
> doc/audio-telephony-design.txt | 4 +-
> doc/media-api.txt | 46 +++----
> profiles/audio/media.c | 8 +-
> profiles/audio/player.c | 2 +-
> profiles/audio/transport.c | 264 ++++++++++++-----------------------------
> test/mpris-player.c | 14 +--
> 6 files changed, 108 insertions(+), 230 deletions(-)
All patches in this set have been applied. Thanks.
Johan
From: Mikel Astiz <[email protected]>
There is no known use-case making use of these access types and
therefore the Media API can be simplified.
>From now on, the transport will always be acquired with read and write
access rights.
---
doc/media-api.txt | 23 ++---------------------
profiles/audio/transport.c | 47 ++++++----------------------------------------
2 files changed, 8 insertions(+), 62 deletions(-)
diff --git a/doc/media-api.txt b/doc/media-api.txt
index cf69efa..b15ad61 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -261,31 +261,12 @@ Service org.bluez
Interface org.bluez.MediaTransport
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/fdX
-Methods fd, uint16, uint16 Acquire(string accesstype)
+Methods fd, uint16, uint16 Acquire()
Acquire transport file descriptor and the MTU for read
and write respectively.
- possible accesstype:
-
- "r" : Read only access
-
- "w" : Write only access
-
- "rw": Read and write access
-
- The accesstype string can also be combined with a "?"
- suffix, which will make the request optional. This
- typically means the transport will only be acquired if
- it is already available (remote-initiated), but
- otherwise no request will be sent to the remote side.
- In this last case the function will fail. Note that,
- due to compatibility issues with older versions of
- BlueZ, clients are encouraged to use exactly the same
- accesstype for Release(), matching the string provided
- to Acquire().
-
- void Release(string accesstype)
+ void Release()
Releases file descriptor.
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 610aca3..a76481c 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -127,19 +127,6 @@ static const char *lock2str(transport_lock_t lock)
return "rw";
}
-static transport_lock_t str2lock(const char *str)
-{
- transport_lock_t lock = 0;
-
- if (g_strstr_len(str, -1, "r") != NULL)
- lock |= TRANSPORT_LOCK_READ;
-
- if (g_strstr_len(str, -1, "w") != NULL)
- lock |= TRANSPORT_LOCK_WRITE;
-
- return lock;
-}
-
static const char *state2str(transport_state_t state)
{
switch (state) {
@@ -532,14 +519,9 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
struct media_transport *transport = data;
struct media_owner *owner;
struct media_request *req;
- const char *accesstype, *sender;
- transport_lock_t lock;
+ const char *sender;
guint id;
-
- if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_STRING, &accesstype,
- DBUS_TYPE_INVALID))
- return btd_error_invalid_args(msg);
+ transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
sender = dbus_message_get_sender(msg);
@@ -547,14 +529,6 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
if (owner != NULL)
return btd_error_not_authorized(msg);
- lock = str2lock(accesstype);
- if (lock == 0)
- return btd_error_invalid_args(msg);
-
- if (transport->state != TRANSPORT_STATE_PENDING &&
- g_strstr_len(accesstype, -1, "?") != NULL)
- return btd_error_failed(msg, "Transport not playing");
-
if (media_transport_acquire(transport, lock) == FALSE)
return btd_error_not_authorized(msg);
@@ -578,14 +552,9 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
{
struct media_transport *transport = data;
struct media_owner *owner;
- const char *accesstype, *sender;
- transport_lock_t lock;
+ const char *sender;
struct media_request *req;
-
- if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_STRING, &accesstype,
- DBUS_TYPE_INVALID))
- return btd_error_invalid_args(msg);
+ transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
sender = dbus_message_get_sender(msg);
@@ -593,8 +562,6 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
if (owner == NULL)
return btd_error_not_authorized(msg);
- lock = str2lock(accesstype);
-
if (owner->lock == lock) {
guint id;
@@ -764,13 +731,11 @@ static void set_volume(const GDBusPropertyTable *property,
static const GDBusMethodTable transport_methods[] = {
{ GDBUS_ASYNC_METHOD("Acquire",
- GDBUS_ARGS({ "access_type", "s" }),
+ NULL,
GDBUS_ARGS({ "fd", "h" }, { "mtu_r", "q" },
{ "mtu_w", "q" } ),
acquire) },
- { GDBUS_ASYNC_METHOD("Release",
- GDBUS_ARGS({ "access_type", "s" }), NULL,
- release ) },
+ { GDBUS_ASYNC_METHOD("Release", NULL, NULL, release) },
{ },
};
--
1.7.11.7
From: Mikel Astiz <[email protected]>
The internal transport_lock_t is not needed any more since transports
are now always acquired with read and write permissions.
---
profiles/audio/transport.c | 130 ++++++++++-----------------------------------
1 file changed, 28 insertions(+), 102 deletions(-)
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index a76481c..4bb54f6 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -51,11 +51,6 @@
#define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport"
typedef enum {
- TRANSPORT_LOCK_READ = 1,
- TRANSPORT_LOCK_WRITE = 1 << 1,
-} transport_lock_t;
-
-typedef enum {
TRANSPORT_STATE_IDLE, /* Not acquired and suspended */
TRANSPORT_STATE_PENDING, /* Playing but not acquired */
TRANSPORT_STATE_REQUESTING, /* Acquire in progress */
@@ -80,7 +75,6 @@ struct media_owner {
struct media_transport *transport;
struct media_request *pending;
char *name;
- transport_lock_t lock;
guint watch;
};
@@ -100,7 +94,6 @@ struct media_transport {
int fd; /* Transport file descriptor */
uint16_t imtu; /* Transport input mtu */
uint16_t omtu; /* Transport output mtu */
- transport_lock_t lock;
transport_state_t state;
guint hs_watch;
guint source_watch;
@@ -115,18 +108,6 @@ struct media_transport {
void *data;
};
-static const char *lock2str(transport_lock_t lock)
-{
- if (lock == 0)
- return "";
- else if (lock == TRANSPORT_LOCK_READ)
- return "r";
- else if (lock == TRANSPORT_LOCK_WRITE)
- return "w";
- else
- return "rw";
-}
-
static const char *state2str(transport_state_t state)
{
switch (state) {
@@ -229,20 +210,6 @@ static void media_request_reply(struct media_request *req, int err)
g_dbus_send_message(btd_get_dbus_connection(), reply);
}
-static gboolean media_transport_release(struct media_transport *transport,
- transport_lock_t lock)
-{
- transport->lock &= ~lock;
-
- if (lock & TRANSPORT_LOCK_READ)
- DBG("Transport %s: read lock released", transport->path);
-
- if (lock & TRANSPORT_LOCK_WRITE)
- DBG("Transport %s: write lock released", transport->path);
-
- return TRUE;
-}
-
static void media_owner_remove(struct media_owner *owner)
{
struct media_transport *transport = owner->transport;
@@ -279,8 +246,6 @@ static void media_transport_remove(struct media_transport *transport,
{
DBG("Transport %s Owner %s", transport->path, owner->name);
- media_transport_release(transport, owner->lock);
-
/* Reply if owner has a pending request */
if (owner->pending)
media_request_reply(owner->pending, EIO);
@@ -339,12 +304,6 @@ static void a2dp_resume_complete(struct avdtp *session,
media_transport_set_fd(transport, fd, imtu, omtu);
- if ((owner->lock & TRANSPORT_LOCK_READ) == 0)
- imtu = 0;
-
- if ((owner->lock & TRANSPORT_LOCK_WRITE) == 0)
- omtu = 0;
-
ret = g_dbus_send_reply(btd_get_dbus_connection(), req->msg,
DBUS_TYPE_UNIX_FD, &fd,
DBUS_TYPE_UINT16, &imtu,
@@ -443,24 +402,6 @@ static void media_owner_exit(DBusConnection *connection, void *user_data)
media_transport_remove(owner->transport, owner);
}
-static gboolean media_transport_acquire(struct media_transport *transport,
- transport_lock_t lock)
-{
- if (transport->lock & lock)
- return FALSE;
-
- transport->lock |= lock;
-
- if (lock & TRANSPORT_LOCK_READ)
- DBG("Transport %s: read lock acquired", transport->path);
-
- if (lock & TRANSPORT_LOCK_WRITE)
- DBG("Transport %s: write lock acquired", transport->path);
-
-
- return TRUE;
-}
-
static void media_transport_add(struct media_transport *transport,
struct media_owner *owner)
{
@@ -473,17 +414,14 @@ static void media_transport_add(struct media_transport *transport,
owner, NULL);
}
-static struct media_owner *media_owner_create(DBusMessage *msg,
- transport_lock_t lock)
+static struct media_owner *media_owner_create(DBusMessage *msg)
{
struct media_owner *owner;
owner = g_new0(struct media_owner, 1);
owner->name = g_strdup(dbus_message_get_sender(msg));
- owner->lock = lock;
- DBG("Owner created: sender=%s accesstype=%s", owner->name,
- lock2str(lock));
+ DBG("Owner created: sender=%s", owner->name);
return owner;
}
@@ -521,7 +459,6 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
struct media_request *req;
const char *sender;
guint id;
- transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
sender = dbus_message_get_sender(msg);
@@ -529,13 +466,12 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
if (owner != NULL)
return btd_error_not_authorized(msg);
- if (media_transport_acquire(transport, lock) == FALSE)
+ if (transport->state >= TRANSPORT_STATE_REQUESTING)
return btd_error_not_authorized(msg);
- owner = media_owner_create(msg, lock);
+ owner = media_owner_create(msg);
id = transport->resume(transport, owner);
if (id == 0) {
- media_transport_release(transport, lock);
media_owner_free(owner);
return btd_error_not_authorized(msg);
}
@@ -554,7 +490,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
struct media_owner *owner;
const char *sender;
struct media_request *req;
- transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
+ guint id;
sender = dbus_message_get_sender(msg);
@@ -562,45 +498,35 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
if (owner == NULL)
return btd_error_not_authorized(msg);
- if (owner->lock == lock) {
- guint id;
-
- /* Not the last owner, no need to suspend */
- if (g_slist_length(transport->owners) != 1) {
- media_transport_remove(transport, owner);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
- }
-
- if (owner->pending) {
- const char *member;
+ /* Not the last owner, no need to suspend */
+ if (g_slist_length(transport->owners) != 1) {
+ media_transport_remove(transport, owner);
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
- member = dbus_message_get_member(owner->pending->msg);
- /* Cancel Acquire request if that exist */
- if (g_str_equal(member, "Acquire"))
- media_owner_remove(owner);
- else
- return btd_error_in_progress(msg);
- }
+ if (owner->pending) {
+ const char *member;
- transport_set_state(transport, TRANSPORT_STATE_SUSPENDING);
+ member = dbus_message_get_member(owner->pending->msg);
+ /* Cancel Acquire request if that exist */
+ if (g_str_equal(member, "Acquire"))
+ media_owner_remove(owner);
+ else
+ return btd_error_in_progress(msg);
+ }
- id = transport->suspend(transport, owner);
- if (id == 0) {
- media_transport_remove(transport, owner);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
- }
+ transport_set_state(transport, TRANSPORT_STATE_SUSPENDING);
- req = media_request_create(msg, id);
- media_owner_add(owner, req);
+ id = transport->suspend(transport, owner);
+ if (id == 0) {
+ media_transport_remove(transport, owner);
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ }
- return NULL;
- } else if ((owner->lock & lock) == lock) {
- media_transport_release(transport, lock);
- owner->lock &= ~lock;
- } else
- return btd_error_not_authorized(msg);
+ req = media_request_create(msg, id);
+ media_owner_add(owner, req);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ return NULL;
}
static gboolean get_device(const GDBusPropertyTable *property,
--
1.7.11.7
From: Mikel Astiz <[email protected]>
Transports now have zero or one owners, so there is no need to maintain
a list any more.
---
profiles/audio/transport.c | 79 ++++++++++++----------------------------------
1 file changed, 21 insertions(+), 58 deletions(-)
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 4bb54f6..1064098 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -88,7 +88,7 @@ struct media_transport {
char *path; /* Transport object path */
struct audio_device *device; /* Transport device */
struct media_endpoint *endpoint; /* Transport endpoint */
- GSList *owners; /* Transport owners */
+ struct media_owner *owner; /* Transport owner */
uint8_t *configuration; /* Transport configuration */
int size; /* Transport configuration size */
int fd; /* Transport file descriptor */
@@ -241,24 +241,24 @@ static void media_owner_free(struct media_owner *owner)
g_free(owner);
}
-static void media_transport_remove(struct media_transport *transport,
- struct media_owner *owner)
+static void media_transport_remove_owner(struct media_transport *transport)
{
+ struct media_owner *owner = transport->owner;
+
DBG("Transport %s Owner %s", transport->path, owner->name);
/* Reply if owner has a pending request */
if (owner->pending)
media_request_reply(owner->pending, EIO);
- transport->owners = g_slist_remove(transport->owners, owner);
+ transport->owner = NULL;
if (owner->watch)
g_dbus_remove_watch(btd_get_dbus_connection(), owner->watch);
media_owner_free(owner);
- /* Suspend if there is no longer any owner */
- if (transport->owners == NULL && state_in_use(transport->state))
+ if (state_in_use(transport->state))
transport->suspend(transport, NULL);
}
@@ -319,7 +319,7 @@ static void a2dp_resume_complete(struct avdtp *session,
return;
fail:
- media_transport_remove(transport, owner);
+ media_transport_remove_owner(transport);
}
static guint resume_a2dp(struct media_transport *transport,
@@ -366,7 +366,7 @@ static void a2dp_suspend_complete(struct avdtp *session,
a2dp_sep_unlock(sep, a2dp->session);
transport_set_state(transport, TRANSPORT_STATE_IDLE);
- media_transport_remove(transport, owner);
+ media_transport_remove_owner(transport);
}
static guint suspend_a2dp(struct media_transport *transport,
@@ -399,14 +399,14 @@ static void media_owner_exit(DBusConnection *connection, void *user_data)
media_owner_remove(owner);
- media_transport_remove(owner->transport, owner);
+ media_transport_remove_owner(owner->transport);
}
-static void media_transport_add(struct media_transport *transport,
+static void media_transport_set_owner(struct media_transport *transport,
struct media_owner *owner)
{
DBG("Transport %s Owner %s", transport->path, owner->name);
- transport->owners = g_slist_append(transport->owners, owner);
+ transport->owner = owner;
owner->transport = transport;
owner->watch = g_dbus_add_disconnect_watch(btd_get_dbus_connection(),
owner->name,
@@ -435,35 +435,15 @@ static void media_owner_add(struct media_owner *owner,
owner->pending = req;
}
-static struct media_owner *media_transport_find_owner(
- struct media_transport *transport,
- const char *name)
-{
- GSList *l;
-
- for (l = transport->owners; l; l = l->next) {
- struct media_owner *owner = l->data;
-
- if (g_strcmp0(owner->name, name) == 0)
- return owner;
- }
-
- return NULL;
-}
-
static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct media_transport *transport = data;
struct media_owner *owner;
struct media_request *req;
- const char *sender;
guint id;
- sender = dbus_message_get_sender(msg);
-
- owner = media_transport_find_owner(transport, sender);
- if (owner != NULL)
+ if (transport->owner != NULL)
return btd_error_not_authorized(msg);
if (transport->state >= TRANSPORT_STATE_REQUESTING)
@@ -478,7 +458,7 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
req = media_request_create(msg, id);
media_owner_add(owner, req);
- media_transport_add(transport, owner);
+ media_transport_set_owner(transport, owner);
return NULL;
}
@@ -487,23 +467,16 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct media_transport *transport = data;
- struct media_owner *owner;
+ struct media_owner *owner = transport->owner;
const char *sender;
struct media_request *req;
guint id;
sender = dbus_message_get_sender(msg);
- owner = media_transport_find_owner(transport, sender);
- if (owner == NULL)
+ if (owner == NULL || g_strcmp0(owner->name, sender) != 0)
return btd_error_not_authorized(msg);
- /* Not the last owner, no need to suspend */
- if (g_slist_length(transport->owners) != 1) {
- media_transport_remove(transport, owner);
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
- }
-
if (owner->pending) {
const char *member;
@@ -519,7 +492,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
id = transport->suspend(transport, owner);
if (id == 0) {
- media_transport_remove(transport, owner);
+ media_transport_remove_owner(transport);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
@@ -689,15 +662,9 @@ static void destroy_a2dp(void *data)
static void media_transport_free(void *data)
{
struct media_transport *transport = data;
- GSList *l = transport->owners;
- while (l) {
- struct media_owner *owner = l->data;
- l = l->next;
- media_transport_remove(transport, owner);
- }
-
- g_slist_free(transport->owners);
+ if (transport->owner)
+ media_transport_remove_owner(transport);
if (transport->destroy != NULL)
transport->destroy(transport->data);
@@ -717,13 +684,9 @@ static void transport_update_playing(struct media_transport *transport,
if (transport->state == TRANSPORT_STATE_PENDING)
transport_set_state(transport, TRANSPORT_STATE_IDLE);
else if (transport->state == TRANSPORT_STATE_ACTIVE) {
- /* Remove all owners */
- while (transport->owners != NULL) {
- struct media_owner *owner;
-
- owner = transport->owners->data;
- media_transport_remove(transport, owner);
- }
+ /* Remove owner */
+ if (transport->owner != NULL)
+ media_transport_remove_owner(transport);
}
} else if (transport->state == TRANSPORT_STATE_IDLE)
transport_set_state(transport, TRANSPORT_STATE_PENDING);
--
1.7.11.7
From: Mikel Astiz <[email protected]>
Append the version number to all D-Bus interface names in the Media API.
---
doc/audio-telephony-design.txt | 4 ++--
doc/media-api.txt | 20 ++++++++++----------
profiles/audio/media.c | 8 ++++----
profiles/audio/player.c | 2 +-
profiles/audio/transport.c | 2 +-
test/mpris-player.c | 14 +++++++-------
6 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/doc/audio-telephony-design.txt b/doc/audio-telephony-design.txt
index ec575f2..308986b 100644
--- a/doc/audio-telephony-design.txt
+++ b/doc/audio-telephony-design.txt
@@ -35,9 +35,9 @@ When a new device is connected, NewConnection method of Profile1 agent
is called with informations related to connecting profile (like RFCOMM
client file descriptor, version, features, media end point path, ...).
-The telephony application is in charge to implement a MediaTransport for
+The telephony application is in charge to implement a MediaTransport1 for
its audio connection with remote device and interact with the
-MediaTransport of the audio component (i.e. PulseAudio).
+MediaTransport1 of the audio component (i.e. PulseAudio).
Flow charts
===========
diff --git a/doc/media-api.txt b/doc/media-api.txt
index 5e052b4..ce7502a 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -5,7 +5,7 @@ Media hierarchy
===============
Service org.bluez
-Interface org.bluez.Media
+Interface org.bluez.Media1
Object path [variable prefix]/{hci0,hci1,...}
Methods void RegisterEndpoint(object endpoint, dict properties)
@@ -123,12 +123,12 @@ Methods void RegisterEndpoint(object endpoint, dict properties)
Unregister sender media player.
-MediaPlayer hierarchy
-=====================
+MediaPlayer1 hierarchy
+======================
Service unique name (Target role)
org.bluez (Controller role)
-Interface org.bluez.MediaPlayer
+Interface org.bluez.Media1Player1
Object path freely definable (Target role)
[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX
(Controller role)
@@ -219,11 +219,11 @@ Properties string Equalizer [readwrite]
possible to signal its end by setting position to the
maximum uint32 value.
-MediaEndpoint hierarchy
-=======================
+MediaEndpoint1 hierarchy
+========================
Service unique name
-Interface org.bluez.MediaEndpoint
+Interface org.bluez.Media1Endpoint1
Object path freely definable
Methods void SetConfiguration(object transport, dict properties)
@@ -254,11 +254,11 @@ Methods void SetConfiguration(object transport, dict properties)
endpoint, because when this method gets called it has
already been unregistered.
-MediaTransport hierarchy
-========================
+MediaTransport1 hierarchy
+=========================
Service org.bluez
-Interface org.bluez.MediaTransport
+Interface org.bluez.MediaTransport1
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/fdX
Methods fd, uint16, uint16 Acquire()
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 2041d23..7c0bc0a 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -50,9 +50,9 @@
#include "avrcp.h"
#include "manager.h"
-#define MEDIA_INTERFACE "org.bluez.Media"
-#define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint"
-#define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer"
+#define MEDIA_INTERFACE "org.bluez.Media1"
+#define MEDIA_ENDPOINT_INTERFACE "org.bluez.Media1Endpoint1"
+#define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer1"
#define REQUEST_TIMEOUT (3 * 1000) /* 3 seconds */
@@ -402,7 +402,7 @@ static gboolean set_configuration(struct media_endpoint *endpoint,
path = media_transport_get_path(transport);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
- g_dbus_get_properties(conn, path, "org.bluez.MediaTransport", &iter);
+ g_dbus_get_properties(conn, path, "org.bluez.MediaTransport1", &iter);
return media_endpoint_async_call(msg, endpoint, cb, user_data, destroy);
}
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 34b1f20..368bfa8 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -42,7 +42,7 @@
#include "dbus-common.h"
#include "error.h"
-#define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer"
+#define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer1"
struct player_callback {
const struct media_player_callback *cbs;
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 666f68a..165ebd3 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -48,7 +48,7 @@
#include "source.h"
#include "avrcp.h"
-#define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport"
+#define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1"
typedef enum {
TRANSPORT_STATE_IDLE, /* Not acquired and suspended */
diff --git a/test/mpris-player.c b/test/mpris-player.c
index 7985cdd..90c87aa 100644
--- a/test/mpris-player.c
+++ b/test/mpris-player.c
@@ -186,7 +186,7 @@ static int parse_property(DBusConnection *conn, const char *path,
DBUS_TYPE_STRING, &value);
else
emit_properties_changed(sys, path,
- "org.bluez.MediaPlayer", "Status",
+ "org.bluez.MediaPlayer1", "Status",
DBUS_TYPE_STRING, &value);
} else if (strcasecmp(key, "Position") == 0) {
int64_t usec, msec;
@@ -203,7 +203,7 @@ static int parse_property(DBusConnection *conn, const char *path,
DBUS_TYPE_UINT32, &msec);
else
emit_properties_changed(sys, path,
- "org.bluez.MediaPlayer", "Position",
+ "org.bluez.MediaPlayer1", "Position",
DBUS_TYPE_UINT32, &msec);
} else if (strcasecmp(key, "Shuffle") == 0) {
dbus_bool_t value;
@@ -221,7 +221,7 @@ static int parse_property(DBusConnection *conn, const char *path,
DBUS_TYPE_STRING, &str);
else
emit_properties_changed(sys, path,
- "org.bluez.MediaPlayer", "Shuffle",
+ "org.bluez.MediaPlayer1", "Shuffle",
DBUS_TYPE_STRING, &str);
}
@@ -446,7 +446,7 @@ static char *sender2path(const char *sender)
static DBusHandlerResult player_message(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- if (dbus_message_is_method_call(msg, "org.bluez.MediaPlayer",
+ if (dbus_message_is_method_call(msg, "org.bluez.MediaPlayer1",
"Release")) {
printf("Release\n");
exit(1);
@@ -472,7 +472,7 @@ static void add_player(DBusConnection *conn, const char *name,
return;
msg = dbus_message_new_method_call("org.bluez", adapter,
- "org.bluez.Media",
+ "org.bluez.Media1",
"RegisterPlayer");
if (!msg) {
fprintf(stderr, "Can't allocate new method call\n");
@@ -539,7 +539,7 @@ static void remove_player(DBusConnection *conn, const char *sender)
char *path;
msg = dbus_message_new_method_call("org.bluez", adapter,
- "org.bluez.Media",
+ "org.bluez.Media1",
"UnregisterPlayer");
if (!msg) {
fprintf(stderr, "Can't allocate new method call\n");
@@ -578,7 +578,7 @@ static DBusHandlerResult properties_changed(DBusConnection *conn,
path = sender2path(dbus_message_get_sender(msg));
parse_properties(conn, path, &iter, NULL);
- signal = dbus_message_new_signal(path, "org.bluez.MediaPlayer",
+ signal = dbus_message_new_signal(path, "org.bluez.MediaPlayer1",
"TrackChanged");
if (!signal) {
fprintf(stderr, "Unable to allocate new PropertyChanged"
--
1.7.11.7
From: Mikel Astiz <[email protected]>
No whitespace should exist before parenthesis close.
---
profiles/audio/transport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 0fd2469..666f68a 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -663,7 +663,7 @@ static const GDBusMethodTable transport_methods[] = {
{ GDBUS_ASYNC_METHOD("Acquire",
NULL,
GDBUS_ARGS({ "fd", "h" }, { "mtu_r", "q" },
- { "mtu_w", "q" } ),
+ { "mtu_w", "q" }),
acquire) },
{ GDBUS_ASYNC_METHOD("TryAcquire",
NULL,
--
1.7.11.7
From: Mikel Astiz <[email protected]>
Split the Acquire() method in two parts so that the optional acquires,
formerly represented as a "?" flag in the accesstype parameter of
Acquire(), are now implemented in TryAcquire().
---
doc/media-api.txt | 7 +++++++
profiles/audio/transport.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/doc/media-api.txt b/doc/media-api.txt
index b15ad61..5e052b4 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -266,6 +266,13 @@ Methods fd, uint16, uint16 Acquire()
Acquire transport file descriptor and the MTU for read
and write respectively.
+ fd, uint16, uint16 TryAcquire()
+
+ Acquire transport file descriptor only if the transport
+ is in "pending" state at the time the message is
+ received by BlueZ. Otherwise no request will be sent
+ to the remote device and the function will just fail.
+
void Release()
Releases file descriptor.
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 1064098..0fd2469 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -463,6 +463,37 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
return NULL;
}
+static DBusMessage *try_acquire(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ struct media_transport *transport = data;
+ struct media_owner *owner;
+ struct media_request *req;
+ guint id;
+
+ if (transport->owner != NULL)
+ return btd_error_not_authorized(msg);
+
+ if (transport->state >= TRANSPORT_STATE_REQUESTING)
+ return btd_error_not_authorized(msg);
+
+ if (transport->state != TRANSPORT_STATE_PENDING)
+ return btd_error_failed(msg, "Transport not playing");
+
+ owner = media_owner_create(msg);
+ id = transport->resume(transport, owner);
+ if (id == 0) {
+ media_owner_free(owner);
+ return btd_error_not_authorized(msg);
+ }
+
+ req = media_request_create(msg, id);
+ media_owner_add(owner, req);
+ media_transport_set_owner(transport, owner);
+
+ return NULL;
+}
+
static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -634,6 +665,11 @@ static const GDBusMethodTable transport_methods[] = {
GDBUS_ARGS({ "fd", "h" }, { "mtu_r", "q" },
{ "mtu_w", "q" } ),
acquire) },
+ { GDBUS_ASYNC_METHOD("TryAcquire",
+ NULL,
+ GDBUS_ARGS({ "fd", "h" }, { "mtu_r", "q" },
+ { "mtu_w", "q" }),
+ try_acquire) },
{ GDBUS_ASYNC_METHOD("Release", NULL, NULL, release) },
{ },
};
--
1.7.11.7