summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2011-08-26 20:26:46 +0800
committerChih-Chung Chang <chihchung@google.com>2011-08-26 20:29:10 +0800
commit5f9cd08076587935f798b2b2eba4aa202362f532 (patch)
treebcc1bbe3e2406fb61c03c8de2b916a75c8545f62
parent072be1ea494b0f4ca6d184e6c53d9ba01e539de2 (diff)
downloadframeworks_av-5f9cd08076587935f798b2b2eba4aa202362f532.zip
frameworks_av-5f9cd08076587935f798b2b2eba4aa202362f532.tar.gz
frameworks_av-5f9cd08076587935f798b2b2eba4aa202362f532.tar.bz2
Fix 5212886: free the reader after freeing decoders.
If we free the reader first, the decoder may still read from it after the reader is freed. So we need to free the reader last. Change-Id: Ib6c7d6991d544870f1b3892387d0db312d501755
-rwxr-xr-xlibvideoeditor/vss/mcs/src/M4MCS_API.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index 5eb2a75..baa0dd5 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -10092,7 +10092,48 @@ static M4OSA_ERR M4MCS_intCleanUp_ReadersDecoders( M4MCS_InternalContext *pC )
M4OSA_TRACE2_1("M4MCS_intCleanUp_ReadersDecoders called with pC=0x%x", pC);
+ /**/
+ /* ----- Free video decoder stuff, if needed ----- */
+
+ if( M4OSA_NULL != pC->pViDecCtxt )
+ {
+ err = pC->m_pVideoDecoder->m_pFctDestroy(pC->pViDecCtxt);
+ pC->pViDecCtxt = M4OSA_NULL;
+
+ if( M4NO_ERROR != err )
+ {
+ M4OSA_TRACE1_1(
+ "M4MCS_cleanUp: m_pVideoDecoder->pFctDestroy returns 0x%x",
+ err);
+ /**< don't return, we still have stuff to free */
+ }
+ }
+
+ /* ----- Free the audio decoder stuff ----- */
+
+ if( M4OSA_NULL != pC->pAudioDecCtxt )
+ {
+ err = pC->m_pAudioDecoder->m_pFctDestroyAudioDec(pC->pAudioDecCtxt);
+ pC->pAudioDecCtxt = M4OSA_NULL;
+
+ if( M4NO_ERROR != err )
+ {
+ M4OSA_TRACE1_1(
+ "M4MCS_cleanUp: m_pAudioDecoder->m_pFctDestroyAudioDec returns 0x%x",
+ err);
+ /**< don't return, we still have stuff to free */
+ }
+ }
+
+ if( M4OSA_NULL != pC->AudioDecBufferOut.m_dataAddress )
+ {
+ free(pC->AudioDecBufferOut.m_dataAddress);
+ pC->AudioDecBufferOut.m_dataAddress = M4OSA_NULL;
+ }
+
/* ----- Free reader stuff, if needed ----- */
+ // We cannot free the reader before decoders because the decoders may read
+ // from the reader (in another thread) before being stopped.
if( M4OSA_NULL != pC->
pReaderContext ) /**< may be M4OSA_NULL if M4MCS_open was not called */
@@ -10140,44 +10181,6 @@ static M4OSA_ERR M4MCS_intCleanUp_ReadersDecoders( M4MCS_InternalContext *pC )
free(pC->m_pDataVideoAddress2);
pC->m_pDataVideoAddress2 = M4OSA_NULL;
}
- /**/
- /* ----- Free video decoder stuff, if needed ----- */
-
- if( M4OSA_NULL != pC->pViDecCtxt )
- {
- err = pC->m_pVideoDecoder->m_pFctDestroy(pC->pViDecCtxt);
- pC->pViDecCtxt = M4OSA_NULL;
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4MCS_cleanUp: m_pVideoDecoder->pFctDestroy returns 0x%x",
- err);
- /**< don't return, we still have stuff to free */
- }
- }
-
- /* ----- Free the audio decoder stuff ----- */
-
- if( M4OSA_NULL != pC->pAudioDecCtxt )
- {
- err = pC->m_pAudioDecoder->m_pFctDestroyAudioDec(pC->pAudioDecCtxt);
- pC->pAudioDecCtxt = M4OSA_NULL;
-
- if( M4NO_ERROR != err )
- {
- M4OSA_TRACE1_1(
- "M4MCS_cleanUp: m_pAudioDecoder->m_pFctDestroyAudioDec returns 0x%x",
- err);
- /**< don't return, we still have stuff to free */
- }
- }
-
- if( M4OSA_NULL != pC->AudioDecBufferOut.m_dataAddress )
- {
- free(pC->AudioDecBufferOut.m_dataAddress);
- pC->AudioDecBufferOut.m_dataAddress = M4OSA_NULL;
- }
return M4NO_ERROR;
}