Merge "Fix for issue 4905998 OMXCodec::drainInputBuffer, findInt64(kKeyTime, &lastBufferTimeUs) fails"
diff --git a/libvideoeditor/vss/common/inc/M4AD_Common.h b/libvideoeditor/vss/common/inc/M4AD_Common.h
index 185ad87..7efee24 100755
--- a/libvideoeditor/vss/common/inc/M4AD_Common.h
+++ b/libvideoeditor/vss/common/inc/M4AD_Common.h
@@ -118,6 +118,7 @@
 {
     M4OSA_MemAddr8    m_dataAddress;
     M4OSA_UInt32    m_bufferSize;
+    int64_t         m_timeStampUs;
 } M4AD_Buffer;
 
 /**
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index d8d47f1..20a3524 100755
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -8275,6 +8275,8 @@
     * Decode the AU */
     pC->AudioDecBufferIn.m_dataAddress = pC->ReaderAudioAU.m_dataAddress;
     pC->AudioDecBufferIn.m_bufferSize = pC->ReaderAudioAU.m_size;
+    pC->AudioDecBufferIn.m_timeStampUs =
+     (int64_t) (pC->ReaderAudioAU.m_CTS * 1000LL);
 
     err = pC->m_pAudioDecoder->m_pFctStepAudioDec(pC->pAudioDecCtxt,
         &pC->AudioDecBufferIn, &pC->AudioDecBufferOut, M4OSA_FALSE);
diff --git a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
index 69e0aab..5eaedf7 100755
--- a/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
+++ b/libvideoeditor/vss/src/M4VSS3GPP_Clip.c
@@ -1415,6 +1415,8 @@
         pClipCtxt->AudioDecBufferIn.m_dataAddress =
             (M4OSA_MemAddr8)pClipCtxt->pAudioFramePtr;
         pClipCtxt->AudioDecBufferIn.m_bufferSize = pClipCtxt->uiAudioFrameSize;
+        pClipCtxt->AudioDecBufferIn.m_timeStampUs =
+            (int64_t) (pClipCtxt->iAudioFrameCts * 1000LL);
 
         err = pClipCtxt->ShellAPI.m_pAudioDecoder->m_pFctStepAudioDec(
             pClipCtxt->pAudioDecCtxt,
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp
index 6d2776f..f1446d1 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorAudioDecoder.cpp
@@ -605,6 +605,7 @@
         buffer = new MediaBuffer((size_t)pInputBuffer->m_bufferSize);
         memcpy((void *)((M4OSA_Int8*)buffer->data() + buffer->range_offset()),
             (void *)pInputBuffer->m_dataAddress, pInputBuffer->m_bufferSize);
+        buffer->meta_data()->setInt64(kKeyTime, pInputBuffer->m_timeStampUs);
     }
     nbBuffer = pDecoderContext->mDecoderSource->storeBuffer(buffer);