diff options
author | James Dong <jdong@google.com> | 2010-03-25 01:06:57 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2010-03-25 01:43:35 -0700 |
commit | 94d15606702ba7469bbb71739df707bfce1c4c3a (patch) | |
tree | 8723dfe4481f30b9565db2bbd489be0d4035dceb | |
parent | 947cd0b2c2aa45819a3460d794f039ea4ce0dce2 (diff) | |
download | opencore-94d15606702ba7469bbb71739df707bfce1c4c3a.tar.gz |
The file writer thread is not thread-safe.
We can run into problem where deallocate() called from two
separate thread which breaks PV's thread model where
every task is scheduled to run within a single omx thread.
I am pretty sure that this is why the free chunk available
notification is lost sometimes; however, this is certainly
not the fix to all the problems that we have seen so far.
bug - 2484098
Change-Id: I88bc494a11ffd739bc5771fa75b4643de503714f
-rw-r--r-- | nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp | 28 | ||||
-rw-r--r-- | nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp | 2 | ||||
-rw-r--r-- | oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp | 5 |
3 files changed, 28 insertions, 7 deletions
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp index a5e5be37f..7905c7507 100644 --- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp +++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp @@ -19,6 +19,34 @@ * @file pvmp4ffcn_node.cpp * @brief Node for PV MPEG4 file format composer */ + +/* + * FIXME: + * The current implementation of the file writer is NOT + * thread-safe. + * + * A separate delete queue should be used to + * pass back the fragments from the file writer thread + * to the composer node and to let the composer node + * handle the deallocation of any fragments; otherwise, + * race condition may occur. Some lost free chunk + * notification has been found due to this race + * condition. + * + * The reason why there is race condition is that the + * rest of the OpenCore assumes a single-thread model. + * In other words, everything is scheduled to + * run within a single omx thread. A separate file writer + * thread breaks this model, and deallocate fragments + * here may cause deallocate() be called within two + * separate thread, and thus the free chunk available + * flag can be corrupted. + * + * Don't remove the following #undef line unless you + * fix the above issue. + */ +#undef ANDROID + #ifdef ANDROID // #define LOG_NDEBUG 0 #define LOG_TAG "PvMp4Composer" diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp index 61aa7b082..a0bf09cb5 100644 --- a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp +++ b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp @@ -1206,8 +1206,6 @@ void PVMFOMXEncNode::Run() PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Run(): Flush pending: Changing Component State Executing->Idle or Pause->Idle", iNodeTypeId)); - if (iOutPort) iOutPort->ClearMsgQueues(); - err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL); if (err != OMX_ErrorNone) { diff --git a/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp b/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp index b86769cb8..efea04814 100644 --- a/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp +++ b/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp @@ -16,7 +16,6 @@ * ------------------------------------------------------------------- */ #include "oscl_mem_mempool.h" -#include <utils/Log.h> /** @@ -155,10 +154,6 @@ OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::deallocate(OsclAny* p) iObserver->freechunkavailable(iNextAvailableContextData); } } - else if (iObserver && iCheckNextAvailableFreeChunk) - { - LOGW("We may have lost some free chunk %p available notification for memory pool %p with chunk size %d", ptmp, mptmp, iChunkSizeMemAligned); - } // Decrement the refcount since deallocating succeeded removeRef(); |