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

Commit 6218fdc2 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

MediaTimeProvider support fixes



Add MEDIA_SKIPPED event when resuming at a different time than
seeked to.

Send MEDIA_STARTED/PAUSED events only when playing (vs. when doing seek
previews)

Change-Id: I243ebf054303755ea8863229c3211694f2c204a7
Signed-off-by: default avatarLajos Molnar <lajos@google.com>
Bug: 10954008
parent 3d97e23f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ enum media_event_type {
    MEDIA_STARTED           = 6,
    MEDIA_PAUSED            = 7,
    MEDIA_STOPPED           = 8,
    MEDIA_SKIPPED           = 9,
    MEDIA_TIMED_TEXT        = 99,
    MEDIA_ERROR             = 100,
    MEDIA_INFO              = 200,
+17 −3
Original line number Diff line number Diff line
@@ -1413,8 +1413,10 @@ status_t AwesomePlayer::seekTo_l(int64_t timeUs) {
    mSeekTimeUs = timeUs;
    modifyFlags((AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS), CLEAR);

    if (mFlags & PLAYING) {
        notifyListener_l(MEDIA_PAUSED);
        mMediaRenderingStartGeneration = ++mStartGeneration;
    }

    seekAudioIfNecessary_l();

@@ -1659,6 +1661,16 @@ void AwesomePlayer::finishSeekIfNecessary(int64_t videoTimeUs) {
        return;
    }

    // If we paused, then seeked, then resumed, it is possible that we have
    // signaled SEEK_COMPLETE at a copmletely different media time than where
    // we are now resuming.  Signal new position to media time provider.
    // Cannot signal another SEEK_COMPLETE, as existing clients may not expect
    // multiple SEEK_COMPLETE responses to a single seek() request.
    if (mSeekNotificationSent && abs(mSeekTimeUs - videoTimeUs) > 10000) {
        // notify if we are resuming more than 10ms away from desired seek time
        notifyListener_l(MEDIA_SKIPPED);
    }

    if (mAudioPlayer != NULL) {
        ALOGV("seeking audio to %lld us (%.2f secs).", videoTimeUs, videoTimeUs / 1E6);

@@ -1930,8 +1942,10 @@ void AwesomePlayer::onVideoEvent() {
            notifyListener_l(MEDIA_INFO, MEDIA_INFO_RENDERING_START);
        }

        if (mFlags & PLAYING) {
            notifyIfMediaStarted_l();
        }
    }

    mVideoBuffer->release();
    mVideoBuffer = NULL;