Skip to content

Commit

Permalink
audiolite/mp3dec: Fix freeze on audiolite_mp3dec component
Browse files Browse the repository at this point in the history
Fix a freeze issue on audiolite_mp3dec component when it started
with user built mp3dec worker.
  • Loading branch information
SPRESENSE committed Nov 5, 2024
1 parent e930717 commit 52ff862
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
17 changes: 5 additions & 12 deletions sdk/modules/audiolite/src/components/al_mp3dec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void audiolite_mp3dec::decode_runner()

while (_is_thrdrun)
{
if (_isplay)
if (_isplay && _worker_booted)
{
audiolite_memapbuf *mem =
(audiolite_memapbuf *)_omempool->allocate();
Expand Down Expand Up @@ -216,18 +216,9 @@ int audiolite_mp3dec::handle_mesage(al_comm_msghdr_t hdr,
}
}

for (int i = 0; i < thiz->_outq.get_qsize(); i++)
{
mem = (audiolite_memapbuf *)thiz->_omempool->allocate();
if (mem)
{
thiz->_outq.push(mem);
alworker_inject_omem(thiz->_worker.getwtask(), mem);
}
}

alworker_send_startframe(thiz->_worker.getwtask());
alworker_send_start(thiz->_worker.getwtask());
thiz->_worker_booted = true; /* This makes start injection of omem */
}
else if (CHECK_HDR(hdr, SYS, SYS_ERR))
{
Expand All @@ -254,7 +245,8 @@ audiolite_mp3dec::audiolite_mp3dec() : audiolite_decoder("mp3decomem",
CONFIG_ALMP3DEC_INJECTSTACK),
_omempool(NULL), _worker(),
_inq(SPRMP3_FRAMEMEM_QSIZE / 2),
_outq(SPRMP3_OUTMEM_QSIZE / 2), _frame_eof(false)
_outq(SPRMP3_OUTMEM_QSIZE / 2), _frame_eof(false),
_worker_booted(false)
{
_worker.set_msghandler(audiolite_mp3dec::handle_mesage, this);
}
Expand Down Expand Up @@ -293,6 +285,7 @@ int audiolite_mp3dec::stop_decode()
}
_inq.disable();
_worker.terminate_worker();
_worker_booted = false;
_outq.disable();

return OK;
Expand Down
1 change: 1 addition & 0 deletions sdk/modules/include/audiolite/al_mp3dec.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class audiolite_mp3dec : public audiolite_decoder
audiolite_workermemq _inq;
audiolite_workermemq _outq;
bool _frame_eof;
volatile bool _worker_booted;

static int handle_mesage(al_comm_msghdr_t hdr,
al_comm_msgopt_t *opt, void *arg);
Expand Down

0 comments on commit 52ff862

Please sign in to comment.