From de14e1f9fefa37b83d4cb1e7c0e7ece6dc4cf27e Mon Sep 17 00:00:00 2001 From: Gina Yeh Date: Mon, 29 Jul 2013 17:32:34 +0800 Subject: [PATCH] Bug 842948 - Patch 3: Cache AVRCP data in BluetoothA2dpManager, r=echou --- dom/bluetooth/BluetoothA2dpManager.cpp | 31 ++++++++++++++++++++ dom/bluetooth/BluetoothA2dpManager.h | 17 +++++++++++ dom/bluetooth/linux/BluetoothDBusService.cpp | 5 ++++ 3 files changed, 53 insertions(+) diff --git a/dom/bluetooth/BluetoothA2dpManager.cpp b/dom/bluetooth/BluetoothA2dpManager.cpp index 60da611d357..d9d8f57299f 100644 --- a/dom/bluetooth/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/BluetoothA2dpManager.cpp @@ -86,6 +86,11 @@ void BluetoothA2dpManager::ResetAvrcp() { mAvrcpConnected = false; + mDuration = 0; + mMediaNumber = 0; + mTotalMediaCount = 0; + mPosition = 0; + mPlayStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN; } static BluetoothA2dpManager::SinkState @@ -329,5 +334,31 @@ BluetoothA2dpManager::IsAvrcpConnected() return mAvrcpConnected; } +void +BluetoothA2dpManager::UpdateMetaData(const nsAString& aTitle, + const nsAString& aArtist, + const nsAString& aAlbum, + uint32_t aMediaNumber, + uint32_t aTotalMediaCount, + uint32_t aDuration) +{ + mTitle.Assign(aTitle); + mArtist.Assign(aArtist); + mAlbum.Assign(aAlbum); + mMediaNumber = aMediaNumber; + mTotalMediaCount = aTotalMediaCount; + mDuration = aDuration; +} + +void +BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration, + uint32_t aPosition, + ControlPlayStatus aPlayStatus) +{ + mDuration = aDuration; + mPosition = aPosition; + mPlayStatus = aPlayStatus; +} + NS_IMPL_ISUPPORTS1(BluetoothA2dpManager, nsIObserver) diff --git a/dom/bluetooth/BluetoothA2dpManager.h b/dom/bluetooth/BluetoothA2dpManager.h index 8971aedbed3..43365f3f282 100644 --- a/dom/bluetooth/BluetoothA2dpManager.h +++ b/dom/bluetooth/BluetoothA2dpManager.h @@ -49,6 +49,15 @@ public: // AVRCP member functions void SetAvrcpConnected(bool aConnected); bool IsAvrcpConnected(); + void UpdateMetaData(const nsAString& aTitle, + const nsAString& aArtist, + const nsAString& aAlbum, + uint32_t aMediaNumber, + uint32_t aTotalMediaCount, + uint32_t aDuration); + void UpdatePlayStatus(uint32_t aDuration, + uint32_t aPosition, + ControlPlayStatus aPlayStatus); private: BluetoothA2dpManager(); @@ -69,6 +78,14 @@ private: // AVRCP data member bool mAvrcpConnected; + nsString mAlbum; + nsString mArtist; + nsString mTitle; + uint32_t mDuration; + uint32_t mMediaNumber; + uint32_t mTotalMediaCount; + uint32_t mPosition; + ControlPlayStatus mPlayStatus; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index bf94f214eb4..8b9dfe4e0b1 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -2921,6 +2921,9 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle, NS_ENSURE_TRUE_VOID(ret); runnable.forget(); + + a2dp->UpdateMetaData(aTitle, aArtist, aAlbum, + aMediaNumber, aTotalMediaCount, aDuration); } static ControlPlayStatus @@ -3001,5 +3004,7 @@ BluetoothDBusService::SendPlayStatus(uint32_t aDuration, NS_ENSURE_TRUE_VOID(ret); runnable.forget(); + + a2dp->UpdatePlayStatus(aDuration, aPosition, playStatus); }