Remove TimedAudioTrack and associated code
Bug: 8278435
Change-Id: I095c1a4888e645e14d93b0b15fbef4524a831ca1
diff --git a/include/media/nbaio/AudioBufferProviderSource.h b/include/media/nbaio/AudioBufferProviderSource.h
index b16e20a..4747dcf 100644
--- a/include/media/nbaio/AudioBufferProviderSource.h
+++ b/include/media/nbaio/AudioBufferProviderSource.h
@@ -42,9 +42,8 @@
//virtual size_t framesOverrun();
//virtual size_t overruns();
virtual ssize_t availableToRead();
- virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
- virtual ssize_t readVia(readVia_t via, size_t total, void *user,
- int64_t readPTS, size_t block);
+ virtual ssize_t read(void *buffer, size_t count);
+ virtual ssize_t readVia(readVia_t via, size_t total, void *user, size_t block);
private:
AudioBufferProvider * const mProvider;
diff --git a/include/media/nbaio/AudioStreamInSource.h b/include/media/nbaio/AudioStreamInSource.h
index 5169f1e..eaea63c 100644
--- a/include/media/nbaio/AudioStreamInSource.h
+++ b/include/media/nbaio/AudioStreamInSource.h
@@ -45,7 +45,7 @@
// FIXME Use an audio HAL API to query the buffer filling status when it's available.
virtual ssize_t availableToRead() { return mStreamBufferSizeBytes / mFrameSize; }
- virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
+ virtual ssize_t read(void *buffer, size_t count);
// NBAIO_Sink end
diff --git a/include/media/nbaio/AudioStreamOutSink.h b/include/media/nbaio/AudioStreamOutSink.h
index 9949b88..0998d45 100644
--- a/include/media/nbaio/AudioStreamOutSink.h
+++ b/include/media/nbaio/AudioStreamOutSink.h
@@ -47,11 +47,6 @@
virtual ssize_t write(const void *buffer, size_t count);
- // AudioStreamOutSink wraps a HAL's output stream. Its
- // getNextWriteTimestamp method is simply a passthru to the HAL's underlying
- // implementation of GNWT (if any)
- virtual status_t getNextWriteTimestamp(int64_t *timestamp);
-
virtual status_t getTimestamp(AudioTimestamp& timestamp);
// NBAIO_Sink end
diff --git a/include/media/nbaio/MonoPipe.h b/include/media/nbaio/MonoPipe.h
index b09b35f..df9cafe 100644
--- a/include/media/nbaio/MonoPipe.h
+++ b/include/media/nbaio/MonoPipe.h
@@ -18,7 +18,6 @@
#define ANDROID_AUDIO_MONO_PIPE_H
#include <time.h>
-#include <utils/LinearTransform.h>
#include "NBAIO.h"
#include <media/SingleStateQueue.h>
@@ -60,20 +59,6 @@
virtual ssize_t write(const void *buffer, size_t count);
//virtual ssize_t writeVia(writeVia_t via, size_t total, void *user, size_t block);
- // MonoPipe's implementation of getNextWriteTimestamp works in conjunction
- // with MonoPipeReader. Every time a MonoPipeReader reads from the pipe, it
- // receives a "readPTS" indicating the point in time for which the reader
- // would like to read data. This "last read PTS" is offset by the amt of
- // data the reader is currently mixing and then cached cached along with the
- // updated read pointer. This cached value is the local time for which the
- // reader is going to request data next time it reads data (assuming we are
- // in steady state and operating with no underflows). Writers to the
- // MonoPipe who would like to know when their next write operation will hit
- // the speakers can call getNextWriteTimestamp which will return the value
- // of the last read PTS plus the duration of the amt of data waiting to be
- // read in the MonoPipe.
- virtual status_t getNextWriteTimestamp(int64_t *timestamp);
-
// average number of frames present in the pipe under normal conditions.
// See throttling mechanism in MonoPipe::write()
size_t getAvgFrames() const { return mSetpoint; }
@@ -95,43 +80,21 @@
status_t getTimestamp(AudioTimestamp& timestamp);
private:
- // A pair of methods and a helper variable which allows the reader and the
- // writer to update and observe the values of mFront and mNextRdPTS in an
- // atomic lock-less fashion.
- //
- // :: Important ::
- // Two assumptions must be true in order for this lock-less approach to
- // function properly on all systems. First, there may only be one updater
- // thread in the system. Second, the updater thread must be running at a
- // strictly higher priority than the observer threads. Currently, both of
- // these assumptions are true. The only updater is always a single
- // FastMixer thread (which runs with SCHED_FIFO/RT priority while the only
- // observer is always an AudioFlinger::PlaybackThread running with
- // traditional (non-RT) audio priority.
- void updateFrontAndNRPTS(int32_t newFront, int64_t newNextRdPTS);
- void observeFrontAndNRPTS(int32_t *outFront, int64_t *outNextRdPTS);
- volatile int32_t mUpdateSeq;
-
const size_t mReqFrames; // as requested in constructor, unrounded
const size_t mMaxFrames; // always a power of 2
void * const mBuffer;
// mFront and mRear will never be separated by more than mMaxFrames.
// 32-bit overflow is possible if the pipe is active for a long time, but if that happens it's
// safe because we "&" with (mMaxFrames-1) at end of computations to calculate a buffer index.
- volatile int32_t mFront; // written by the reader with updateFrontAndNRPTS, observed by
- // the writer with observeFrontAndNRPTS
+ volatile int32_t mFront; // written by reader with android_atomic_release_store,
+ // read by writer with android_atomic_acquire_load
volatile int32_t mRear; // written by writer with android_atomic_release_store,
// read by reader with android_atomic_acquire_load
- volatile int64_t mNextRdPTS; // written by the reader with updateFrontAndNRPTS, observed by
- // the writer with observeFrontAndNRPTS
bool mWriteTsValid; // whether mWriteTs is valid
struct timespec mWriteTs; // time that the previous write() completed
size_t mSetpoint; // target value for pipe fill depth
const bool mWriteCanBlock; // whether write() should block if the pipe is full
- int64_t offsetTimestampByAudioFrames(int64_t ts, size_t audFrames);
- LinearTransform mSamplesToLocalTime;
-
bool mIsShutdown; // whether shutdown(true) was called, no barriers are needed
AudioTimestampSingleStateQueue::Shared mTimestampShared;
diff --git a/include/media/nbaio/MonoPipeReader.h b/include/media/nbaio/MonoPipeReader.h
index 78fe867..4a7c3c5 100644
--- a/include/media/nbaio/MonoPipeReader.h
+++ b/include/media/nbaio/MonoPipeReader.h
@@ -47,7 +47,7 @@
virtual ssize_t availableToRead();
- virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
+ virtual ssize_t read(void *buffer, size_t count);
virtual void onTimestamp(const AudioTimestamp& timestamp);
diff --git a/include/media/nbaio/NBAIO.h b/include/media/nbaio/NBAIO.h
index d9bbc8d..2f7e291 100644
--- a/include/media/nbaio/NBAIO.h
+++ b/include/media/nbaio/NBAIO.h
@@ -79,8 +79,7 @@
// Callbacks used by NBAIO_Sink::writeVia() and NBAIO_Source::readVia() below.
typedef ssize_t (*writeVia_t)(void *user, void *buffer, size_t count);
-typedef ssize_t (*readVia_t)(void *user, const void *buffer,
- size_t count, int64_t readPTS);
+typedef ssize_t (*readVia_t)(void *user, const void *buffer, size_t count);
// Check whether an NBAIO_Format is valid
bool Format_isValid(const NBAIO_Format& format);
@@ -210,21 +209,6 @@
// < 0 status_t error occurred prior to the first frame transfer during this callback.
virtual ssize_t writeVia(writeVia_t via, size_t total, void *user, size_t block = 0);
- // Get the time (on the LocalTime timeline) at which the first frame of audio of the next write
- // operation to this sink will be eventually rendered by the HAL.
- // Inputs:
- // ts A pointer pointing to the int64_t which will hold the result.
- // Return value:
- // OK Everything went well, *ts holds the time at which the first audio frame of the next
- // write operation will be rendered, or AudioBufferProvider::kInvalidPTS if this sink
- // does not know the answer for some reason. Sinks which eventually lead to a HAL
- // which implements get_next_write_timestamp may return Invalid temporarily if the DMA
- // output of the audio driver has not started yet. Sinks which lead to a HAL which
- // does not implement get_next_write_timestamp, or which don't lead to a HAL at all,
- // will always return kInvalidPTS.
- // <other> Something unexpected happened internally. Check the logs and start debugging.
- virtual status_t getNextWriteTimestamp(int64_t *ts) { return INVALID_OPERATION; }
-
// Returns NO_ERROR if a timestamp is available. The timestamp includes the total number
// of frames presented to an external observer, together with the value of CLOCK_MONOTONIC
// as of this presentation count. The timestamp parameter is undefined if error is returned.
@@ -271,8 +255,6 @@
// Inputs:
// buffer Non-NULL destination buffer owned by consumer.
// count Maximum number of frames to transfer.
- // readPTS The presentation time (on the LocalTime timeline) for which data
- // is being requested, or kInvalidPTS if not known.
// Return value:
// > 0 Number of frames successfully transferred prior to first error.
// = 0 Count was zero.
@@ -282,7 +264,7 @@
// WOULD_BLOCK No frames can be transferred without blocking.
// OVERRUN read() has not been called frequently enough, or with enough frames to keep up.
// One or more frames were lost due to overrun, try again to read more recent data.
- virtual ssize_t read(void *buffer, size_t count, int64_t readPTS) = 0;
+ virtual ssize_t read(void *buffer, size_t count) = 0;
// Transfer data from source using a series of callbacks. More suitable for zero-fill,
// synthesis, and non-contiguous transfers (e.g. circular buffer or readv).
@@ -291,8 +273,6 @@
// total Estimate of the number of frames the consumer desires. This is an estimate,
// and it can consume a different number of frames during the series of callbacks.
// user Arbitrary void * reserved for data consumer.
- // readPTS The presentation time (on the LocalTime timeline) for which data
- // is being requested, or kInvalidPTS if not known.
// block Number of frames per block, that is a suggested value for 'count' in each callback.
// Zero means no preference. This parameter is a hint only, and may be ignored.
// Return value:
@@ -315,8 +295,7 @@
// > 0 Number of frames successfully transferred during this callback prior to first error.
// = 0 Count was zero.
// < 0 status_t error occurred prior to the first frame transfer during this callback.
- virtual ssize_t readVia(readVia_t via, size_t total, void *user,
- int64_t readPTS, size_t block = 0);
+ virtual ssize_t readVia(readVia_t via, size_t total, void *user, size_t block = 0);
// Invoked asynchronously by corresponding sink when a new timestamp is available.
// Default implementation ignores the timestamp.
diff --git a/include/media/nbaio/PipeReader.h b/include/media/nbaio/PipeReader.h
index 350e6ab..398353b 100644
--- a/include/media/nbaio/PipeReader.h
+++ b/include/media/nbaio/PipeReader.h
@@ -45,7 +45,7 @@
virtual ssize_t availableToRead();
- virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
+ virtual ssize_t read(void *buffer, size_t count);
// NBAIO_Source end
diff --git a/include/media/nbaio/SourceAudioBufferProvider.h b/include/media/nbaio/SourceAudioBufferProvider.h
index daf6bc3..29172e1 100644
--- a/include/media/nbaio/SourceAudioBufferProvider.h
+++ b/include/media/nbaio/SourceAudioBufferProvider.h
@@ -31,7 +31,7 @@
virtual ~SourceAudioBufferProvider();
// AudioBufferProvider interface
- virtual status_t getNextBuffer(Buffer *buffer, int64_t pts);
+ virtual status_t getNextBuffer(Buffer *buffer);
virtual void releaseBuffer(Buffer *buffer);
// ExtendedAudioBufferProvider interface