diff options
author | Eric Laurent <elaurent@google.com> | 2011-09-07 11:13:23 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2011-09-08 15:18:37 -0700 |
commit | 2267ba18d0d2b2d4bd7f5411821ad89ac2659a88 (patch) | |
tree | 3339791f7085faf94b891071826d8a1be5d1cb17 /media | |
parent | 74a0a0d7f766d63330a00c3fa8f133c44c1d5be6 (diff) | |
download | frameworks_av-2267ba18d0d2b2d4bd7f5411821ad89ac2659a88.zip frameworks_av-2267ba18d0d2b2d4bd7f5411821ad89ac2659a88.tar.gz frameworks_av-2267ba18d0d2b2d4bd7f5411821ad89ac2659a88.tar.bz2 |
AudioTrack: extend callback thread sleep time
Do not force wake up the AudioTrack thread every 10ms if no timed
events (loop, markers..) have to be processed.
This will help reduce power consumption.
Change-Id: Icb425b13800690008dd07c27ffac84739e3dbba3
Diffstat (limited to 'media')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 7509239..c2c6715 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1078,6 +1078,11 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread) frames = mRemainingFrames; } + int32_t waitCount = -1; + if (mUpdatePeriod || (!mMarkerReached && mMarkerPosition) || mLoopCount) { + waitCount = 1; + } + do { audioBuffer.frameCount = frames; @@ -1085,7 +1090,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread) // Calling obtainBuffer() with a wait count of 1 // limits wait time to WAIT_PERIOD_MS. This prevents from being // stuck here not being able to handle timed events (position, markers, loops). - status_t err = obtainBuffer(&audioBuffer, 1); + status_t err = obtainBuffer(&audioBuffer, waitCount); if (err < NO_ERROR) { if (err != TIMED_OUT) { LOGE_IF(err != status_t(NO_MORE_BUFFERS), "Error obtaining an audio buffer, giving up."); |