[meta/buffer]: Fix usage after service is destoyed

When C++ global destructor is called MppBufferService and MppMetaService
maybe be called before other destructors which may call mpp_buffer_put
and mpp_meta_put. So we mark finished flag after ~MppBufferService and
~MppMetaService is call and so not free corresponding data again.

This case usually happens when user call exit() directly.

Change-Id: I997c49b095e443b061fca230587b6216f710d31c
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen
2020-10-19 17:38:24 +08:00
parent fa3478c309
commit 0520b7d35d
2 changed files with 13 additions and 1 deletions

View File

@@ -75,6 +75,7 @@ private:
RK_U32 group_id;
RK_U32 group_count;
RK_U32 finalizing;
RK_U32 finished;
// misc group for internal / externl buffer with different type
MppBufferGroupImpl *misc[MPP_BUFFER_MODE_BUTT][MPP_BUFFER_TYPE_BUTT];
@@ -604,6 +605,7 @@ MppBufferService::MppBufferService()
: group_id(0),
group_count(0),
finalizing(0),
finished(0),
misc_count(0)
{
RK_S32 i, j;
@@ -655,6 +657,7 @@ MppBufferService::~MppBufferService()
deinit_buffer_no_lock(pos, __FUNCTION__);
}
}
finished = 1;
}
RK_U32 MppBufferService::get_group_id()
@@ -745,6 +748,9 @@ void MppBufferService::set_misc(MppBufferMode mode, MppBufferType type, MppBuffe
void MppBufferService::put_group(MppBufferGroupImpl *p)
{
if (finished)
return ;
buffer_group_add_log(p, NULL, GRP_RELEASE, __FUNCTION__);
// remove unused list