From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Bharat Bhusan Panda <bharat.panda@samsung.com>
Cc: "linux-bluetooth@vger.kernel.org"
<linux-bluetooth@vger.kernel.org>,
cpgs@samsung.com
Subject: Re: [PATCH 2/3] audio/avrcp: Handle PlaylistChanged signal
Date: Wed, 2 Dec 2015 15:31:51 +0200 [thread overview]
Message-ID: <CABBYNZLHJo+eQ1SCughLL1QUmsJRDSmanKb_08bSg4fbYE7m9A@mail.gmail.com> (raw)
In-Reply-To: <001c01d12905$cd41ec80$67c5c580$@samsung.com>
Hi Bharat,
On Fri, Nov 27, 2015 at 1:21 PM, Bharat Bhusan Panda
<bharat.panda@samsung.com> wrote:
> ping
>
>> -----Original Message-----
>> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
>> owner@vger.kernel.org] On Behalf Of Bharat Panda
>> Sent: Tuesday, October 20, 2015 6:46 PM
>> To: linux-bluetooth@vger.kernel.org
>> Cc: cpgs@samsung.com; Bharat Panda
>> Subject: [PATCH 2/3] audio/avrcp: Handle PlaylistChanged signal
>>
>> Added signal handler for "PlaylistChanged" on MediaPlayer2.Playlists
>> interface.
>> ---
>> profiles/audio/media.c | 79
>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 79 insertions(+)
>>
>> diff --git a/profiles/audio/media.c b/profiles/audio/media.c index
>> 1b5246d..94fce79 100644
>> --- a/profiles/audio/media.c
>> +++ b/profiles/audio/media.c
>> @@ -113,6 +113,7 @@ struct media_player {
>> guint watch;
>> guint properties_watch;
>> guint seek_watch;
>> + guint playlist_watch;
>> char *status;
>> uint32_t position;
>> uint32_t duration;
>> @@ -973,6 +974,7 @@ static void media_player_free(gpointer data)
>> g_dbus_remove_watch(conn, mp->watch);
>> g_dbus_remove_watch(conn, mp->properties_watch);
>> g_dbus_remove_watch(conn, mp->seek_watch);
>> + g_dbus_remove_watch(conn, mp->playlist_watch);
>>
>> if (mp->track)
>> g_hash_table_unref(mp->track);
>> @@ -1913,6 +1915,76 @@ static gboolean
>> position_changed(DBusConnection *connection, DBusMessage *msg,
>> return TRUE;
>> }
>>
>> +static struct media_playlist *find_playlist_by_id(struct media_player
> *mp,
>> + char *playlist_id)
>> +{
>> + GSList *l;
>> +
>> + for (l = mp->playlists; l; l = l->next) {
>> + struct media_playlist *playlist = l->data;
>> +
>> + if (g_strcmp0(playlist->id, playlist_id) == 0) {
>> + return playlist;
>> + }
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> +static gboolean playlist_changed(DBusConnection *connection,
>> + DBusMessage *msg,
>> + void *user_data)
>> +{
>> + struct media_player *mp = user_data;
>> + struct media_playlist *playlist;
>> + DBusMessageIter iter;
>> + DBusMessageIter entry;
>> + char *playlist_id;
>> + char *name;
>> + char *icon;
>> +
>> + dbus_message_iter_init(msg, &iter);
>> + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRUCT)
>> + return FALSE;
>> +
>> + dbus_message_iter_recurse(&iter, &entry);
>> +
>> + if (dbus_message_iter_get_arg_type(&entry) !=
>> + DBUS_TYPE_OBJECT_PATH)
>> + return FALSE;
>> +
>> + dbus_message_iter_get_basic(&entry, &playlist_id);
>> +
>> + dbus_message_iter_next(&entry);
>> + if (dbus_message_iter_get_arg_type(&entry) !=
>> + DBUS_TYPE_STRING)
>> + return FALSE;
>> +
>> + dbus_message_iter_get_basic(&entry, &name);
>> +
>> + dbus_message_iter_next(&entry);
>> + if (dbus_message_iter_get_arg_type(&entry) !=
>> + DBUS_TYPE_STRING)
>> + return FALSE;
>> +
>> + dbus_message_iter_get_basic(&entry, &icon);
>> +
>> + playlist = find_playlist_by_id(mp, playlist_id);
>> +
>> + if (playlist) {
>> + playlist->name = g_strdup(name);
>> + playlist->icon = g_strdup(icon);
>> + } else {
>> + playlist = g_new0(struct media_playlist, 1);
>> +
>> + playlist->id = playlist_id;
>> + playlist->name = g_strdup(name);
>> + playlist->icon = g_strdup(icon);
>> + }
Change this to if (!playlist) { new0.. the you can have name and icon
set after that since playlist would be set one way or the other.
>> + return TRUE;
>> +}
>> +
>> static struct media_player *media_player_create(struct media_adapter
>> *adapter,
>> const char *sender,
>> const char *path,
>> @@ -1995,6 +2067,13 @@ static DBusMessage
>> *register_player(DBusConnection *conn, DBusMessage *msg,
>> if (!get_playlists(mp))
>> DBG("Error fetching playlists");
>>
>> + mp->playlist_watch = g_dbus_add_signal_watch(conn,
>> + sender, path,
>> +
>> MEDIA_PLAYER_PLAYLIST_INTERFACE,
>> + "PlaylistChanged",
>> + playlist_changed,
>> + mp, NULL);
>> +
>> return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); }
>>
>> --
>> 1.9.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in
>> the body of a message to majordomo@vger.kernel.org More majordomo
>> info at http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Luiz Augusto von Dentz
next prev parent reply other threads:[~2015-12-02 13:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 13:16 [PATCH 1/3] audio/avrcp: Get player playlist details Bharat Panda
2015-10-20 13:16 ` [PATCH 2/3] audio/avrcp: Handle PlaylistChanged signal Bharat Panda
2015-11-27 11:21 ` Bharat Bhusan Panda
2015-12-02 13:31 ` Luiz Augusto von Dentz [this message]
2015-10-20 13:16 ` [PATCH 3/3] audio/avrcp: Add support for SetBrowsedPlayer Bharat Panda
2015-11-27 11:21 ` Bharat Bhusan Panda
2015-12-02 13:41 ` Luiz Augusto von Dentz
2015-10-21 13:04 ` [PATCH 1/3] audio/avrcp: Get player playlist details Luiz Augusto von Dentz
-- strict thread matches above, loose matches on Subject: below --
2015-10-06 11:53 [PATCH 1/3] aurdio/avrcp: " Bharat Panda
2015-10-06 11:53 ` [PATCH 2/3] audio/avrcp: Handle PlaylistChanged signal Bharat Panda
2015-10-19 10:42 ` 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=CABBYNZLHJo+eQ1SCughLL1QUmsJRDSmanKb_08bSg4fbYE7m9A@mail.gmail.com \
--to=luiz.dentz@gmail.com \
--cc=bharat.panda@samsung.com \
--cc=cpgs@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.