[mpp_dec]: Fix error on random reset call

When decoding is not finish (eos) and user call reset the hal thread
may not clear all the reference frame used in decoder and not clear
frame in display queue. There will be memory leak on this case.

This patch fix this error when user randomly call reset funciton on
decoding by flushing decoder and clearing display queue.

Change-Id: I68a12bd8cfb94a4d56d652a11695ef69f2a78825
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen 2018-10-19 14:55:18 +08:00
parent 6000ab1e8b
commit 1a388b0a94
2 changed files with 25 additions and 2 deletions

View file

@ -492,9 +492,11 @@ static void clear_slots_impl(MppBufSlotsImpl *impl)
MppBufSlotEntry *slot = (MppBufSlotEntry *)impl->slots;
RK_S32 i;
for (i = 0; i < impl->buf_count; i++, slot++) {
if (slot->status.on_used)
dump_slots(impl);
mpp_assert(!slot->status.on_used);
if (slot->status.on_used) {
dump_slots(impl);
mpp_buf_slot_reset(impl, i);
}
}
impl->used_count = 0;

View file

@ -393,6 +393,25 @@ static void mpp_dec_put_task(Mpp *mpp, DecTask *task)
task->hnd = NULL;
}
static void reset_hal_thread(Mpp *mpp)
{
MppDec *dec = mpp->mDec;
MppBufSlots frame_slots = dec->frame_slots;
HalDecTaskFlag flag;
RK_S32 index = -1;
/* when hal thread reset output all frames */
flag.val = 0;
mpp_dec_flush(dec);
mpp->mThreadHal->lock(THREAD_OUTPUT);
while (MPP_OK == mpp_buf_slot_dequeue(frame_slots, &index, QUEUE_DISPLAY)) {
mpp_dec_put_frame(mpp, index, flag);
mpp_buf_slot_clr_flag(frame_slots, index, SLOT_QUEUE_USE);
}
mpp->mThreadHal->unlock(THREAD_OUTPUT);
}
static MPP_RET try_proc_dec_task(Mpp *mpp, DecTask *task)
{
MppDec *dec = mpp->mDec;
@ -823,6 +842,8 @@ void *mpp_dec_hal_thread(void *data)
// process all task then do reset process
if (dec->reset_flag && !dec->hal_reset_done) {
AutoMutex ctrl_lock(hal->mutex(THREAD_CONTROL));
reset_hal_thread(mpp);
dec->hal_reset_done = 1;
hal->signal(THREAD_CONTROL);
continue;