From fd42e7afbe43eca5ab6835f8b2720b7e0e8302e0 Mon Sep 17 00:00:00 2001 From: Preetam Singh Ranawat Date: Thu, 23 Jul 2015 08:59:47 +0530 Subject: AVCustomizations: Enable 16 and 24 bit PCM offload. -create extended decoder and renderer -add change to pass bit width and format info to renderer. -add change for PCM conversions -add changes for time calucation Conflicts: media/libmediaplayerservice/nuplayer/NuPlayer.cpp Change-Id: I3363140fad441a7746884076c40b46e777f2e06e --- media/libmedia/AudioTrack.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) mode change 100644 => 100755 media/libmedia/AudioTrack.cpp (limited to 'media/libmedia/AudioTrack.cpp') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp old mode 100644 new mode 100755 index f9eb496..fa24415 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -30,6 +30,7 @@ #include #include #include +#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. -- cgit v1.1