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

Commit cfd55579 authored by Andreas Huber's avatar Andreas Huber
Browse files

OMXCodec now notifies the reader of changes in the output format by returning...

OMXCodec now notifies the reader of changes in the output format by returning a special result/error code.
parent d5ad08bd
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -71,7 +71,12 @@ static void playSource(OMXClient *client, const sp<MediaSource> &source) {
            options.clearSeekTo();

            bool shouldSeek = false;
            if (err != OK) {
            if (err == INFO_FORMAT_CHANGED) {
                CHECK_EQ(buffer, NULL);

                printf("format changed.\n");
                continue;
            } else if (err != OK) {
                printf("reached EOF.\n");

                shouldSeek = true;
@@ -136,6 +141,12 @@ static void playSource(OMXClient *client, const sp<MediaSource> &source) {

            if (err != OK) {
                CHECK_EQ(buffer, NULL);

                if (err == INFO_FORMAT_CHANGED) {
                    printf("format changed.\n");
                    continue;
                }

                break;
            }

+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ enum {
    ERROR_BUFFER_TOO_SMALL  = MEDIA_ERROR_BASE - 9,
    ERROR_UNSUPPORTED       = MEDIA_ERROR_BASE - 10,
    ERROR_END_OF_STREAM     = MEDIA_ERROR_BASE - 11,

    // Not technically an error.
    INFO_FORMAT_CHANGED    = MEDIA_ERROR_BASE - 12,
};

}  // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ struct MediaSource : public RefBase {
    // buffer is available, an error is encountered of the end of the stream
    // is reached.
    // End of stream is signalled by a result of ERROR_END_OF_STREAM.
    // A result of INFO_FORMAT_CHANGED indicates that the format of this
    // MediaSource has changed mid-stream, the client can continue reading
    // but should be prepared for buffers of the new configuration.
    virtual status_t read(
            MediaBuffer **buffer, const ReadOptions *options = NULL) = 0;

+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ private:
    bool mInitialBufferSubmit;
    bool mSignalledEOS;
    bool mNoMoreOutputData;
    bool mOutputPortSettingsHaveChanged;
    int64_t mSeekTimeUs;

    Mutex mLock;
+4 −1
Original line number Diff line number Diff line
@@ -130,7 +130,10 @@ VideoFrame *StagefrightMetadataRetriever::captureFrame() {
    decoder->start();

    MediaBuffer *buffer;
    status_t err = decoder->read(&buffer);
    status_t err;
    do {
        err = decoder->read(&buffer);
    } while (err == INFO_FORMAT_CHANGED);

    if (err != OK) {
        CHECK_EQ(buffer, NULL);
Loading