diff options
author | Andy Hung <hunga@google.com> | 2014-12-29 18:39:32 -0800 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-01-06 12:00:00 -0800 |
commit | 3c09c78aabcb9d314dfb400258fb99a37c7b50c9 (patch) | |
tree | cff9d9d4cf65e0d4bf4e135ed4337c56dd6670af /media/libmedia/AudioTrack.cpp | |
parent | 53c3b5fc1afe162a8669cb3d27d6bb14e1847e39 (diff) | |
download | frameworks_av-3c09c78aabcb9d314dfb400258fb99a37c7b50c9.zip frameworks_av-3c09c78aabcb9d314dfb400258fb99a37c7b50c9.tar.gz frameworks_av-3c09c78aabcb9d314dfb400258fb99a37c7b50c9.tar.bz2 |
Event driven wake for AudioTrackThread notification changes
Used for setMarkerPosition and setPositionUpdatePeriod.
Change-Id: I0d94b929438a5cd94b295d7c1884f876fae8b5e7
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index ea7b2df..ca36143 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -753,6 +753,8 @@ void AudioTrack::setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount) mLoopStart = loopStart; mLoopCountNotified = loopCount; mStaticProxy->setLoop(loopStart, loopEnd, loopCount); + + // Waking the AudioTrackThread is not needed as this cannot be called when active. } status_t AudioTrack::setMarkerPosition(uint32_t marker) @@ -766,6 +768,10 @@ status_t AudioTrack::setMarkerPosition(uint32_t marker) mMarkerPosition = marker; mMarkerReached = false; + sp<AudioTrackThread> t = mAudioTrackThread; + if (t != 0) { + t->wake(); + } return NO_ERROR; } @@ -795,6 +801,10 @@ status_t AudioTrack::setPositionUpdatePeriod(uint32_t updatePeriod) mNewPosition = updateAndGetPosition_l() + updatePeriod; mUpdatePeriod = updatePeriod; + sp<AudioTrackThread> t = mAudioTrackThread; + if (t != 0) { + t->wake(); + } return NO_ERROR; } @@ -835,6 +845,8 @@ status_t AudioTrack::setPosition(uint32_t position) // After setting the position, use full update period before notification. mNewPosition = updateAndGetPosition_l() + mUpdatePeriod; mStaticProxy->setBufferPosition(position); + + // Waking the AudioTrackThread is not needed as this cannot be called when active. return NO_ERROR; } @@ -2181,8 +2193,8 @@ bool AudioTrack::AudioTrackThread::threadLoop() case NS_NEVER: return false; case NS_WHENEVER: - // FIXME increase poll interval, or make event-driven - ns = 1000000000LL; + // Event driven: call wake() when callback notifications conditions change. + ns = INT64_MAX; // fall through default: LOG_ALWAYS_FATAL_IF(ns < 0, "processAudioBuffer() returned %" PRId64, ns); @@ -2215,6 +2227,17 @@ void AudioTrack::AudioTrackThread::resume() } } +void AudioTrack::AudioTrackThread::wake() +{ + AutoMutex _l(mMyLock); + if (!mPaused && mPausedInt && mPausedNs > 0) { + // audio track is active and internally paused with timeout. + mIgnoreNextPausedInt = true; + mPausedInt = false; + mMyCond.signal(); + } +} + void AudioTrack::AudioTrackThread::pauseInternal(nsecs_t ns) { AutoMutex _l(mMyLock); |