diff options
author | Andy Hung <hunga@google.com> | 2015-03-29 01:13:58 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-04-08 15:55:46 -0700 |
commit | 73c02e4277b399c2ec1555d32b6ad5df23bb83dc (patch) | |
tree | c42d75e42eda5b09915c0962107083f1c55dc74a /services/audioflinger/Threads.h | |
parent | 97a893eb34f8687485c88eaf15917974a203f20b (diff) | |
download | frameworks_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.h | 33 |
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 |