diff options
author | Andreas Huber <andih@google.com> | 2009-11-05 16:34:39 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2009-11-05 16:34:39 -0800 |
commit | c997acacd54e30293920a7e2bda80a3d9a7d76c6 (patch) | |
tree | 2a4f7f4ac5064fbd99ebd8b200782e15840b7ab1 /media | |
parent | 05eca1d46a45723a57899dabad698537b7faef82 (diff) | |
download | frameworks_base-c997acacd54e30293920a7e2bda80a3d9a7d76c6.zip frameworks_base-c997acacd54e30293920a7e2bda80a3d9a7d76c6.tar.gz frameworks_base-c997acacd54e30293920a7e2bda80a3d9a7d76c6.tar.bz2 |
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).
Diffstat (limited to 'media')
-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 319488e..538facb 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; @@ -222,6 +223,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 2e609e3..622ea7e 100644 --- a/media/libstagefright/MediaPlayerImpl.cpp +++ b/media/libstagefright/MediaPlayerImpl.cpp @@ -157,7 +157,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; @@ -285,6 +293,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; } |