diff options
author | Andreas Huber <andih@google.com> | 2009-11-06 10:07:53 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-11-06 10:07:53 -0800 |
commit | be364022fbdaa8eaef986b0ac4dae1c4ac7d64d5 (patch) | |
tree | 907f3faf0fc6c158965ea7b63d32e7100c522ef6 | |
parent | 1ae7831b8a90a9c0c614790027ce88d5fe75cf93 (diff) | |
parent | fde273baf6592a5fde15ee4dd4d798d90368e440 (diff) | |
download | frameworks_base-be364022fbdaa8eaef986b0ac4dae1c4ac7d64d5.zip frameworks_base-be364022fbdaa8eaef986b0ac4dae1c4ac7d64d5.tar.gz frameworks_base-be364022fbdaa8eaef986b0ac4dae1c4ac7d64d5.tar.bz2 |
am fde273ba: Merge change Ic997acac into eclair
Merge commit 'fde273baf6592a5fde15ee4dd4d798d90368e440' into eclair-mr2
* commit 'fde273baf6592a5fde15ee4dd4d798d90368e440':
Make AudioPlayer a little less verbose, defer starting audio playback until after the first video frame has been decoded (if there's video at all).
-rw-r--r-- | media/libstagefright/AudioPlayer.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/MediaPlayerImpl.cpp | 14 |
2 files changed, 21 insertions, 3 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp index 7b4d178..d7e3f66 100644 --- a/media/libstagefright/AudioPlayer.cpp +++ b/media/libstagefright/AudioPlayer.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 #define LOG_TAG "AudioPlayer" #include <utils/Log.h> @@ -136,7 +137,7 @@ void AudioPlayer::stop() { // Make sure to release any buffer we hold onto so that the // source is able to stop(). if (mInputBuffer != NULL) { - LOGI("AudioPlayer releasing input buffer."); + LOGV("AudioPlayer releasing input buffer."); mInputBuffer->release(); mInputBuffer = NULL; @@ -176,7 +177,7 @@ void AudioPlayer::AudioCallback(int event, void *info) { void AudioPlayer::fillBuffer(void *data, size_t size) { if (mNumFramesPlayed == 0) { - LOGI("AudioCallback"); + LOGV("AudioCallback"); } size_t size_done = 0; @@ -216,6 +217,11 @@ void AudioPlayer::fillBuffer(void *data, size_t size) { mPositionTimeRealUs = ((mNumFramesPlayed + size_done / mFrameSize) * 1000000) / mSampleRate; + + LOGV("buffer->size() = %d, " + "mPositionTimeMediaUs=%.2f mPositionTimeRealUs=%.2f", + mInputBuffer->range_length(), + mPositionTimeMediaUs / 1E6, mPositionTimeRealUs / 1E6); } if (mInputBuffer->range_length() == 0) { diff --git a/media/libstagefright/MediaPlayerImpl.cpp b/media/libstagefright/MediaPlayerImpl.cpp index 4d14e4c..eb9fe7f 100644 --- a/media/libstagefright/MediaPlayerImpl.cpp +++ b/media/libstagefright/MediaPlayerImpl.cpp @@ -147,7 +147,15 @@ void MediaPlayerImpl::play() { if (mAudioSource != NULL) { mAudioPlayer = new AudioPlayer(mAudioSink); mAudioPlayer->setSource(mAudioDecoder); - mAudioPlayer->start(); + + if (mVideoDecoder == NULL) { + // If there is no video, start playing right away, + // otherwise we'll start the audio player after we decode + // the first video frame, this way we won't be behind right + // away. + mAudioPlayer->start(); + } + mTimeSource = mAudioPlayer; } else { mTimeSource = new SystemTimeSource; @@ -276,6 +284,10 @@ void MediaPlayerImpl::videoEntry() { } if (firstFrame || seeking) { + if (firstFrame && mAudioPlayer != NULL) { + // We've deferred starting the audio player until now. + mAudioPlayer->start(); + } mTimeSourceDeltaUs = mTimeSource->getRealTimeUs() - pts_us; firstFrame = false; } |