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) {
(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;
......
......@@ -58,6 +58,7 @@ public:
void registerCallback(EngineCallback cb) {callback_ = cb;}
size_t dbgGetDevBufCount();
std::mutex m_;
std::atomic_bool waiting_ {false};
};
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment