mirror of
https://github.com/openharmony/multimedia_audio_standard.git
synced 2026-07-01 22:14:07 -04:00
handle audio render mode callback start stream crash
Signed-off-by: Sulav Mulmi <sulav.mulmi@huawei.com>
This commit is contained in:
@@ -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_) {
|
||||
|
||||
Reference in New Issue
Block a user