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

Commit 9fee0b2a authored by Andreas Huber's avatar Andreas Huber
Browse files

Ogg files can be tagged to be automatically looping, this setting always...

Ogg files can be tagged to be automatically looping, this setting always overrides the MediaPlayer's setLooping setting.

Change-Id: Ifb564c6cdf6137eac14869f9ca7d471f05a5556a
related-to-bug: 2974691
parent dc243482
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ enum {

    kKeyNotRealTime       = 'ntrt',  // bool (int32_t)

    // Ogg files can be tagged to be automatically looping...
    kKeyAutoLoop          = 'autL',  // bool (int32_t)
};

enum {
+10 −3
Original line number Diff line number Diff line
@@ -330,6 +330,13 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
        } else if (!haveAudio && !strncasecmp(mime, "audio/", 6)) {
            setAudioSource(extractor->getTrack(i));
            haveAudio = true;

            sp<MetaData> fileMeta = extractor->getMetaData();
            int32_t loop;
            if (fileMeta != NULL
                    && fileMeta->findInt32(kKeyAutoLoop, &loop) && loop != 0) {
                mFlags |= AUTO_LOOPING;
            }
        }

        if (haveAudio && haveVideo) {
@@ -587,7 +594,7 @@ void AwesomePlayer::onStreamDone() {
        return;
    }

    if (mFlags & LOOPING) {
    if (mFlags & (LOOPING | AUTO_LOOPING)) {
        seekTo_l(0);

        if (mVideoSource != NULL) {
@@ -1560,7 +1567,7 @@ status_t AwesomePlayer::suspend() {
    state->mUriHeaders = mUriHeaders;
    state->mFileSource = mFileSource;

    state->mFlags = mFlags & (PLAYING | LOOPING | AT_EOS);
    state->mFlags = mFlags & (PLAYING | AUTO_LOOPING | LOOPING | AT_EOS);
    getPosition(&state->mPositionUs);

    if (mLastVideoBuffer) {
@@ -1621,7 +1628,7 @@ status_t AwesomePlayer::resume() {

    seekTo_l(state->mPositionUs);

    mFlags = state->mFlags & (LOOPING | AT_EOS);
    mFlags = state->mFlags & (AUTO_LOOPING | LOOPING | AT_EOS);

    if (state->mLastVideoFrame && mISurface != NULL) {
        mVideoRenderer =
+5 −1
Original line number Diff line number Diff line
@@ -592,6 +592,7 @@ void MyVorbisExtractor::parseFileMetaData() {
        { "DATE", kKeyDate },
        { "LYRICIST", kKeyWriter },
        { "METADATA_BLOCK_PICTURE", kKeyAlbumArt },
        { "ANDROID_LOOP", kKeyAutoLoop },
    };

    for (int i = 0; i < mVc.comments; ++i) {
@@ -605,12 +606,15 @@ void MyVorbisExtractor::parseFileMetaData() {
                    extractAlbumArt(
                            &comment[tagLen + 1],
                            mVc.comment_lengths[i] - tagLen - 1);
                } else if (kMap[j].mKey == kKeyAutoLoop) {
                    if (!strcasecmp(&comment[tagLen + 1], "true")) {
                        mFileMeta->setInt32(kKeyAutoLoop, true);
                    }
                } else {
                    mFileMeta->setCString(kMap[j].mKey, &comment[tagLen + 1]);
                }
            }
        }

    }

#if 0
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ private:
        CACHE_UNDERRUN      = 128,
        AUDIO_AT_EOS        = 256,
        VIDEO_AT_EOS        = 512,
        AUTO_LOOPING        = 1024,
    };

    mutable Mutex mLock;