Skip to content
Snippets Groups Projects
Commit 1ccd3442 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

opensl: bring back mutex

Change-Id: Iede9cf73b9f55e5aaa1e6d60da30362475656362
parent e2fb50a8
Branches
No related tags found
No related merge requests found
...@@ -40,6 +40,8 @@ void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *ctx) { ...@@ -40,6 +40,8 @@ void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *ctx) {
(static_cast<AudioPlayer *>(ctx))->processSLCallback(bq); (static_cast<AudioPlayer *>(ctx))->processSLCallback(bq);
} }
void AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) { void AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) {
std::lock_guard<std::mutex> lk(m_);
// retrieve the finished device buf and put onto the free queue // retrieve the finished device buf and put onto the free queue
// so recorder could re-use it // so recorder could re-use it
sample_buf *buf; sample_buf *buf;
......
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
void registerCallback(EngineCallback cb) {callback_ = cb;} void registerCallback(EngineCallback cb) {callback_ = cb;}
size_t dbgGetDevBufCount(); size_t dbgGetDevBufCount();
std::mutex m_;
std::atomic_bool waiting_ {false}; std::atomic_bool waiting_ {false};
}; };
......
...@@ -302,14 +302,14 @@ OpenSLLayer::startAudioPlayback() ...@@ -302,14 +302,14 @@ OpenSLLayer::startAudioPlayback()
while (player_ || ringtone_) { while (player_ || ringtone_) {
playCv.wait_for(lck, std::chrono::seconds(1)); playCv.wait_for(lck, std::chrono::seconds(1));
if (player_ && player_->waiting_) { if (player_ && player_->waiting_) {
//std::lock_guard<std::mutex> lk(player_->m_); std::lock_guard<std::mutex> lk(player_->m_);
engineServicePlay(false); engineServicePlay(false);
auto n = playBufQueue_.size(); auto n = playBufQueue_.size();
if (n >= PLAY_KICKSTART_BUFFER_COUNT) if (n >= PLAY_KICKSTART_BUFFER_COUNT)
player_->playAudioBuffers(n); player_->playAudioBuffers(n);
} }
if (ringtone_ && ringtone_->waiting_) { if (ringtone_ && ringtone_->waiting_) {
//std::lock_guard<std::mutex> lk(ringtone_->m_); std::lock_guard<std::mutex> lk(ringtone_->m_);
engineServiceRing(false); engineServiceRing(false);
auto n = ringBufQueue_.size(); auto n = ringBufQueue_.size();
if (n >= PLAY_KICKSTART_BUFFER_COUNT) if (n >= PLAY_KICKSTART_BUFFER_COUNT)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment