Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fde273ba authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change Ic997acac into eclair

* changes:
  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).
parents 8b1243e5 c997acac
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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) {
+13 −1
Original line number Diff line number Diff line
@@ -157,7 +157,15 @@ void MediaPlayerImpl::play() {
    if (mAudioSource != NULL) {
        mAudioPlayer = new AudioPlayer(mAudioSink);
        mAudioPlayer->setSource(mAudioDecoder);

        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;
        }