Playback now handles any sample rate and channel combo.
Main stuff
- Delayed construction of audio player until after sample rate and
channels have been read from the first callback.
- Removed all sample rate and channels from outward facing api.
- Remove pause playing and prefetch duration and sample rate hacky code.
- Fixes handling of any sample rate by removing switch statement.
- Fixes a HORRIBLE bug introduced in last cl where I was creating the
callback context on the stack inside a method call, and using it a
pointer to it long after the object had been erased from the stack.
[worse yet: it still mostly worked fine!]
Other
- Fixes an obvious failure case of all tests - duh - I was calling setUp()
before setting the executor properly, so they were giving NPEs.
- Correct calculation of totalDuration now done on first decode callback.
- This will let us remove MediaPlayer from prepare() in follow up.
- Initializing the engine outside of the PlaybackRunnable, is cleaner.
- Adds static methods for reading duration and position, again so that
follow up can have accurate get current position rather than best guess.
- Buffers in use for decoding also not created until first decode callback.
- Introduces some wicked-cool OpenSL macro to log api calls, make the
api calls and check the result value.
Bug: 5048252
Bug: 5048257
Change-Id: I60705fa6c6ab29a35740f22bef76450e8c1d25a2
diff --git a/variablespeed/jni/jni_entry.cc b/variablespeed/jni/jni_entry.cc
index f7b1f2e..0069956 100644
--- a/variablespeed/jni/jni_entry.cc
+++ b/variablespeed/jni/jni_entry.cc
@@ -28,10 +28,10 @@
class MethodLog {
public:
explicit MethodLog(const char* name) : name_(name) {
- LOGD("+ %s", name);
+ LOGV("+ %s", name);
}
virtual ~MethodLog() {
- LOGD("- %s", name_);
+ LOGV("- %s", name_);
}
private:
@@ -75,13 +75,13 @@
return AudioEngine::GetEngine()->GetTotalDuration();
}
-JNI_METHOD(initializeEngine, void) (JNIEnv*, jclass, int channels,
- int sampleRate, int targetFrames, float windowDuration,
+JNI_METHOD(initializeEngine, void) (JNIEnv*, jclass,
+ int targetFrames, float windowDuration,
float windowOverlapDuration, size_t maxPlayBufferCount,
float initialRate, size_t decodeInitialSize, size_t decodeMaxSize,
size_t startPositionMillis) {
MethodLog _("initializeEngine");
- AudioEngine::SetEngine(new AudioEngine(channels, sampleRate, targetFrames,
+ AudioEngine::SetEngine(new AudioEngine(targetFrames,
windowDuration, windowOverlapDuration, maxPlayBufferCount, initialRate,
decodeInitialSize, decodeMaxSize, startPositionMillis));
}