handle audio render mode callback start stream crash

Signed-off-by: Sulav Mulmi <sulav.mulmi@huawei.com>
This commit is contained in:
Sulav Mulmi
2022-07-06 16:51:33 +05:30
parent 48d6dc0dc2
commit 9aa191a3b3
@@ -462,6 +462,15 @@ bool AudioStream::PauseAudioStream()
readThread_->join();
}
}
// Ends the WriteBuffers thread
if (renderMode_ == RENDER_MODE_CALLBACK) {
isReadyToWrite_ = false;
if (writeThread_ && writeThread_->joinable()) {
writeThread_->join();
}
}
while (isReadInProgress_ || isWriteInProgress_) {
std::this_thread::sleep_for(std::chrono::microseconds(READ_WRITE_WAIT_TIME_IN_US));
}
@@ -473,11 +482,6 @@ bool AudioStream::PauseAudioStream()
return false;
}
// Ends the WriteBuffers thread
if (renderMode_ == RENDER_MODE_CALLBACK) {
isReadyToWrite_ = false;
}
AUDIO_INFO_LOG("PauseAudioStream SUCCESS");
if (audioStreamTracker_) {
@@ -508,6 +512,15 @@ bool AudioStream::StopAudioStream()
readThread_->join();
}
}
// Ends the WriteBuffers thread
if (renderMode_ == RENDER_MODE_CALLBACK) {
isReadyToWrite_ = false;
if (writeThread_ && writeThread_->joinable()) {
writeThread_->join();
}
}
while (isReadInProgress_ || isWriteInProgress_) {
std::this_thread::sleep_for(std::chrono::microseconds(READ_WRITE_WAIT_TIME_IN_US));
}
@@ -519,11 +532,6 @@ bool AudioStream::StopAudioStream()
return false;
}
// Ends the WriteBuffers thread
if (renderMode_ == RENDER_MODE_CALLBACK) {
isReadyToWrite_ = false;
}
AUDIO_INFO_LOG("StopAudioStream SUCCESS");
if (audioStreamTracker_) {