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

Commit d8cbe4a0 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: update ACodec to use CodecBase enumerations directly

Bug: 11784825
Change-Id: I9f322b78b52bfcc5040fda951486df4354cdba4f
parent 92cd05b8
Loading
Loading
Loading
Loading
+8 −14
Original line number Diff line number Diff line
@@ -211,28 +211,28 @@ protected:
                int32_t what;
                CHECK(msg->findInt32("what", &what));

                if (what == ACodec::kWhatFillThisBuffer) {
                if (what == CodecBase::kWhatFillThisBuffer) {
                    onFillThisBuffer(msg);
                } else if (what == ACodec::kWhatDrainThisBuffer) {
                } else if (what == CodecBase::kWhatDrainThisBuffer) {
                    if ((mNumOutputBuffersReceived++ % 16) == 0) {
                        printf(".");
                        fflush(stdout);
                    }

                    onDrainThisBuffer(msg);
                } else if (what == ACodec::kWhatEOS
                        || what == ACodec::kWhatError) {
                    printf((what == ACodec::kWhatEOS) ? "$\n" : "E\n");
                } else if (what == CodecBase::kWhatEOS
                        || what == CodecBase::kWhatError) {
                    printf((what == CodecBase::kWhatEOS) ? "$\n" : "E\n");

                    printStatistics();
                    (new AMessage(kWhatStop, id()))->post();
                } else if (what == ACodec::kWhatFlushCompleted) {
                } else if (what == CodecBase::kWhatFlushCompleted) {
                    mSeekState = SEEK_FLUSH_COMPLETED;
                    mCodec->signalResume();

                    (new AMessage(kWhatSeek, id()))->post(5000000ll);
                } else if (what == ACodec::kWhatOutputFormatChanged) {
                } else if (what == ACodec::kWhatShutdownCompleted) {
                } else if (what == CodecBase::kWhatOutputFormatChanged) {
                } else if (what == CodecBase::kWhatShutdownCompleted) {
                    mDecodeLooper->unregisterHandler(mCodec->id());

                    if (mDecodeLooper != looper()) {
@@ -240,12 +240,6 @@ protected:
                    }

                    looper()->stop();
                } else if (what == ACodec::kWhatError) {
                    ALOGE("something went wrong, codec reported an error.");

                    printf("E\n");

                    (new AMessage(kWhatStop, id()))->post();
                }
                break;
            }
+0 −15
Original line number Diff line number Diff line
@@ -34,21 +34,6 @@ struct ABuffer;
struct MemoryDealer;

struct ACodec : public AHierarchicalStateMachine, public CodecBase {
    enum {
        kWhatFillThisBuffer      = CodecBase::kWhatFillThisBuffer,
        kWhatDrainThisBuffer     = CodecBase::kWhatDrainThisBuffer,
        kWhatEOS                 = CodecBase::kWhatEOS,
        kWhatShutdownCompleted   = CodecBase::kWhatShutdownCompleted,
        kWhatFlushCompleted      = CodecBase::kWhatFlushCompleted,
        kWhatOutputFormatChanged = CodecBase::kWhatOutputFormatChanged,
        kWhatError               = CodecBase::kWhatError,
        kWhatComponentAllocated  = CodecBase::kWhatComponentAllocated,
        kWhatComponentConfigured = CodecBase::kWhatComponentConfigured,
        kWhatInputSurfaceCreated = CodecBase::kWhatInputSurfaceCreated,
        kWhatSignaledInputEOS    = CodecBase::kWhatSignaledInputEOS,
        kWhatBuffersAllocated    = CodecBase::kWhatBuffersAllocated,
    };

    ACodec();

    virtual void setNotificationMessage(const sp<AMessage> &msg);
+16 −16
Original line number Diff line number Diff line
@@ -547,7 +547,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
    }

    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", ACodec::kWhatBuffersAllocated);
    notify->setInt32("what", CodecBase::kWhatBuffersAllocated);

    notify->setInt32("portIndex", portIndex);

@@ -3005,7 +3005,7 @@ void ACodec::sendFormatChange(const sp<AMessage> &reply) {

void ACodec::signalError(OMX_ERRORTYPE error, status_t internalError) {
    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", ACodec::kWhatError);
    notify->setInt32("what", CodecBase::kWhatError);
    notify->setInt32("omx-error", error);
    notify->setInt32("err", internalError);
    notify->post();
@@ -3398,7 +3398,7 @@ void ACodec::BaseState::postFillThisBuffer(BufferInfo *info) {
    CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_US);

    sp<AMessage> notify = mCodec->mNotify->dup();
    notify->setInt32("what", ACodec::kWhatFillThisBuffer);
    notify->setInt32("what", CodecBase::kWhatFillThisBuffer);
    notify->setInt32("buffer-id", info->mBufferID);

    info->mData->meta()->clear();
@@ -3693,7 +3693,7 @@ bool ACodec::BaseState::onOMXFillBufferDone(
            info->mData->meta()->setInt64("timeUs", timeUs);

            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", ACodec::kWhatDrainThisBuffer);
            notify->setInt32("what", CodecBase::kWhatDrainThisBuffer);
            notify->setInt32("buffer-id", info->mBufferID);
            notify->setBuffer("buffer", info->mData);
            notify->setInt32("flags", flags);
@@ -3710,7 +3710,7 @@ bool ACodec::BaseState::onOMXFillBufferDone(
                ALOGV("[%s] saw output EOS", mCodec->mComponentName.c_str());

                sp<AMessage> notify = mCodec->mNotify->dup();
                notify->setInt32("what", ACodec::kWhatEOS);
                notify->setInt32("what", CodecBase::kWhatEOS);
                notify->setInt32("err", mCodec->mInputEOSResult);
                notify->post();

@@ -3891,7 +3891,7 @@ bool ACodec::UninitializedState::onMessageReceived(const sp<AMessage> &msg) {
                     "cannot keep component allocated on shutdown in Uninitialized state");

            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", ACodec::kWhatShutdownCompleted);
            notify->setInt32("what", CodecBase::kWhatShutdownCompleted);
            notify->post();

            handled = true;
@@ -3901,7 +3901,7 @@ bool ACodec::UninitializedState::onMessageReceived(const sp<AMessage> &msg) {
        case ACodec::kWhatFlush:
        {
            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", ACodec::kWhatFlushCompleted);
            notify->setInt32("what", CodecBase::kWhatFlushCompleted);
            notify->post();

            handled = true;
@@ -4023,7 +4023,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {

    {
        sp<AMessage> notify = mCodec->mNotify->dup();
        notify->setInt32("what", ACodec::kWhatComponentAllocated);
        notify->setInt32("what", CodecBase::kWhatComponentAllocated);
        notify->setString("componentName", mCodec->mComponentName.c_str());
        notify->post();
    }
@@ -4073,7 +4073,7 @@ void ACodec::LoadedState::onShutdown(bool keepComponentAllocated) {

    if (mCodec->mExplicitShutdown) {
        sp<AMessage> notify = mCodec->mNotify->dup();
        notify->setInt32("what", ACodec::kWhatShutdownCompleted);
        notify->setInt32("what", CodecBase::kWhatShutdownCompleted);
        notify->post();
        mCodec->mExplicitShutdown = false;
    }
@@ -4120,7 +4120,7 @@ bool ACodec::LoadedState::onMessageReceived(const sp<AMessage> &msg) {
        case ACodec::kWhatFlush:
        {
            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", ACodec::kWhatFlushCompleted);
            notify->setInt32("what", CodecBase::kWhatFlushCompleted);
            notify->post();

            handled = true;
@@ -4169,7 +4169,7 @@ bool ACodec::LoadedState::onConfigureComponent(

    {
        sp<AMessage> notify = mCodec->mNotify->dup();
        notify->setInt32("what", ACodec::kWhatComponentConfigured);
        notify->setInt32("what", CodecBase::kWhatComponentConfigured);
        notify->setMessage("input-format", mCodec->mInputFormat);
        notify->setMessage("output-format", mCodec->mOutputFormat);
        notify->post();
@@ -4183,7 +4183,7 @@ void ACodec::LoadedState::onCreateInputSurface(
    ALOGV("onCreateInputSurface");

    sp<AMessage> notify = mCodec->mNotify->dup();
    notify->setInt32("what", ACodec::kWhatInputSurfaceCreated);
    notify->setInt32("what", CodecBase::kWhatInputSurfaceCreated);

    sp<IGraphicBufferProducer> bufferProducer;
    status_t err;
@@ -4337,7 +4337,7 @@ bool ACodec::LoadedToIdleState::onMessageReceived(const sp<AMessage> &msg) {
        {
            // We haven't even started yet, so we're flushed alright...
            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", ACodec::kWhatFlushCompleted);
            notify->setInt32("what", CodecBase::kWhatFlushCompleted);
            notify->post();
            return true;
        }
@@ -4398,7 +4398,7 @@ bool ACodec::IdleToExecutingState::onMessageReceived(const sp<AMessage> &msg) {
        {
            // We haven't even started yet, so we're flushed alright...
            sp<AMessage> notify = mCodec->mNotify->dup();
            notify->setInt32("what", ACodec::kWhatFlushCompleted);
            notify->setInt32("what", CodecBase::kWhatFlushCompleted);
            notify->post();

            return true;
@@ -4701,7 +4701,7 @@ status_t ACodec::setParameters(const sp<AMessage> &params) {

void ACodec::onSignalEndOfInputStream() {
    sp<AMessage> notify = mNotify->dup();
    notify->setInt32("what", ACodec::kWhatSignaledInputEOS);
    notify->setInt32("what", CodecBase::kWhatSignaledInputEOS);

    status_t err = mOMX->signalEndOfInputStream(mNode);
    if (err != OK) {
@@ -5131,7 +5131,7 @@ void ACodec::FlushingState::changeStateIfWeOwnAllBuffers() {
        mCodec->waitUntilAllPossibleNativeWindowBuffersAreReturnedToUs();

        sp<AMessage> notify = mCodec->mNotify->dup();
        notify->setInt32("what", ACodec::kWhatFlushCompleted);
        notify->setInt32("what", CodecBase::kWhatFlushCompleted);
        notify->post();

        mCodec->mPortEOS[kPortIndexInput] =