Fixed crash (for double-delete) in unloadSampleData().
diff --git a/samples/iolib/src/main/cpp/player/SampleBuffer.cpp b/samples/iolib/src/main/cpp/player/SampleBuffer.cpp
index 0f8faef..42078b6 100644
--- a/samples/iolib/src/main/cpp/player/SampleBuffer.cpp
+++ b/samples/iolib/src/main/cpp/player/SampleBuffer.cpp
@@ -34,7 +34,9 @@
}
void SampleBuffer::unloadSampleData() {
- delete[] mSampleData;
+ if (mSampleData != nullptr) {
+ delete[] mSampleData;
+ }
mNumSamples = 0;
}
diff --git a/samples/iolib/src/main/cpp/player/SimpleMultiPlayer.cpp b/samples/iolib/src/main/cpp/player/SimpleMultiPlayer.cpp
index 4313668..b9a6859 100644
--- a/samples/iolib/src/main/cpp/player/SimpleMultiPlayer.cpp
+++ b/samples/iolib/src/main/cpp/player/SimpleMultiPlayer.cpp
@@ -142,8 +142,9 @@
void SimpleMultiPlayer::unloadSampleData() {
__android_log_print(ANDROID_LOG_INFO, TAG, "unloadSampleData()");
+ resetAll();
+
for (int32_t bufferIndex = 0; bufferIndex < mNumSampleBuffers; bufferIndex++) {
- mSampleBuffers[bufferIndex]->unloadSampleData();
delete mSampleBuffers[bufferIndex];
delete mSampleSources[bufferIndex];
}