summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rwxr-xr-x[-rw-r--r--]media/libmedia/AudioTrack.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index f9eb496..fa24415 100644..100755
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -30,6 +30,7 @@
#include <media/IAudioFlinger.h>
#include <media/AudioPolicyHelper.h>
#include <media/AudioResamplerPublic.h>
+#include "media/AVMediaExtensions.h"
#define WAIT_PERIOD_MS 10
#define WAIT_STREAM_END_TIMEOUT_SEC 120
@@ -992,6 +993,10 @@ status_t AudioTrack::getPosition(uint32_t *position)
return NO_ERROR;
}
+ if (AVMediaUtils::get()->AudioTrackGetPosition(this, position) == NO_ERROR) {
+ return NO_ERROR;
+ }
+
if (mOutput != AUDIO_IO_HANDLE_NONE) {
uint32_t halFrames; // actually unused
(void) AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames);
@@ -2223,14 +2228,21 @@ status_t AudioTrack::getTimestamp(AudioTimestamp& timestamp)
}
}
- // The presented frame count must always lag behind the consumed frame count.
- // To avoid a race, read the presented frames first. This ensures that presented <= consumed.
- status_t status = mAudioTrack->getTimestamp(timestamp);
- if (status != NO_ERROR) {
- ALOGV_IF(status != WOULD_BLOCK, "getTimestamp error:%#x", status);
- return status;
+ status_t status = UNKNOWN_ERROR;
+ //do not call Timestamp if its PCM offloaded
+ if (!AVMediaUtils::get()->AudioTrackIsPcmOffloaded(mFormat)) {
+ // The presented frame count must always lag behind the consumed frame count.
+ // To avoid a race, read the presented frames first. This ensures that presented <= consumed.
+
+ status = mAudioTrack->getTimestamp(timestamp);
+ if (status != NO_ERROR) {
+ ALOGV_IF(status != WOULD_BLOCK, "getTimestamp error:%#x", status);
+ return status;
+ }
+
}
- if (isOffloadedOrDirect_l()) {
+
+ if (isOffloadedOrDirect_l() && !AVMediaUtils::get()->AudioTrackIsPcmOffloaded(mFormat)) {
if (isOffloaded_l() && (mState == STATE_PAUSED || mState == STATE_PAUSED_STOPPING)) {
// use cached paused position in case another offloaded track is running.
timestamp.mPosition = mPausedPosition;
@@ -2288,6 +2300,11 @@ status_t AudioTrack::getTimestamp(AudioTimestamp& timestamp)
}
} else {
// Update the mapping between local consumed (mPosition) and server consumed (mServer)
+
+ if (AVMediaUtils::get()->AudioTrackGetTimestamp(this, timestamp) == NO_ERROR) {
+ return NO_ERROR;
+ }
+
(void) updateAndGetPosition_l();
// Server consumed (mServer) and presented both use the same server time base,
// and server consumed is always >= presented.