diff options
author | Hans Boehm <hboehm@google.com> | 2014-07-31 22:49:07 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-31 21:38:33 +0000 |
commit | fdefe34f40ea6c8964677eaa9107958b0bdf76d0 (patch) | |
tree | baaa5cb4624a46f91299888756f2d7ba2d8d6704 | |
parent | 25644c502ed8ec13bcf496613e65ec8edb1af4a7 (diff) | |
parent | e6fa1b7fdc74bec3292d6a10c99f25f9fd989d3f (diff) | |
download | frameworks_av-fdefe34f40ea6c8964677eaa9107958b0bdf76d0.zip frameworks_av-fdefe34f40ea6c8964677eaa9107958b0bdf76d0.tar.gz frameworks_av-fdefe34f40ea6c8964677eaa9107958b0bdf76d0.tar.bz2 |
Merge "Remove 64-bit android_atomic uses from StateQueue." into lmp-dev
-rw-r--r-- | services/audioflinger/StateQueue.cpp | 16 | ||||
-rw-r--r-- | services/audioflinger/StateQueue.h | 4 |
2 files changed, 8 insertions, 12 deletions
diff --git a/services/audioflinger/StateQueue.cpp b/services/audioflinger/StateQueue.cpp index 7e01c9f..40d7bcd 100644 --- a/services/audioflinger/StateQueue.cpp +++ b/services/audioflinger/StateQueue.cpp @@ -41,13 +41,14 @@ void StateQueueMutatorDump::dump(int fd) // Constructor and destructor template<typename T> StateQueue<T>::StateQueue() : - mNext(NULL), mAck(NULL), mCurrent(NULL), + mAck(NULL), mCurrent(NULL), mMutating(&mStates[0]), mExpecting(NULL), mInMutation(false), mIsDirty(false), mIsInitialized(false) #ifdef STATE_QUEUE_DUMP , mObserverDump(&mObserverDummyDump), mMutatorDump(&mMutatorDummyDump) #endif { + atomic_init(&mNext, 0); } template<typename T> StateQueue<T>::~StateQueue() @@ -58,11 +59,8 @@ template<typename T> StateQueue<T>::~StateQueue() template<typename T> const T* StateQueue<T>::poll() { -#ifdef __LP64__ - const T *next = (const T *) android_atomic_acquire_load64((volatile int64_t *) &mNext); -#else - const T *next = (const T *) android_atomic_acquire_load((volatile int32_t *) &mNext); -#endif + const T *next = (const T *) atomic_load_explicit(&mNext, memory_order_acquire); + if (next != mCurrent) { mAck = next; // no additional barrier needed mCurrent = next; @@ -144,11 +142,7 @@ template<typename T> bool StateQueue<T>::push(StateQueue<T>::block_t block) } // publish -#ifdef __LP64__ - android_atomic_release_store64((int64_t) mMutating, (volatile int64_t *) &mNext); -#else - android_atomic_release_store((int32_t) mMutating, (volatile int32_t *) &mNext); -#endif + atomic_store_explicit(&mNext, (uintptr_t)mMutating, memory_order_release); mExpecting = mMutating; // copy with circular wraparound diff --git a/services/audioflinger/StateQueue.h b/services/audioflinger/StateQueue.h index 9e176c4..27f6a28 100644 --- a/services/audioflinger/StateQueue.h +++ b/services/audioflinger/StateQueue.h @@ -17,6 +17,8 @@ #ifndef ANDROID_AUDIO_STATE_QUEUE_H #define ANDROID_AUDIO_STATE_QUEUE_H +#include <stdatomic.h> + // The state queue template class was originally driven by this use case / requirements: // There are two threads: a fast mixer, and a normal mixer, and they share state. // The interesting part of the shared state is a set of active fast tracks, @@ -186,7 +188,7 @@ private: T mStates[kN]; // written by mutator, read by observer // "volatile" is meaningless with SMP, but here it indicates that we're using atomic ops - volatile const T* mNext; // written by mutator to advance next, read by observer + atomic_uintptr_t mNext; // written by mutator to advance next, read by observer volatile const T* mAck; // written by observer to acknowledge advance of next, read by mutator // only used by observer |