summaryrefslogtreecommitdiffstats
path: root/include/media/AudioTrack.h
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-03-26 19:13:55 -0700
committerAndy Hung <hunga@google.com>2015-04-09 18:49:15 -0700
commit8edb8dc44b8a2f81bdb5db645b6b708548771a31 (patch)
tree663bda0f8a3d43894fa6d3d3f4283ed0df427f03 /include/media/AudioTrack.h
parentc5656cc900aeb4a705e27508dd82c70030a97709 (diff)
downloadframeworks_av-8edb8dc44b8a2f81bdb5db645b6b708548771a31.zip
frameworks_av-8edb8dc44b8a2f81bdb5db645b6b708548771a31.tar.gz
frameworks_av-8edb8dc44b8a2f81bdb5db645b6b708548771a31.tar.bz2
Add playback rate to AudioTrack
Bug: 19196501 Change-Id: I6411e1d3ce652b711a71a6d9df020cb5f60d4714
Diffstat (limited to 'include/media/AudioTrack.h')
-rw-r--r--include/media/AudioTrack.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index e7e0703..a06197f 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -359,6 +359,21 @@ public:
/* Return current source sample rate in Hz */
uint32_t getSampleRate() const;
+ /* Set source playback rate for timestretch
+ * 1.0 is normal speed: < 1.0 is slower, > 1.0 is faster
+ * 1.0 is normal pitch: < 1.0 is lower pitch, > 1.0 is higher pitch
+ *
+ * AUDIO_TIMESTRETCH_SPEED_MIN <= speed <= AUDIO_TIMESTRETCH_SPEED_MAX
+ * AUDIO_TIMESTRETCH_PITCH_MIN <= pitch <= AUDIO_TIMESTRETCH_PITCH_MAX
+ *
+ * Speed increases the playback rate of media, but does not alter pitch.
+ * Pitch increases the "tonal frequency" of media, but does not affect the playback rate.
+ */
+ status_t setPlaybackRate(float speed, float pitch);
+
+ /* Return current playback rate */
+ void getPlaybackRate(float *speed, float *pitch) const;
+
/* Enables looping and sets the start and end points of looping.
* Only supported for static buffer mode.
*
@@ -719,6 +734,9 @@ protected:
// increment mPosition by the delta of mServer, and return new value of mPosition
uint32_t updateAndGetPosition_l();
+ // check sample rate and speed is compatible with AudioTrack
+ bool isSampleRateSpeedAllowed_l(uint32_t sampleRate, float speed) const;
+
// Next 4 fields may be changed if IAudioTrack is re-created, but always != 0
sp<IAudioTrack> mAudioTrack;
sp<IMemory> mCblkMemory;
@@ -730,6 +748,8 @@ protected:
float mVolume[2];
float mSendLevel;
mutable uint32_t mSampleRate; // mutable because getSampleRate() can update it
+ float mSpeed; // timestretch: 1.0f for normal speed.
+ float mPitch; // timestretch: 1.0f for normal pitch.
size_t mFrameCount; // corresponds to current IAudioTrack, value is
// reported back by AudioFlinger to the client
size_t mReqFrameCount; // frame count to request the first or next time