diff options
author | Gu, Wangyi <wangyi.gu@intel.com> | 2013-02-20 14:36:22 +0800 |
---|---|---|
committer | Patrick Tjin <pattjin@google.com> | 2014-07-21 22:03:41 -0700 |
commit | d438ab4e1c4dde0b5e0aa7c44186137b2d2adaa5 (patch) | |
tree | 83a3b02db55d2902e23ba8a0f6de4e1b9f92d4b7 | |
parent | d84f1cd0a72565031a7bbb1f245bc4718e7fc33f (diff) | |
download | wrs_omxil_core-d438ab4e1c4dde0b5e0aa7c44186137b2d2adaa5.tar.gz |
OMX IL Core: add a lock to protect the component state
BZ: 86281
Root cause: two methods of state obtaining mechanism in omx il core design,
and two threads will access the same state variable, which isn't protectted.
Change-Id: I3bbb28a52b5e25a8b475433042d5b0152891be74
Signed-off-by: Gu, Wangyi <wangyi.gu@intel.com>
Reviewed-on: http://android.intel.com:8080/93185
Reviewed-by: Feng, Wei <wei.feng@intel.com>
Reviewed-by: Shi, PingX <pingx.shi@intel.com>
Tested-by: Shi, PingX <pingx.shi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
-rw-r--r-- | base/inc/componentbase.h | 3 | ||||
-rw-r--r-- | base/src/componentbase.cpp | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/base/inc/componentbase.h b/base/inc/componentbase.h index 945c91c..66f3ba5 100644 --- a/base/inc/componentbase.h +++ b/base/inc/componentbase.h @@ -432,6 +432,9 @@ private: /* component name */ char name[OMX_MAX_STRINGNAME_SIZE]; + /* state lock */ + pthread_mutex_t state_block; + /* omx specification version */ #ifndef ANDROID const static OMX_U8 OMX_SPEC_VERSION_MAJOR = 1; diff --git a/base/src/componentbase.cpp b/base/src/componentbase.cpp index 17e27b7..2b0cbaf 100644 --- a/base/src/componentbase.cpp +++ b/base/src/componentbase.cpp @@ -136,6 +136,7 @@ void ComponentBase::__ComponentBase(void) bufferwork = NULL; pthread_mutex_init(&ports_block, NULL); + pthread_mutex_init(&state_block, NULL); } ComponentBase::ComponentBase() @@ -152,6 +153,7 @@ ComponentBase::ComponentBase(const OMX_STRING name) ComponentBase::~ComponentBase() { pthread_mutex_destroy(&ports_block); + pthread_mutex_destroy(&state_block); if (roles) { if (roles[0]) @@ -775,7 +777,9 @@ OMX_ERRORTYPE ComponentBase::CBaseGetState( if (hComponent != handle) return OMX_ErrorBadParameter; + pthread_mutex_lock(&state_block); *pState = state; + pthread_mutex_unlock(&state_block); return OMX_ErrorNone; } OMX_ERRORTYPE ComponentBase::UseBuffer( @@ -1160,7 +1164,9 @@ void ComponentBase::CmdHandler(struct cmd_s *cmd) case OMX_CommandStateSet: { OMX_STATETYPE transition = (OMX_STATETYPE)cmd->param1; + pthread_mutex_lock(&state_block); TransState(transition); + pthread_mutex_unlock(&state_block); break; } case OMX_CommandFlush: { |