From 96f60d8f04432a1ed503b3e24d5736d28c63c9a2 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Fri, 12 Jul 2013 10:21:18 -0700 Subject: Rename control block flags to mFlags Change-Id: I7b6d31e24531954ab1ecdf3ed56c19433700bd89 --- include/private/media/AudioTrackShared.h | 3 ++- media/libmedia/AudioRecord.cpp | 4 ++-- media/libmedia/AudioTrack.cpp | 18 +++++++++--------- media/libmedia/AudioTrackShared.cpp | 18 +++++++++--------- services/audioflinger/Threads.cpp | 6 +++--- services/audioflinger/Tracks.cpp | 16 ++++++++-------- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h index e950b9e..c5d8145 100644 --- a/include/private/media/AudioTrackShared.h +++ b/include/private/media/AudioTrackShared.h @@ -31,6 +31,7 @@ namespace android { // ---------------------------------------------------------------------------- +// for audio_track_cblk_t::mFlags #define CBLK_UNDERRUN 0x01 // set by server immediately on output underrun, cleared by client #define CBLK_FORCEREADY 0x02 // set: track is considered ready immediately by AudioFlinger, // clear: track is ready when buffer full @@ -127,7 +128,7 @@ public: // read-only for client, server writes once at initialization and is then read-only uint8_t mName; // normal tracks: track name, fast tracks: track index - volatile int32_t flags; + volatile int32_t mFlags; // combinations of CBLK_* // Cache line boundary (32 bytes) diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index 603c16e..0e7e17f 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -300,7 +300,7 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, int triggerSession) mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition()); mNewPosition = mProxy->getPosition() + mUpdatePeriod; - int32_t flags = android_atomic_acquire_load(&mCblk->flags); + int32_t flags = android_atomic_acquire_load(&mCblk->mFlags); status_t status = NO_ERROR; if (!(flags & CBLK_INVALID)) { @@ -667,7 +667,7 @@ nsecs_t AudioRecord::processAudioBuffer(const sp& thread) mLock.lock(); // Can only reference mCblk while locked - int32_t flags = android_atomic_and(~CBLK_OVERRUN, &mCblk->flags); + int32_t flags = android_atomic_and(~CBLK_OVERRUN, &mCblk->mFlags); // Check for track invalidation if (flags & CBLK_INVALID) { diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 3653b7f..64a59be 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -389,7 +389,7 @@ status_t AudioTrack::start() mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition()); } mNewPosition = mProxy->getPosition() + mUpdatePeriod; - int32_t flags = android_atomic_and(~CBLK_DISABLED, &mCblk->flags); + int32_t flags = android_atomic_and(~CBLK_DISABLED, &mCblk->mFlags); sp t = mAudioTrackThread; if (t != 0) { @@ -1182,7 +1182,7 @@ void AudioTrack::releaseBuffer(Buffer* audioBuffer) // restart track if it was disabled by audioflinger due to previous underrun if (mState == STATE_ACTIVE) { audio_track_cblk_t* cblk = mCblk; - if (android_atomic_and(~CBLK_DISABLED, &cblk->flags) & CBLK_DISABLED) { + if (android_atomic_and(~CBLK_DISABLED, &cblk->mFlags) & CBLK_DISABLED) { ALOGW("releaseBuffer() track %p name=%#x disabled due to previous underrun, restarting", this, cblk->mName); // FIXME ignoring status @@ -1261,16 +1261,16 @@ status_t TimedAudioTrack::allocateTimedBuffer(size_t size, sp* buffer) // fails indicating that the server is dead, flag the track as invalid so // we can attempt to restore in just a bit. audio_track_cblk_t* cblk = mCblk; - if (!(cblk->flags & CBLK_INVALID)) { + if (!(cblk->mFlags & CBLK_INVALID)) { result = mAudioTrack->allocateTimedBuffer(size, buffer); if (result == DEAD_OBJECT) { - android_atomic_or(CBLK_INVALID, &cblk->flags); + android_atomic_or(CBLK_INVALID, &cblk->mFlags); } } // If the track is invalid at this point, attempt to restore it. and try the // allocation one more time. - if (cblk->flags & CBLK_INVALID) { + if (cblk->mFlags & CBLK_INVALID) { result = restoreTrack_l("allocateTimedBuffer"); if (result == NO_ERROR) { @@ -1290,8 +1290,8 @@ status_t TimedAudioTrack::queueTimedBuffer(const sp& buffer, audio_track_cblk_t* cblk = mCblk; // restart track if it was disabled by audioflinger due to previous underrun if (buffer->size() != 0 && status == NO_ERROR && - (mState == STATE_ACTIVE) && (cblk->flags & CBLK_DISABLED)) { - android_atomic_and(~CBLK_DISABLED, &cblk->flags); + (mState == STATE_ACTIVE) && (cblk->mFlags & CBLK_DISABLED)) { + android_atomic_and(~CBLK_DISABLED, &cblk->mFlags); ALOGW("queueTimedBuffer() track %p disabled, restarting", this); // FIXME ignoring status mAudioTrack->start(); @@ -1339,7 +1339,7 @@ nsecs_t AudioTrack::processAudioBuffer(const sp& thread) // Can only reference mCblk while locked int32_t flags = android_atomic_and( - ~(CBLK_UNDERRUN | CBLK_LOOP_CYCLE | CBLK_LOOP_FINAL | CBLK_BUFFER_END), &mCblk->flags); + ~(CBLK_UNDERRUN | CBLK_LOOP_CYCLE | CBLK_LOOP_FINAL | CBLK_BUFFER_END), &mCblk->mFlags); // Check for track invalidation if (flags & CBLK_INVALID) { @@ -1681,7 +1681,7 @@ status_t AudioTrack::restoreTrack_l(const char *from) // the actual amount of audio frames played (e.g SoundPool) receives them. if (mSharedBuffer == 0) { // restart playback even if buffer is not completely filled. - android_atomic_or(CBLK_FORCEREADY, &mCblk->flags); + android_atomic_or(CBLK_FORCEREADY, &mCblk->mFlags); } } #endif diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp index e5f7fcd..5015b8d 100644 --- a/media/libmedia/AudioTrackShared.cpp +++ b/media/libmedia/AudioTrackShared.cpp @@ -27,7 +27,7 @@ namespace android { audio_track_cblk_t::audio_track_cblk_t() : mServer(0), frameCount_(0), mFutex(0), mMinimum(0), - mVolumeLR(0x10001000), mSampleRate(0), mSendLevel(0), mName(0), flags(0) + mVolumeLR(0x10001000), mSampleRate(0), mSendLevel(0), mName(0), mFlags(0) { memset(&u, 0, sizeof(u)); } @@ -99,7 +99,7 @@ status_t ClientProxy::obtainBuffer(Buffer* buffer, const struct timespec *reques goto end; } for (;;) { - int32_t flags = android_atomic_and(~CBLK_INTERRUPT, &cblk->flags); + int32_t flags = android_atomic_and(~CBLK_INTERRUPT, &cblk->mFlags); // check for track invalidation by server, or server death detection if (flags & CBLK_INVALID) { ALOGV("Track invalidated"); @@ -293,7 +293,7 @@ void ClientProxy::releaseBuffer(Buffer* buffer) void ClientProxy::binderDied() { audio_track_cblk_t* cblk = mCblk; - if (!(android_atomic_or(CBLK_INVALID, &cblk->flags) & CBLK_INVALID)) { + if (!(android_atomic_or(CBLK_INVALID, &cblk->mFlags) & CBLK_INVALID)) { // it seems that a FUTEX_WAKE_PRIVATE will not wake a FUTEX_WAIT, even within same process (void) __futex_syscall3(&cblk->mFutex, mClientInServer ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE, 1); @@ -303,7 +303,7 @@ void ClientProxy::binderDied() void ClientProxy::interrupt() { audio_track_cblk_t* cblk = mCblk; - if (!(android_atomic_or(CBLK_INTERRUPT, &cblk->flags) & CBLK_INTERRUPT)) { + if (!(android_atomic_or(CBLK_INTERRUPT, &cblk->mFlags) & CBLK_INTERRUPT)) { (void) __futex_syscall3(&cblk->mFutex, mClientInServer ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE, 1); } @@ -324,11 +324,11 @@ void AudioTrackClientProxy::flush() } bool AudioTrackClientProxy::clearStreamEndDone() { - return (android_atomic_and(~CBLK_STREAM_END_DONE, &mCblk->flags) & CBLK_STREAM_END_DONE) != 0; + return (android_atomic_and(~CBLK_STREAM_END_DONE, &mCblk->mFlags) & CBLK_STREAM_END_DONE) != 0; } bool AudioTrackClientProxy::getStreamEndDone() const { - return (mCblk->flags & CBLK_STREAM_END_DONE) != 0; + return (mCblk->mFlags & CBLK_STREAM_END_DONE) != 0; } status_t AudioTrackClientProxy::waitStreamEndDone(const struct timespec *requested) @@ -354,7 +354,7 @@ status_t AudioTrackClientProxy::waitStreamEndDone(const struct timespec *request timeout = TIMEOUT_FINITE; } for (;;) { - int32_t flags = android_atomic_and(~(CBLK_INTERRUPT|CBLK_STREAM_END_DONE), &cblk->flags); + int32_t flags = android_atomic_and(~(CBLK_INTERRUPT|CBLK_STREAM_END_DONE), &cblk->mFlags); // check for track invalidation by server, or server death detection if (flags & CBLK_INVALID) { ALOGV("Track invalidated"); @@ -653,7 +653,7 @@ size_t AudioTrackServerProxy::framesReady() bool AudioTrackServerProxy::setStreamEndDone() { bool old = - (android_atomic_or(CBLK_STREAM_END_DONE, &mCblk->flags) & CBLK_STREAM_END_DONE) != 0; + (android_atomic_or(CBLK_STREAM_END_DONE, &mCblk->mFlags) & CBLK_STREAM_END_DONE) != 0; if (!old) { (void) __futex_syscall3(&mCblk->mFutex, mClientInServer ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE, 1); @@ -808,7 +808,7 @@ void StaticAudioTrackServerProxy::releaseBuffer(Buffer* buffer) cblk->mServer += stepCount; cblk->u.mStatic.mBufferPosition = newPosition; if (setFlags != 0) { - (void) android_atomic_or(setFlags, &cblk->flags); + (void) android_atomic_or(setFlags, &cblk->mFlags); // this would be a good place to wake a futex } diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 5ba64d5..e6a9d65c 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -2783,7 +2783,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac } // indicate to client process that the track was disabled because of underrun; // it will then automatically call start() when data is available - android_atomic_or(CBLK_DISABLED, &track->mCblk->flags); + android_atomic_or(CBLK_DISABLED, &track->mCblk->mFlags); // remove from active list, but state remains ACTIVE [confusing but true] isActive = false; break; @@ -3061,7 +3061,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // we missed desiredFrames whatever the actual number of frames missing was cblk->u.mStreaming.mUnderrunFrames += desiredFrames; // FIXME also wake futex so that underrun is noticed more quickly - (void) android_atomic_or(CBLK_UNDERRUN, &cblk->flags); + (void) android_atomic_or(CBLK_UNDERRUN, &cblk->mFlags); } // clear effect chain input buffer if an active track underruns to avoid sending // previous audio buffer again to effects @@ -3094,7 +3094,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac tracksToRemove->add(track); // indicate to client process that the track was disabled because of underrun; // it will then automatically call start() when data is available - android_atomic_or(CBLK_DISABLED, &cblk->flags); + android_atomic_or(CBLK_DISABLED, &cblk->mFlags); // If one track is not ready, mark the mixer also not ready if: // - the mixer was ready during previous round OR // - no other track is ready diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index 4f2e372..58af204 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -128,7 +128,7 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase( } else { mBuffer = sharedBuffer->pointer(); #if 0 - mCblk->flags = CBLK_FORCEREADY; // FIXME hack, need to fix the track ready logic + mCblk->mFlags = CBLK_FORCEREADY; // FIXME hack, need to fix the track ready logic #endif } @@ -471,7 +471,7 @@ void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size) mCblk->mServer, (int)mMainBuffer, (int)mAuxBuffer, - mCblk->flags, + mCblk->mFlags, mUnderrunCount, nowInUnderrun); } @@ -494,7 +494,7 @@ status_t AudioFlinger::PlaybackThread::Track::getNextBuffer( // only implemented so far for normal tracks, not fast tracks mCblk->u.mStreaming.mUnderrunFrames += desiredFrames; // FIXME also wake futex so that underrun is noticed more quickly - (void) android_atomic_or(CBLK_UNDERRUN, &mCblk->flags); + (void) android_atomic_or(CBLK_UNDERRUN, &mCblk->mFlags); } return status; } @@ -518,9 +518,9 @@ bool AudioFlinger::PlaybackThread::Track::isReady() const { } if (framesReady() >= mFrameCount || - (mCblk->flags & CBLK_FORCEREADY)) { + (mCblk->mFlags & CBLK_FORCEREADY)) { mFillingUpStatus = FS_FILLED; - android_atomic_and(~CBLK_FORCEREADY, &mCblk->flags); + android_atomic_and(~CBLK_FORCEREADY, &mCblk->mFlags); return true; } return false; @@ -694,7 +694,7 @@ void AudioFlinger::PlaybackThread::Track::reset() if (!mResetDone) { // Force underrun condition to avoid false underrun callback until first data is // written to buffer - android_atomic_and(~CBLK_FORCEREADY, &mCblk->flags); + android_atomic_and(~CBLK_FORCEREADY, &mCblk->mFlags); mFillingUpStatus = FS_FILLING; mResetDone = true; if (mState == FLUSHED) { @@ -856,7 +856,7 @@ void AudioFlinger::PlaybackThread::Track::invalidate() { // FIXME should use proxy, and needs work audio_track_cblk_t* cblk = mCblk; - android_atomic_or(CBLK_INVALID, &cblk->flags); + android_atomic_or(CBLK_INVALID, &cblk->mFlags); android_atomic_release_store(0x40000000, &cblk->mFutex); // client is not in server, so FUTEX_WAKE is needed instead of FUTEX_WAKE_PRIVATE (void) __futex_syscall3(&cblk->mFutex, FUTEX_WAKE, INT_MAX); @@ -1679,7 +1679,7 @@ status_t AudioFlinger::RecordThread::RecordTrack::getNextBuffer(AudioBufferProvi buffer->raw = buf.mRaw; if (buf.mFrameCount == 0) { // FIXME also wake futex so that overrun is noticed more quickly - (void) android_atomic_or(CBLK_OVERRUN, &mCblk->flags); + (void) android_atomic_or(CBLK_OVERRUN, &mCblk->mFlags); } return status; } -- cgit v1.1