diff options
author | James Dong <jdong@google.com> | 2011-02-16 12:28:26 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2011-02-17 14:43:16 -0800 |
commit | a472613aec322e25891abf5c77bf3f7e3c244920 (patch) | |
tree | 2b8aa12e87fff0c143d50022f9f413305dc7882f /media/libstagefright/AudioSource.cpp | |
parent | f71eb135c28dd7b305b7030776ef0d44fac732c4 (diff) | |
download | frameworks_av-a472613aec322e25891abf5c77bf3f7e3c244920.zip frameworks_av-a472613aec322e25891abf5c77bf3f7e3c244920.tar.gz frameworks_av-a472613aec322e25891abf5c77bf3f7e3c244920.tar.bz2 |
A/V synchronization at the beginning of a recording session
o do not use edts/elst boxes since these optional boxes are ignored
o manipulate the first video/audio frame duration to make sure that the rest
of the audio/video is in sync (ideally, we should only manipulate
the vidoe frame duration, not the audio)
o reduce the initial audio mute/suppression period, which is used to
eliminate the "recording" sound.
bug - 3405882 and 3362703
Change-Id: Ib0acfb4f3843b365157288951dc122b006299c18
Diffstat (limited to 'media/libstagefright/AudioSource.cpp')
-rw-r--r-- | media/libstagefright/AudioSource.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp index cd0e021..bbdec02 100644 --- a/media/libstagefright/AudioSource.cpp +++ b/media/libstagefright/AudioSource.cpp @@ -263,6 +263,13 @@ status_t AudioSource::dataCallbackTimestamp( return OK; } + // Drop retrieved and previously lost audio data. + if (mNumFramesReceived == 0 && timeUs < mStartTimeUs) { + mRecord->getInputFramesLost(); + LOGV("Drop audio data at %lld/%lld us", timeUs, mStartTimeUs); + return OK; + } + if (mNumFramesReceived == 0 && mPrevSampleTimeUs == 0) { mInitialReadTimeUs = timeUs; // Initial delay @@ -277,7 +284,13 @@ status_t AudioSource::dataCallbackTimestamp( int64_t timestampUs = mPrevSampleTimeUs; - size_t numLostBytes = mRecord->getInputFramesLost(); + size_t numLostBytes = 0; + if (mNumFramesReceived > 0) { // Ignore earlier frame lost + // getInputFramesLost() returns the number of lost frames. + // Convert number of frames lost to number of bytes lost. + numLostBytes = mRecord->getInputFramesLost() * mRecord->frameSize(); + } + CHECK_EQ(numLostBytes & 1, 0u); CHECK_EQ(audioBuffer.size & 1, 0u); size_t bufferSize = numLostBytes + audioBuffer.size; |