diff --git a/src/media/audio/opensl/audio_player.cpp b/src/media/audio/opensl/audio_player.cpp index b80394e5f46abce46f23cdeddf4332c1e9ee5cb6..dfd7b3be5ef755484236d6e61ca97b46d55c1bc9 100644 --- a/src/media/audio/opensl/audio_player.cpp +++ b/src/media/audio/opensl/audio_player.cpp @@ -40,6 +40,8 @@ void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *ctx) { (static_cast<AudioPlayer *>(ctx))->processSLCallback(bq); } void AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) { + std::lock_guard<std::mutex> lk(m_); + // retrieve the finished device buf and put onto the free queue // so recorder could re-use it sample_buf *buf; diff --git a/src/media/audio/opensl/audio_player.h b/src/media/audio/opensl/audio_player.h index 0e9383c8963053979fe2324f929511e220349963..7fc470b8c67a9f5920cc14fe591313f09dce3f65 100644 --- a/src/media/audio/opensl/audio_player.h +++ b/src/media/audio/opensl/audio_player.h @@ -58,6 +58,7 @@ public: void registerCallback(EngineCallback cb) {callback_ = cb;} size_t dbgGetDevBufCount(); + std::mutex m_; std::atomic_bool waiting_ {false}; }; diff --git a/src/media/audio/opensl/opensllayer.cpp b/src/media/audio/opensl/opensllayer.cpp index 445b0603f53ac2eb3030b7345382b1e42db5697b..3a58dc63b51095014cc6a017722a56b72dc9ac25 100644 --- a/src/media/audio/opensl/opensllayer.cpp +++ b/src/media/audio/opensl/opensllayer.cpp @@ -302,14 +302,14 @@ OpenSLLayer::startAudioPlayback() while (player_ || ringtone_) { playCv.wait_for(lck, std::chrono::seconds(1)); if (player_ && player_->waiting_) { - //std::lock_guard<std::mutex> lk(player_->m_); + std::lock_guard<std::mutex> lk(player_->m_); engineServicePlay(false); auto n = playBufQueue_.size(); if (n >= PLAY_KICKSTART_BUFFER_COUNT) player_->playAudioBuffers(n); } if (ringtone_ && ringtone_->waiting_) { - //std::lock_guard<std::mutex> lk(ringtone_->m_); + std::lock_guard<std::mutex> lk(ringtone_->m_); engineServiceRing(false); auto n = ringBufQueue_.size(); if (n >= PLAY_KICKSTART_BUFFER_COUNT)