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

Commit 1a77b68e authored by Andreas Huber's avatar Andreas Huber
Browse files

Another stagefright test-case and ignore end-of-stream notifications while we're flushing.

parent e777e0a3
Loading
Loading
Loading
Loading
+60 −0
Original line number Original line Diff line number Diff line
@@ -61,6 +61,66 @@ static void playSource(OMXClient *client, const sp<MediaSource> &source) {


    decoder->start();
    decoder->start();


    if (gReproduceBug == 3) {
        status_t err;
        MediaBuffer *buffer;
        MediaSource::ReadOptions options;
        int64_t seekTimeUs = -1;
        for (;;) {
            err = decoder->read(&buffer, &options);
            options.clearSeekTo();

            bool shouldSeek = false;
            if (err != OK) {
                printf("reached EOF.\n");

                shouldSeek = true;
            } else {
                int32_t units, scale;
                CHECK(buffer->meta_data()->findInt32(kKeyTimeUnits, &units));
                CHECK(buffer->meta_data()->findInt32(kKeyTimeScale, &scale));
                int64_t timestamp = ((OMX_TICKS)units * 1000000) / scale;

                bool failed = false;
                if (seekTimeUs >= 0) {
                    int64_t diff = timestamp - seekTimeUs;

                    if (diff > 500000) {
                        printf("ERROR: ");
                        failed = true;
                    }
                }

                printf("buffer has timestamp %lld us (%.2f secs)\n",
                       timestamp, timestamp / 1E6);

                buffer->release();
                buffer = NULL;

                if (failed) {
                    break;
                }

                shouldSeek = ((double)rand() / RAND_MAX) < 0.1;
                shouldSeek = false;
            }

            seekTimeUs = -1;

            if (shouldSeek) {
                seekTimeUs = (rand() * 30E6) / RAND_MAX;
                options.setSeekTo(seekTimeUs);

                printf("seeking to %lld us (%.2f secs)\n",
                       seekTimeUs, seekTimeUs / 1E6);
            }
        }

        decoder->stop();

        return;
    }

    int n = 0;
    int n = 0;
    int64_t startTime = getNowUs();
    int64_t startTime = getNowUs();


+7 −0
Original line number Original line Diff line number Diff line
@@ -1148,6 +1148,13 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
                    CODEC_LOGV("Finished flushing both ports, now continuing from"
                    CODEC_LOGV("Finished flushing both ports, now continuing from"
                         " seek-time.");
                         " seek-time.");


                    // Clear this flag in case the decoder sent us either
                    // the EVENT_BUFFER_FLAG(1) or an output buffer with
                    // the EOS flag set _while_ flushing. Since we're going
                    // to submit "fresh" input data now, this flag no longer
                    // applies to our future.
                    mNoMoreOutputData = false;

                    drainInputBuffers();
                    drainInputBuffers();
                    fillOutputBuffers();
                    fillOutputBuffers();
                }
                }