summaryrefslogtreecommitdiffstats
path: root/include/media/AudioResamplerPublic.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/AudioResamplerPublic.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/AudioResamplerPublic.h')
-rw-r--r--include/media/AudioResamplerPublic.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/media/AudioResamplerPublic.h b/include/media/AudioResamplerPublic.h
index 3c30148..07d946d 100644
--- a/include/media/AudioResamplerPublic.h
+++ b/include/media/AudioResamplerPublic.h
@@ -42,6 +42,8 @@
#define AUDIO_TIMESTRETCH_PITCH_MAX 2.0f
#define AUDIO_TIMESTRETCH_PITCH_NORMAL 1.0f
+// TODO: Consider putting these inlines into a class scope
+
// Returns the source frames needed to resample to destination frames. This is not a precise
// value and depends on the resampler (and possibly how it handles rounding internally).
// Nevertheless, this should be an upper bound on the requirements of the resampler.
@@ -66,4 +68,13 @@ static inline size_t destinationFramesPossible(size_t srcFrames, uint32_t srcSam
return dstFrames > 2 ? dstFrames - 2 : 0;
}
+static inline size_t sourceFramesNeededWithTimestretch(
+ uint32_t srcSampleRate, size_t dstFramesRequired, uint32_t dstSampleRate,
+ float speed) {
+ // required is the number of input frames the resampler needs
+ size_t required = sourceFramesNeeded(srcSampleRate, dstFramesRequired, dstSampleRate);
+ // to deliver this, the time stretcher requires:
+ return required * (double)speed + 1 + 1; // accounting for rounding dependencies
+}
+
#endif // ANDROID_AUDIO_RESAMPLER_PUBLIC_H