From 43a345e28b64d6eb63f4d5bb1fa5b7d67c5ce26f Mon Sep 17 00:00:00 2001 From: Satya Krishna Pindiproli Date: Wed, 30 Sep 2015 16:32:12 +0530 Subject: libmedia: return error if getRenderPosition fails Currently, if the call getRenderPosition() fails, no error is propagated to the caller. As the handling is already present in NuPlayerRenderer, return an error if the call fails. CRs-Fixed: 912730 Change-Id: I01e3348ffd696ce781287451b9a9478b50037ade --- media/libmedia/AudioTrack.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'media/libmedia/AudioTrack.cpp') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index f46b66e..2d9fcf7 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -999,14 +999,18 @@ status_t AudioTrack::getPosition(uint32_t *position) return NO_ERROR; } - if (AVMediaUtils::get()->AudioTrackGetPosition(this, position) == NO_ERROR) { + if (AVMediaUtils::get()->AudioTrackIsPcmOffloaded(mFormat) && + 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); - // FIXME: on getRenderPosition() error, we return OK with frame position 0. + status_t status = AudioSystem::getRenderPosition(mOutput, &halFrames, &dspFrames); + if (status != NO_ERROR) { + ALOGW("failed to getRenderPosition for offload session status %d", status); + return INVALID_OPERATION; + } } // FIXME: dspFrames may not be zero in (mState == STATE_STOPPED || mState == STATE_FLUSHED) // due to hardware latency. We leave this behavior for now. -- cgit v1.1