Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion samples/powerplay/src/main/cpp/PowerPlayMultiPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void PowerPlayMultiPlayer::setupAudioStream(int32_t channelCount,
bool PowerPlayMultiPlayer::openStream(oboe::PerformanceMode performanceMode) {
__android_log_print(ANDROID_LOG_INFO, TAG, "openStream()");
mLastPerformanceMode = performanceMode;
mLastMMapEnabled = isMMapEnabled();

// Use shared_ptr to prevent use of a deleted callback.
mDataCallback = std::make_shared<MyDataCallback>(this);
Expand Down Expand Up @@ -132,7 +133,9 @@ void PowerPlayMultiPlayer::triggerDown(int32_t index, oboe::PerformanceMode perf
}

// If the performance mode has changed, we need to reopen the stream.
if (performanceMode != mLastPerformanceMode) {
// Also reopen if the user has changed the MMAP policy (enabled/disabled) since the stream was opened.
if (performanceMode != mLastPerformanceMode ||
isMMapEnabled() != mLastMMapEnabled) {
teardownAudioStream();

// Attempt here to reopen the stream with the new performance mode.
Expand Down
2 changes: 2 additions & 0 deletions samples/powerplay/src/main/cpp/PowerPlayMultiPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class PowerPlayMultiPlayer : public iolib::SimpleMultiPlayer {
std::shared_ptr<MyPresentationCallback> mPresentationCallback;

oboe::PerformanceMode mLastPerformanceMode;

bool mLastMMapEnabled;
};

#endif //SAMPLES_POWERPLAYMULTIPLAYER_H