Return-Path: From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/8] media: Implement new callbacks for pass-through operations Date: Fri, 10 May 2013 14:02:04 +0300 Message-Id: <1368183727-24461-5-git-send-email-luiz.dentz@gmail.com> In-Reply-To: <1368183727-24461-1-git-send-email-luiz.dentz@gmail.com> References: <1368183727-24461-1-git-send-email-luiz.dentz@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: From: Luiz Augusto von Dentz This implements newly introduced callbacks for pass-through operation so they are directly sent to the active player. --- profiles/audio/media.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index cab79b5..327b58e 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1129,6 +1129,67 @@ static void set_volume(uint8_t volume, struct audio_device *dev, void *user_data } } +static bool media_player_send(struct media_player *mp, const char *name) +{ + DBusMessage *msg; + + msg = dbus_message_new_method_call(mp->sender, mp->path, + MEDIA_PLAYER_INTERFACE, name); + if (msg == NULL) { + error("Couldn't allocate D-Bus message"); + return false; + } + + g_dbus_send_message(btd_get_dbus_connection(), msg); + + return true; +} + +static bool play(void *user_data) +{ + struct media_player *mp = user_data; + + DBG(""); + + return media_player_send(mp, "Play"); +} + +static bool stop(void *user_data) +{ + struct media_player *mp = user_data; + + DBG(""); + + return media_player_send(mp, "Stop"); +} + +static bool pause(void *user_data) +{ + struct media_player *mp = user_data; + + DBG(""); + + return media_player_send(mp, "Pause"); +} + +static bool next(void *user_data) +{ + struct media_player *mp = user_data; + + DBG(""); + + return media_player_send(mp, "Next"); +} + +static bool previous(void *user_data) +{ + struct media_player *mp = user_data; + + DBG(""); + + return media_player_send(mp, "Previous"); +} + static struct avrcp_player_cb player_cb = { .list_settings = list_settings, .get_setting = get_setting, @@ -1139,7 +1200,12 @@ static struct avrcp_player_cb player_cb = { .get_position = get_position, .get_duration = get_duration, .get_status = get_status, - .set_volume = set_volume + .set_volume = set_volume, + .play = play, + .stop = stop, + .pause = pause, + .next = next, + .previous = previous, }; static void media_player_exit(DBusConnection *connection, void *user_data) -- 1.8.1.4