Remove TimedAudioTrack and associated code
Bug: 8278435
Change-Id: I095c1a4888e645e14d93b0b15fbef4524a831ca1
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index a13d53a..e17e47e 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -163,7 +163,6 @@
AudioTrack::AudioTrack()
: mStatus(NO_INIT),
- mIsTimed(false),
mPreviousPriority(ANDROID_PRIORITY_NORMAL),
mPreviousSchedulingGroup(SP_DEFAULT),
mPausedPosition(0),
@@ -193,7 +192,6 @@
const audio_attributes_t* pAttributes,
bool doNotReconnect)
: mStatus(NO_INIT),
- mIsTimed(false),
mPreviousPriority(ANDROID_PRIORITY_NORMAL),
mPreviousSchedulingGroup(SP_DEFAULT),
mPausedPosition(0),
@@ -223,7 +221,6 @@
const audio_attributes_t* pAttributes,
bool doNotReconnect)
: mStatus(NO_INIT),
- mIsTimed(false),
mPreviousPriority(ANDROID_PRIORITY_NORMAL),
mPreviousSchedulingGroup(SP_DEFAULT),
mPausedPosition(0),
@@ -750,7 +747,7 @@
if (rate == mSampleRate) {
return NO_ERROR;
}
- if (mIsTimed || isOffloadedOrDirect_l() || (mFlags & AUDIO_OUTPUT_FLAG_FAST)) {
+ if (isOffloadedOrDirect_l() || (mFlags & AUDIO_OUTPUT_FLAG_FAST)) {
return INVALID_OPERATION;
}
if (mOutput == AUDIO_IO_HANDLE_NONE) {
@@ -777,10 +774,6 @@
uint32_t AudioTrack::getSampleRate() const
{
- if (mIsTimed) {
- return 0;
- }
-
AutoMutex lock(mLock);
// sample rate can be updated during playback by the offloaded decoder so we need to
@@ -800,10 +793,6 @@
uint32_t AudioTrack::getOriginalSampleRate() const
{
- if (mIsTimed) {
- return 0;
- }
-
return mOriginalSampleRate;
}
@@ -813,7 +802,7 @@
if (isAudioPlaybackRateEqual(playbackRate, mPlaybackRate)) {
return NO_ERROR;
}
- if (mIsTimed || isOffloadedOrDirect_l()) {
+ if (isOffloadedOrDirect_l()) {
return INVALID_OPERATION;
}
if (mFlags & AUDIO_OUTPUT_FLAG_FAST) {
@@ -877,7 +866,7 @@
return NO_INIT;
}
// Reject if timed track or compressed audio.
- if (mIsTimed || !audio_is_linear_pcm(mFormat)) {
+ if (!audio_is_linear_pcm(mFormat)) {
return INVALID_OPERATION;
}
// TODO also need to inform the server side (through mAudioTrack) that
@@ -888,7 +877,7 @@
status_t AudioTrack::setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount)
{
- if (mSharedBuffer == 0 || mIsTimed || isOffloadedOrDirect()) {
+ if (mSharedBuffer == 0 || isOffloadedOrDirect()) {
return INVALID_OPERATION;
}
@@ -991,7 +980,7 @@
status_t AudioTrack::setPosition(uint32_t position)
{
- if (mSharedBuffer == 0 || mIsTimed || isOffloadedOrDirect()) {
+ if (mSharedBuffer == 0 || isOffloadedOrDirect()) {
return INVALID_OPERATION;
}
if (position > mFrameCount) {
@@ -1056,7 +1045,7 @@
status_t AudioTrack::getBufferPosition(uint32_t *position)
{
- if (mSharedBuffer == 0 || mIsTimed) {
+ if (mSharedBuffer == 0) {
return INVALID_OPERATION;
}
if (position == NULL) {
@@ -1070,7 +1059,7 @@
status_t AudioTrack::reload()
{
- if (mSharedBuffer == 0 || mIsTimed || isOffloadedOrDirect()) {
+ if (mSharedBuffer == 0 || isOffloadedOrDirect()) {
return INVALID_OPERATION;
}
@@ -1199,8 +1188,7 @@
mSampleRate = mAfSampleRate;
mOriginalSampleRate = mAfSampleRate;
}
- // Client decides whether the track is TIMED (see below), but can only express a preference
- // for FAST. Server will perform additional tests.
+ // Client can only express a preference for FAST. Server will perform additional tests.
if (mFlags & AUDIO_OUTPUT_FLAG_FAST) {
bool useCaseAllowed =
// either of these use cases:
@@ -1284,9 +1272,6 @@
}
IAudioFlinger::track_flags_t trackFlags = IAudioFlinger::TRACK_DEFAULT;
- if (mIsTimed) {
- trackFlags |= IAudioFlinger::TRACK_TIMED;
- }
pid_t tid = -1;
if (mFlags & AUDIO_OUTPUT_FLAG_FAST) {
@@ -1626,7 +1611,7 @@
ssize_t AudioTrack::write(const void* buffer, size_t userSize, bool blocking)
{
- if (mTransfer != TRANSFER_SYNC || mIsTimed) {
+ if (mTransfer != TRANSFER_SYNC) {
return INVALID_OPERATION;
}
@@ -1676,73 +1661,6 @@
// -------------------------------------------------------------------------
-TimedAudioTrack::TimedAudioTrack() {
- mIsTimed = true;
-}
-
-status_t TimedAudioTrack::allocateTimedBuffer(size_t size, sp<IMemory>* buffer)
-{
- AutoMutex lock(mLock);
- status_t result = UNKNOWN_ERROR;
-
-#if 1
- // acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
- // while we are accessing the cblk
- sp<IAudioTrack> audioTrack = mAudioTrack;
- sp<IMemory> iMem = mCblkMemory;
-#endif
-
- // If the track is not invalid already, try to allocate a buffer. alloc
- // fails indicating that the server is dead, flag the track as invalid so
- // we can attempt to restore in just a bit.
- audio_track_cblk_t* cblk = mCblk;
- if (!(cblk->mFlags & CBLK_INVALID)) {
- result = mAudioTrack->allocateTimedBuffer(size, buffer);
- if (result == DEAD_OBJECT) {
- android_atomic_or(CBLK_INVALID, &cblk->mFlags);
- }
- }
-
- // If the track is invalid at this point, attempt to restore it. and try the
- // allocation one more time.
- if (cblk->mFlags & CBLK_INVALID) {
- result = restoreTrack_l("allocateTimedBuffer");
-
- if (result == NO_ERROR) {
- result = mAudioTrack->allocateTimedBuffer(size, buffer);
- }
- }
-
- return result;
-}
-
-status_t TimedAudioTrack::queueTimedBuffer(const sp<IMemory>& buffer,
- int64_t pts)
-{
- status_t status = mAudioTrack->queueTimedBuffer(buffer, pts);
- {
- AutoMutex lock(mLock);
- audio_track_cblk_t* cblk = mCblk;
- // restart track if it was disabled by audioflinger due to previous underrun
- if (buffer->size() != 0 && status == NO_ERROR &&
- (mState == STATE_ACTIVE) && (cblk->mFlags & CBLK_DISABLED)) {
- android_atomic_and(~CBLK_DISABLED, &cblk->mFlags);
- ALOGW("queueTimedBuffer() track %p disabled, restarting", this);
- // FIXME ignoring status
- mAudioTrack->start();
- }
- }
- return status;
-}
-
-status_t TimedAudioTrack::setMediaTimeTransform(const LinearTransform& xform,
- TargetTimeline target)
-{
- return mAudioTrack->setMediaTimeTransform(xform, target);
-}
-
-// -------------------------------------------------------------------------
-
nsecs_t AudioTrack::processAudioBuffer()
{
// Currently the AudioTrack thread is not created if there are no callbacks.
diff --git a/media/libmedia/IAudioTrack.cpp b/media/libmedia/IAudioTrack.cpp
index 651cb61..636e3bb 100644
--- a/media/libmedia/IAudioTrack.cpp
+++ b/media/libmedia/IAudioTrack.cpp
@@ -36,9 +36,6 @@
RESERVED, // was MUTE
PAUSE,
ATTACH_AUX_EFFECT,
- ALLOCATE_TIMED_BUFFER,
- QUEUE_TIMED_BUFFER,
- SET_MEDIA_TIME_TRANSFORM,
SET_PARAMETERS,
GET_TIMESTAMP,
SIGNAL,
@@ -115,55 +112,6 @@
return status;
}
- virtual status_t allocateTimedBuffer(size_t size, sp<IMemory>* buffer) {
- Parcel data, reply;
- data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
- data.writeInt64(size);
- status_t status = remote()->transact(ALLOCATE_TIMED_BUFFER,
- data, &reply);
- if (status == NO_ERROR) {
- status = reply.readInt32();
- if (status == NO_ERROR) {
- *buffer = interface_cast<IMemory>(reply.readStrongBinder());
- if (*buffer != 0 && (*buffer)->pointer() == NULL) {
- (*buffer).clear();
- }
- }
- }
- return status;
- }
-
- virtual status_t queueTimedBuffer(const sp<IMemory>& buffer,
- int64_t pts) {
- Parcel data, reply;
- data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
- data.writeStrongBinder(IInterface::asBinder(buffer));
- data.writeInt64(pts);
- status_t status = remote()->transact(QUEUE_TIMED_BUFFER,
- data, &reply);
- if (status == NO_ERROR) {
- status = reply.readInt32();
- }
- return status;
- }
-
- virtual status_t setMediaTimeTransform(const LinearTransform& xform,
- int target) {
- Parcel data, reply;
- data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
- data.writeInt64(xform.a_zero);
- data.writeInt64(xform.b_zero);
- data.writeInt32(xform.a_to_b_numer);
- data.writeInt32(xform.a_to_b_denom);
- data.writeInt32(target);
- status_t status = remote()->transact(SET_MEDIA_TIME_TRANSFORM,
- data, &reply);
- if (status == NO_ERROR) {
- status = reply.readInt32();
- }
- return status;
- }
-
virtual status_t setParameters(const String8& keyValuePairs) {
Parcel data, reply;
data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
@@ -235,35 +183,6 @@
reply->writeInt32(attachAuxEffect(data.readInt32()));
return NO_ERROR;
} break;
- case ALLOCATE_TIMED_BUFFER: {
- CHECK_INTERFACE(IAudioTrack, data, reply);
- sp<IMemory> buffer;
- status_t status = allocateTimedBuffer(data.readInt64(), &buffer);
- reply->writeInt32(status);
- if (status == NO_ERROR) {
- reply->writeStrongBinder(IInterface::asBinder(buffer));
- }
- return NO_ERROR;
- } break;
- case QUEUE_TIMED_BUFFER: {
- CHECK_INTERFACE(IAudioTrack, data, reply);
- sp<IMemory> buffer = interface_cast<IMemory>(
- data.readStrongBinder());
- uint64_t pts = data.readInt64();
- reply->writeInt32(queueTimedBuffer(buffer, pts));
- return NO_ERROR;
- } break;
- case SET_MEDIA_TIME_TRANSFORM: {
- CHECK_INTERFACE(IAudioTrack, data, reply);
- LinearTransform xform;
- xform.a_zero = data.readInt64();
- xform.b_zero = data.readInt64();
- xform.a_to_b_numer = data.readInt32();
- xform.a_to_b_denom = data.readInt32();
- int target = data.readInt32();
- reply->writeInt32(setMediaTimeTransform(xform, target));
- return NO_ERROR;
- } break;
case SET_PARAMETERS: {
CHECK_INTERFACE(IAudioTrack, data, reply);
String8 keyValuePairs(data.readString8());
diff --git a/media/libnbaio/Android.mk b/media/libnbaio/Android.mk
index 1353f28..16c5040 100644
--- a/media/libnbaio/Android.mk
+++ b/media/libnbaio/Android.mk
@@ -28,7 +28,6 @@
LOCAL_SHARED_LIBRARIES := \
libaudioutils \
libbinder \
- libcommon_time_client \
libcutils \
libutils \
liblog
diff --git a/media/libnbaio/AudioBufferProviderSource.cpp b/media/libnbaio/AudioBufferProviderSource.cpp
index 551f516..cba8b59 100644
--- a/media/libnbaio/AudioBufferProviderSource.cpp
+++ b/media/libnbaio/AudioBufferProviderSource.cpp
@@ -46,16 +46,14 @@
return mBuffer.raw != NULL ? mBuffer.frameCount - mConsumed : 0;
}
-ssize_t AudioBufferProviderSource::read(void *buffer,
- size_t count,
- int64_t readPTS)
+ssize_t AudioBufferProviderSource::read(void *buffer, size_t count)
{
if (CC_UNLIKELY(!mNegotiated)) {
return NEGOTIATE;
}
if (CC_UNLIKELY(mBuffer.raw == NULL)) {
mBuffer.frameCount = count;
- status_t status = mProvider->getNextBuffer(&mBuffer, readPTS);
+ status_t status = mProvider->getNextBuffer(&mBuffer);
if (status != OK) {
return status == NOT_ENOUGH_DATA ? (ssize_t) WOULD_BLOCK : (ssize_t) status;
}
@@ -81,8 +79,7 @@
return count;
}
-ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *user,
- int64_t readPTS, size_t block)
+ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *user, size_t block)
{
if (CC_UNLIKELY(!mNegotiated)) {
return NEGOTIATE;
@@ -102,7 +99,7 @@
// 1 <= count <= block
if (CC_UNLIKELY(mBuffer.raw == NULL)) {
mBuffer.frameCount = count;
- status_t status = mProvider->getNextBuffer(&mBuffer, readPTS);
+ status_t status = mProvider->getNextBuffer(&mBuffer);
if (CC_LIKELY(status == OK)) {
ALOG_ASSERT(mBuffer.raw != NULL && mBuffer.frameCount <= count);
// mConsumed is 0 either from constructor or after releaseBuffer()
@@ -120,8 +117,8 @@
count = available;
}
if (CC_LIKELY(count > 0)) {
- char* readTgt = (char *) mBuffer.raw + (mConsumed * mFrameSize);
- ssize_t ret = via(user, readTgt, count, readPTS);
+ ssize_t ret = via(user, (char *) mBuffer.raw + (mConsumed * mFrameSize), count);
+
if (CC_UNLIKELY(ret <= 0)) {
if (CC_LIKELY(accumulator > 0)) {
return accumulator;
diff --git a/media/libnbaio/AudioStreamInSource.cpp b/media/libnbaio/AudioStreamInSource.cpp
index 6aab48a..286e0eb 100644
--- a/media/libnbaio/AudioStreamInSource.cpp
+++ b/media/libnbaio/AudioStreamInSource.cpp
@@ -64,7 +64,7 @@
return mFramesOverrun;
}
-ssize_t AudioStreamInSource::read(void *buffer, size_t count, int64_t readPTS __unused)
+ssize_t AudioStreamInSource::read(void *buffer, size_t count)
{
if (CC_UNLIKELY(!Format_isValid(mFormat))) {
return NEGOTIATE;
diff --git a/media/libnbaio/AudioStreamOutSink.cpp b/media/libnbaio/AudioStreamOutSink.cpp
index 0d5f935..3f4e0bb 100644
--- a/media/libnbaio/AudioStreamOutSink.cpp
+++ b/media/libnbaio/AudioStreamOutSink.cpp
@@ -66,18 +66,6 @@
return ret;
}
-status_t AudioStreamOutSink::getNextWriteTimestamp(int64_t *timestamp) {
- ALOG_ASSERT(timestamp != NULL);
-
- if (NULL == mStream)
- return INVALID_OPERATION;
-
- if (NULL == mStream->get_next_write_timestamp)
- return INVALID_OPERATION;
-
- return mStream->get_next_write_timestamp(mStream, timestamp);
-}
-
status_t AudioStreamOutSink::getTimestamp(AudioTimestamp& timestamp)
{
if (mStream->get_presentation_position == NULL) {
diff --git a/media/libnbaio/MonoPipe.cpp b/media/libnbaio/MonoPipe.cpp
index 129e9ef..aef9834 100644
--- a/media/libnbaio/MonoPipe.cpp
+++ b/media/libnbaio/MonoPipe.cpp
@@ -19,10 +19,8 @@
#define LOG_TAG "MonoPipe"
//#define LOG_NDEBUG 0
-#include <common_time/cc_helper.h>
#include <cutils/atomic.h>
#include <cutils/compiler.h>
-#include <utils/LinearTransform.h>
#include <utils/Log.h>
#include <utils/Trace.h>
#include <media/AudioBufferProvider.h>
@@ -32,26 +30,8 @@
namespace android {
-static uint64_t cacheN; // output of CCHelper::getLocalFreq()
-static bool cacheValid; // whether cacheN is valid
-static pthread_once_t cacheOnceControl = PTHREAD_ONCE_INIT;
-
-static void cacheOnceInit()
-{
- CCHelper tmpHelper;
- status_t res;
- if (OK != (res = tmpHelper.getLocalFreq(&cacheN))) {
- ALOGE("Failed to fetch local time frequency when constructing a"
- " MonoPipe (res = %d). getNextWriteTimestamp calls will be"
- " non-functional", res);
- return;
- }
- cacheValid = true;
-}
-
MonoPipe::MonoPipe(size_t reqFrames, const NBAIO_Format& format, bool writeCanBlock) :
NBAIO_Sink(format),
- mUpdateSeq(0),
mReqFrames(reqFrames),
mMaxFrames(roundup(reqFrames)),
mBuffer(malloc(mMaxFrames * Format_frameSize(format))),
@@ -66,36 +46,6 @@
mTimestampMutator(&mTimestampShared),
mTimestampObserver(&mTimestampShared)
{
- uint64_t N, D;
-
- mNextRdPTS = AudioBufferProvider::kInvalidPTS;
-
- mSamplesToLocalTime.a_zero = 0;
- mSamplesToLocalTime.b_zero = 0;
- mSamplesToLocalTime.a_to_b_numer = 0;
- mSamplesToLocalTime.a_to_b_denom = 0;
-
- D = Format_sampleRate(format);
-
- (void) pthread_once(&cacheOnceControl, cacheOnceInit);
- if (!cacheValid) {
- // log has already been done
- return;
- }
- N = cacheN;
-
- LinearTransform::reduce(&N, &D);
- static const uint64_t kSignedHiBitsMask = ~(0x7FFFFFFFull);
- static const uint64_t kUnsignedHiBitsMask = ~(0xFFFFFFFFull);
- if ((N & kSignedHiBitsMask) || (D & kUnsignedHiBitsMask)) {
- ALOGE("Cannot reduce sample rate to local clock frequency ratio to fit"
- " in a 32/32 bit rational. (max reduction is 0x%016" PRIx64 "/0x%016" PRIx64
- "). getNextWriteTimestamp calls will be non-functional", N, D);
- return;
- }
-
- mSamplesToLocalTime.a_to_b_numer = static_cast<int32_t>(N);
- mSamplesToLocalTime.a_to_b_denom = static_cast<uint32_t>(D);
}
MonoPipe::~MonoPipe()
@@ -223,104 +173,6 @@
mSetpoint = setpoint;
}
-status_t MonoPipe::getNextWriteTimestamp(int64_t *timestamp)
-{
- int32_t front;
-
- ALOG_ASSERT(NULL != timestamp);
-
- if (0 == mSamplesToLocalTime.a_to_b_denom)
- return UNKNOWN_ERROR;
-
- observeFrontAndNRPTS(&front, timestamp);
-
- if (AudioBufferProvider::kInvalidPTS != *timestamp) {
- // If we have a valid read-pointer and next read timestamp pair, then
- // use the current value of the write pointer to figure out how many
- // frames are in the buffer, and offset the timestamp by that amt. Then
- // next time we write to the MonoPipe, the data will hit the speakers at
- // the next read timestamp plus the current amount of data in the
- // MonoPipe.
- size_t pendingFrames = (mRear - front) & (mMaxFrames - 1);
- *timestamp = offsetTimestampByAudioFrames(*timestamp, pendingFrames);
- }
-
- return OK;
-}
-
-void MonoPipe::updateFrontAndNRPTS(int32_t newFront, int64_t newNextRdPTS)
-{
- // Set the MSB of the update sequence number to indicate that there is a
- // multi-variable update in progress. Use an atomic store with an "acquire"
- // barrier to make sure that the next operations cannot be re-ordered and
- // take place before the change to mUpdateSeq is commited..
- int32_t tmp = mUpdateSeq | 0x80000000;
- android_atomic_acquire_store(tmp, &mUpdateSeq);
-
- // Update mFront and mNextRdPTS
- mFront = newFront;
- mNextRdPTS = newNextRdPTS;
-
- // We are finished with the update. Compute the next sequnce number (which
- // should be the old sequence number, plus one, and with the MSB cleared)
- // and then store it in mUpdateSeq using an atomic store with a "release"
- // barrier so our update operations cannot be re-ordered past the update of
- // the sequence number.
- tmp = (tmp + 1) & 0x7FFFFFFF;
- android_atomic_release_store(tmp, &mUpdateSeq);
-}
-
-void MonoPipe::observeFrontAndNRPTS(int32_t *outFront, int64_t *outNextRdPTS)
-{
- // Perform an atomic observation of mFront and mNextRdPTS. Basically,
- // atomically observe the sequence number, then observer the variables, then
- // atomically observe the sequence number again. If the two observations of
- // the sequence number match, and the update-in-progress bit was not set,
- // then we know we have a successful atomic observation. Otherwise, we loop
- // around and try again.
- //
- // Note, it is very important that the observer be a lower priority thread
- // than the updater. If the updater is lower than the observer, or they are
- // the same priority and running with SCHED_FIFO (implying that quantum
- // based premption is disabled) then we run the risk of deadlock.
- int32_t seqOne, seqTwo;
-
- do {
- seqOne = android_atomic_acquire_load(&mUpdateSeq);
- *outFront = mFront;
- *outNextRdPTS = mNextRdPTS;
- seqTwo = android_atomic_release_load(&mUpdateSeq);
- } while ((seqOne != seqTwo) || (seqOne & 0x80000000));
-}
-
-int64_t MonoPipe::offsetTimestampByAudioFrames(int64_t ts, size_t audFrames)
-{
- if (0 == mSamplesToLocalTime.a_to_b_denom)
- return AudioBufferProvider::kInvalidPTS;
-
- if (ts == AudioBufferProvider::kInvalidPTS)
- return AudioBufferProvider::kInvalidPTS;
-
- int64_t frame_lt_duration;
- if (!mSamplesToLocalTime.doForwardTransform(audFrames,
- &frame_lt_duration)) {
- // This should never fail, but if there is a bug which is causing it
- // to fail, this message would probably end up flooding the logs
- // because the conversion would probably fail forever. Log the
- // error, but then zero out the ratio in the linear transform so
- // that we don't try to do any conversions from now on. This
- // MonoPipe's getNextWriteTimestamp is now broken for good.
- ALOGE("Overflow when attempting to convert %zu audio frames to"
- " duration in local time. getNextWriteTimestamp will fail from"
- " now on.", audFrames);
- mSamplesToLocalTime.a_to_b_numer = 0;
- mSamplesToLocalTime.a_to_b_denom = 0;
- return AudioBufferProvider::kInvalidPTS;
- }
-
- return ts + frame_lt_duration;
-}
-
void MonoPipe::shutdown(bool newState)
{
mIsShutdown = newState;
diff --git a/media/libnbaio/MonoPipeReader.cpp b/media/libnbaio/MonoPipeReader.cpp
index e4d3ed8..7e09544 100644
--- a/media/libnbaio/MonoPipeReader.cpp
+++ b/media/libnbaio/MonoPipeReader.cpp
@@ -43,25 +43,11 @@
return ret;
}
-ssize_t MonoPipeReader::read(void *buffer, size_t count, int64_t readPTS)
+ssize_t MonoPipeReader::read(void *buffer, size_t count)
{
- // Compute the "next read PTS" and cache it. Callers of read pass a read
- // PTS indicating the local time for which they are requesting data along
- // with a count (which is the number of audio frames they are going to
- // ultimately pass to the next stage of the pipeline). Offsetting readPTS
- // by the duration of count will give us the readPTS which will be passed to
- // us next time, assuming they system continues to operate in steady state
- // with no discontinuities. We stash this value so it can be used by the
- // MonoPipe writer to imlement getNextWriteTimestamp.
- int64_t nextReadPTS;
- nextReadPTS = mPipe->offsetTimestampByAudioFrames(readPTS, count);
-
// count == 0 is unlikely and not worth checking for explicitly; will be handled automatically
ssize_t red = availableToRead();
if (CC_UNLIKELY(red <= 0)) {
- // Uh-oh, looks like we are underflowing. Update the next read PTS and
- // get out.
- mPipe->updateFrontAndNRPTS(mPipe->mFront, nextReadPTS);
return red;
}
if (CC_LIKELY((size_t) red > count)) {
@@ -80,7 +66,7 @@
memcpy((char *) buffer + (part1 * mFrameSize), mPipe->mBuffer, part2 * mFrameSize);
}
}
- mPipe->updateFrontAndNRPTS(red + mPipe->mFront, nextReadPTS);
+ android_atomic_release_store(red + mPipe->mFront, &mPipe->mFront);
mFramesRead += red;
}
return red;
diff --git a/media/libnbaio/NBAIO.cpp b/media/libnbaio/NBAIO.cpp
index d641e74..1cb4410 100644
--- a/media/libnbaio/NBAIO.cpp
+++ b/media/libnbaio/NBAIO.cpp
@@ -97,8 +97,7 @@
}
// This is a default implementation; it is expected that subclasses will optimize this.
-ssize_t NBAIO_Source::readVia(readVia_t via, size_t total, void *user,
- int64_t readPTS, size_t block)
+ssize_t NBAIO_Source::readVia(readVia_t via, size_t total, void *user, size_t block)
{
if (!mNegotiated) {
return (ssize_t) NEGOTIATE;
@@ -117,11 +116,11 @@
if (count > block) {
count = block;
}
- ssize_t ret = read(buffer, count, readPTS);
+ ssize_t ret = read(buffer, count);
if (ret > 0) {
ALOG_ASSERT((size_t) ret <= count);
size_t maxRet = ret;
- ret = via(user, buffer, maxRet, readPTS);
+ ret = via(user, buffer, maxRet);
if (ret > 0) {
ALOG_ASSERT((size_t) ret <= maxRet);
accumulator += ret;
diff --git a/media/libnbaio/PipeReader.cpp b/media/libnbaio/PipeReader.cpp
index c8e4953..b096903 100644
--- a/media/libnbaio/PipeReader.cpp
+++ b/media/libnbaio/PipeReader.cpp
@@ -59,7 +59,7 @@
return avail;
}
-ssize_t PipeReader::read(void *buffer, size_t count, int64_t readPTS __unused)
+ssize_t PipeReader::read(void *buffer, size_t count)
{
ssize_t avail = availableToRead();
if (CC_UNLIKELY(avail <= 0)) {
diff --git a/media/libnbaio/SourceAudioBufferProvider.cpp b/media/libnbaio/SourceAudioBufferProvider.cpp
index 04c42c9..dc01c0e 100644
--- a/media/libnbaio/SourceAudioBufferProvider.cpp
+++ b/media/libnbaio/SourceAudioBufferProvider.cpp
@@ -45,7 +45,7 @@
free(mAllocated);
}
-status_t SourceAudioBufferProvider::getNextBuffer(Buffer *buffer, int64_t pts)
+status_t SourceAudioBufferProvider::getNextBuffer(Buffer *buffer)
{
ALOG_ASSERT(buffer != NULL && buffer->frameCount > 0 && mGetCount == 0);
// any leftover data available?
@@ -73,7 +73,7 @@
}
{
// read from source
- ssize_t actual = mSource->read(mAllocated, buffer->frameCount, pts);
+ ssize_t actual = mSource->read(mAllocated, buffer->frameCount);
if (actual > 0) {
ALOG_ASSERT((size_t) actual <= buffer->frameCount);
mOffset = 0;