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

opensl: handle Enqueue failure

Change-Id: I4bdef901c2a2bc07dc1a9263eb0a9796655c051a
parent dabccb4d
Branches
No related tags found
No related merge requests found
...@@ -86,11 +86,12 @@ AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq) ...@@ -86,11 +86,12 @@ AudioPlayer::processSLCallback(SLAndroidSimpleBufferQueueItf bq)
playQueue_->pop(); playQueue_->pop();
} }
if (devShadowQueue_.size() == 0) { if (devShadowQueue_.size() == 0) {
// JAMI_ERR("AudioPlayer: nothing to play %zu %zu %zu", freeQueue_->size(),
// playQueue_->size(), devShadowQueue_.size());
for (int i = 0; i < DEVICE_SHADOW_BUFFER_QUEUE_LEN; i++) { for (int i = 0; i < DEVICE_SHADOW_BUFFER_QUEUE_LEN; i++) {
(*bq)->Enqueue(bq, silentBuf_.buf_, silentBuf_.size_); if ((*bq)->Enqueue(bq, silentBuf_.buf_, silentBuf_.size_) == SL_RESULT_SUCCESS) {
devShadowQueue_.push(&silentBuf_); devShadowQueue_.push(&silentBuf_);
} else {
JAMI_ERR("Enqueue silentBuf_ failed");
}
} }
} }
} }
...@@ -208,9 +209,12 @@ AudioPlayer::start() ...@@ -208,9 +209,12 @@ AudioPlayer::start()
result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_STOPPED); result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_STOPPED);
SLASSERT(result); SLASSERT(result);
SLASSERT(
(*playBufferQueueItf_)->Enqueue(playBufferQueueItf_, silentBuf_.buf_, silentBuf_.size_));
devShadowQueue_.push(&silentBuf_); devShadowQueue_.push(&silentBuf_);
result = (*playBufferQueueItf_)->Enqueue(playBufferQueueItf_, silentBuf_.buf_, silentBuf_.size_);
if (result != SL_RESULT_SUCCESS) {
JAMI_ERR("Enqueue silentBuf_ failed, result = %d", result);
devShadowQueue_.pop();
}
lk.unlock(); lk.unlock();
result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_PLAYING); result = (*playItf_)->SetPlayState(playItf_, SL_PLAYSTATE_PLAYING);
......
...@@ -167,7 +167,8 @@ OpenSLLayer::initAudioEngine() ...@@ -167,7 +167,8 @@ OpenSLLayer::initAudioEngine()
SLASSERT((*engineObject_)->Realize(engineObject_, SL_BOOLEAN_FALSE)); SLASSERT((*engineObject_)->Realize(engineObject_, SL_BOOLEAN_FALSE));
SLASSERT((*engineObject_)->GetInterface(engineObject_, SL_IID_ENGINE, &engineInterface_)); SLASSERT((*engineObject_)->GetInterface(engineObject_, SL_IID_ENGINE, &engineInterface_));
uint32_t bufSize = hardwareBuffSize_ * hardwareFormat_.getBytesPerFrame(); size_t bufSize = hardwareBuffSize_ * hardwareFormat_.getBytesPerFrame();
JAMI_DBG("OpenSL init: using buffer of %u bytes to support %s with %zu samples per channel", bufSize, hardwareFormat_.toString().c_str(), hardwareBuffSize_);
bufs_ = allocateSampleBufs(BUF_COUNT * 3, bufSize); bufs_ = allocateSampleBufs(BUF_COUNT * 3, bufSize);
for (int i = 0; i < BUF_COUNT; i++) for (int i = 0; i < BUF_COUNT; i++)
freePlayBufQueue_.push(&bufs_[i]); freePlayBufQueue_.push(&bufs_[i]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment