From 2ecba3086813465026188c0514786dcf1330ba53 Mon Sep 17 00:00:00 2001 From: Gina Yeh Date: Mon, 9 Sep 2013 23:12:58 +0200 Subject: [PATCH] Bug 914076 - Send play status change event after pausing music, r=echou --- dom/bluetooth/linux/BluetoothDBusService.cpp | 43 ++++++++------------ 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index 2c39d508e42b..2d246de7ac5c 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -3079,6 +3079,16 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle, const char* totalMediaCount = tempTotalMediaCount.get(); const char* duration = tempDuration.get(); + nsAutoString prevTitle, prevAlbum; + a2dp->GetTitle(prevTitle); + a2dp->GetAlbum(prevAlbum); + + if (aMediaNumber != a2dp->GetMediaNumber() || + !aTitle.Equals(prevTitle) || + !aAlbum.Equals(prevAlbum)) { + UpdateNotification(ControlEventId::EVENT_TRACK_CHANGED, aMediaNumber); + } + nsRefPtr runnable(aRunnable); bool ret = dbus_func_args_async(mConnection, @@ -3099,16 +3109,6 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle, runnable.forget(); - nsAutoString prevTitle, prevAlbum; - a2dp->GetTitle(prevTitle); - a2dp->GetAlbum(prevAlbum); - - if (aMediaNumber != a2dp->GetMediaNumber() || - !aTitle.Equals(prevTitle) || - !aAlbum.Equals(prevAlbum)) { - UpdateNotification(ControlEventId::EVENT_TRACK_CHANGED, aMediaNumber); - } - a2dp->UpdateMetaData(aTitle, aArtist, aAlbum, aMediaNumber, aTotalMediaCount, aDuration); } @@ -3177,6 +3177,14 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration, return; } + uint32_t tempPlayStatus = playStatus; + if (playStatus != a2dp->GetPlayStatus()) { + UpdateNotification(ControlEventId::EVENT_PLAYBACK_STATUS_CHANGED, + tempPlayStatus); + } else if (aPosition != a2dp->GetPosition()) { + UpdateNotification(ControlEventId::EVENT_PLAYBACK_POS_CHANGED, aPosition); + } + nsAutoString address; a2dp->GetAddress(address); nsString objectPath = @@ -3184,7 +3192,6 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration, nsRefPtr runnable(aRunnable); - uint32_t tempPlayStatus = playStatus; bool ret = dbus_func_args_async(mConnection, -1, GetVoidCallback, @@ -3200,20 +3207,6 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration, runnable.forget(); - ControlEventId eventId = ControlEventId::EVENT_UNKNOWN; - uint64_t data; - if (aPosition != a2dp->GetPosition()) { - eventId = ControlEventId::EVENT_PLAYBACK_POS_CHANGED; - data = aPosition; - } else if (playStatus != a2dp->GetPlayStatus()) { - eventId = ControlEventId::EVENT_PLAYBACK_STATUS_CHANGED; - data = tempPlayStatus; - } - - if (eventId != ControlEventId::EVENT_UNKNOWN) { - UpdateNotification(eventId, data); - } - a2dp->UpdatePlayStatus(aDuration, aPosition, playStatus); }