summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Threads.h
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-03-29 01:13:58 -0700
committerAndy Hung <hunga@google.com>2015-04-08 15:55:46 -0700
commit73c02e4277b399c2ec1555d32b6ad5df23bb83dc (patch)
treec42d75e42eda5b09915c0962107083f1c55dc74a /services/audioflinger/Threads.h
parent97a893eb34f8687485c88eaf15917974a203f20b (diff)
downloadframeworks_av-73c02e4277b399c2ec1555d32b6ad5df23bb83dc.zip
frameworks_av-73c02e4277b399c2ec1555d32b6ad5df23bb83dc.tar.gz
frameworks_av-73c02e4277b399c2ec1555d32b6ad5df23bb83dc.tar.bz2
Improve ResamplerBufferProvider
Change-Id: I3cc3af221ad5797ff219d75227350733afa180db
Diffstat (limited to 'services/audioflinger/Threads.h')
-rw-r--r--services/audioflinger/Threads.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 053d2e7..27bc56b 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1036,17 +1036,46 @@ class RecordThread : public ThreadBase
public:
class RecordTrack;
+
+ /* The ResamplerBufferProvider is used to retrieve recorded input data from the
+ * RecordThread. It maintains local state on the relative position of the read
+ * position of the RecordTrack compared with the RecordThread.
+ */
class ResamplerBufferProvider : public AudioBufferProvider
- // derives from AudioBufferProvider interface for use by resampler
{
public:
- ResamplerBufferProvider(RecordTrack* recordTrack) : mRecordTrack(recordTrack) { }
+ ResamplerBufferProvider(RecordTrack* recordTrack) :
+ mRecordTrack(recordTrack),
+ mRsmpInUnrel(0), mRsmpInFront(0) { }
virtual ~ResamplerBufferProvider() { }
+
+ // called to set the ResamplerBufferProvider to head of the RecordThread data buffer,
+ // skipping any previous data read from the hal.
+ virtual void reset();
+
+ /* Synchronizes RecordTrack position with the RecordThread.
+ * Calculates available frames and handle overruns if the RecordThread
+ * has advanced faster than the ResamplerBufferProvider has retrieved data.
+ * TODO: why not do this for every getNextBuffer?
+ *
+ * Parameters
+ * framesAvailable: pointer to optional output size_t to store record track
+ * frames available.
+ * hasOverrun: pointer to optional boolean, returns true if track has overrun.
+ */
+
+ virtual void sync(size_t *framesAvailable = NULL, bool *hasOverrun = NULL);
+
// AudioBufferProvider interface
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts);
virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
private:
RecordTrack * const mRecordTrack;
+ size_t mRsmpInUnrel; // unreleased frames remaining from
+ // most recent getNextBuffer
+ // for debug only
+ int32_t mRsmpInFront; // next available frame
+ // rolling counter that is never cleared
};
/* The RecordBufferConverter is used for format, channel, and sample rate