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

Commit cac286e1 authored by Arun Johnson's avatar Arun Johnson
Browse files

Adding atrace markers to mediacodec and ccodecs

Bug: 385202255
Flag: EXEMPT only adding atrace messages

Change-Id: I6fd774677d101ee4e4aa11a35fd1392092f4be68
parent da1dca0f
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -3111,10 +3111,13 @@ c2_status_t Codec2Client::Component::queue(
    }
    if (mAidlBase) {
        c2_aidl::WorkBundle workBundle;
        {
            ScopedTrace trace(ATRACE_TAG, "CCodec::Codec2Client::ToAidl");
            if (!c2_aidl::utils::ToAidl(&workBundle, *items, mAidlBufferPoolSender.get())) {
                LOG(ERROR) << "queue -- bad input.";
                return C2_TRANSACTION_FAILED;
            }
        }
        ::ndk::ScopedAStatus transStatus = mAidlBase->queue(workBundle);
        return GetC2Status(transStatus, "queue");
    }
@@ -3446,7 +3449,7 @@ status_t Codec2Client::Component::queueToOutputSurface(
        const C2ConstGraphicBlock& block,
        const QueueBufferInput& input,
        QueueBufferOutput* output) {
    ScopedTrace trace(ATRACE_TAG,"Codec2Client::Component::queueToOutputSurface");
    ScopedTrace trace(ATRACE_TAG,"CCodec::Codec2Client::Component::queueToOutputSurface");
    if (mAidlBase) {
        std::shared_ptr<AidlGraphicBufferAllocator> gba =
                mGraphicBufferAllocators->current();
+4 −0
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

//#define LOG_NDEBUG 0
#define LOG_TAG "CCodec"
#define ATRACE_TAG  ATRACE_TAG_VIDEO
#include <utils/Log.h>
#include <utils/Trace.h>

#include <sstream>
#include <thread>
@@ -883,6 +885,7 @@ struct CCodec::ClientListener : public Codec2Client::Listener {
            const std::weak_ptr<Codec2Client::Component>& component,
            std::list<std::unique_ptr<C2Work>>& workItems) override {
        (void)component;
        ScopedTrace trace(ATRACE_TAG, "CCodec::ClientListener-WorkDone");
        sp<CCodec> codec(mCodec.promote());
        if (!codec) {
            return;
@@ -2878,6 +2881,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }
        case kWhatWorkDone: {
            ScopedTrace trace(ATRACE_TAG, "CCodec::msg-onWorkDone");
            std::unique_ptr<C2Work> work;
            bool shouldPost = false;
            {
+135 −109
Original line number Diff line number Diff line
@@ -911,6 +911,7 @@ status_t CCodecBufferChannel::queueSecureInputBuffer(
    size_t bufferSize = 0;
    c2_status_t blockRes = C2_OK;
    bool copied = false;
    {
        ScopedTrace trace(ATRACE_TAG, android::base::StringPrintf(
                "CCodecBufferChannel::decrypt(%s)", mName).c_str());
        if (mSendEncryptedInfoBuffer) {
@@ -1033,7 +1034,7 @@ status_t CCodecBufferChannel::queueSecureInputBuffer(
        }

        buffer->setRange(codecDataOffset, result - codecDataOffset);

    }
    return queueInputBufferInternal(buffer, block, bufferSize);
}

@@ -1238,6 +1239,13 @@ void CCodecBufferChannel::feedInputBufferIfAvailableInternal() {

status_t CCodecBufferChannel::renderOutputBuffer(
        const sp<MediaCodecBuffer> &buffer, int64_t timestampNs) {
    std::string traceStr;
    if (ATRACE_ENABLED()) {
        traceStr = android::base::StringPrintf(
                "CCodecBufferChannel::renderOutputBuffer-%s", mName);
    }
    ScopedTrace trace(ATRACE_TAG, traceStr.c_str());

    ALOGV("[%s] renderOutputBuffer: %p", mName, buffer.get());
    std::shared_ptr<C2Buffer> c2Buffer;
    bool released = false;
@@ -2363,6 +2371,12 @@ void CCodecBufferChannel::onWorkDone(
        const sp<AMessage> &inputFormat,
        const sp<AMessage> &outputFormat,
        const C2StreamInitDataInfo::output *initData) {
    std::string traceStr;
    if (ATRACE_ENABLED()) {
        traceStr = android::base::StringPrintf(
                "CCodecBufferChannel::onWorkDone-%s", mName).c_str();
    }
    ScopedTrace trace(ATRACE_TAG, traceStr.c_str());
    if (handleWork(std::move(work), inputFormat, outputFormat, initData)) {
        feedInputBufferIfAvailable();
    }
@@ -2396,6 +2410,12 @@ bool CCodecBufferChannel::handleWork(
        const sp<AMessage> &inputFormat,
        const sp<AMessage> &outputFormat,
        const C2StreamInitDataInfo::output *initData) {
    std::string traceStr;
    if (ATRACE_ENABLED()) {
        traceStr = android::base::StringPrintf(
                "CCodecBufferChannel::handleWork-%s", mName).c_str();
    }
    ScopedTrace atrace(ATRACE_TAG, traceStr.c_str());
    {
        Mutexed<Output>::Locked output(mOutput);
        if (!output->buffers) {
@@ -2746,6 +2766,12 @@ bool CCodecBufferChannel::handleWork(
}

void CCodecBufferChannel::sendOutputBuffers() {
    std::string traceStr;
    if (ATRACE_ENABLED()) {
        traceStr = android::base::StringPrintf(
                "CCodecBufferChannel::sendOutputBuffers-%s", mName);
    }
    ScopedTrace trace(ATRACE_TAG, traceStr.c_str());
    OutputBuffers::BufferAction action;
    size_t index;
    sp<MediaCodecBuffer> outBuffer;
+3 −0
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

//#define LOG_NDEBUG 0
#define LOG_TAG "CCodecBuffers"
#define ATRACE_TAG  ATRACE_TAG_VIDEO
#include <utils/Log.h>
#include <utils/Trace.h>

#include <numeric>

@@ -984,6 +986,7 @@ sp<Codec2Buffer> SlotInputBuffers::createNewBuffer() {
// LinearInputBuffers

bool LinearInputBuffers::requestNewBuffer(size_t *index, sp<MediaCodecBuffer> *buffer) {
    ScopedTrace trace(ATRACE_TAG, "CCodec::LinearInputBuffers::requestNewBuffer");
    sp<Codec2Buffer> newBuffer = createNewBuffer();
    if (newBuffer == nullptr) {
        return false;
+20 −2
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
//#define LOG_NDEBUG 0
#include "hidl/HidlSupport.h"
#define LOG_TAG "MediaCodec"
#define ATRACE_TAG  ATRACE_TAG_VIDEO
#include <utils/Log.h>
#include <utils/Trace.h>

#include <dlfcn.h>
#include <inttypes.h>
@@ -2220,6 +2222,7 @@ static const CodecListCache &GetCodecListCache() {
}

status_t MediaCodec::init(const AString &name) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::Init#native");
    status_t err = mResourceManagerProxy->init();
    if (err != OK) {
        mErrorLog.log(LOG_TAG, base::StringPrintf(
@@ -2549,7 +2552,7 @@ status_t MediaCodec::configure(
        const sp<ICrypto> &crypto,
        const sp<IDescrambler> &descrambler,
        uint32_t flags) {

    ScopedTrace trace(ATRACE_TAG, "MediaCodec::configure#native");
    // Update the codec importance.
    updateCodecImportance(format);

@@ -3225,6 +3228,7 @@ uint64_t MediaCodec::getGraphicBufferSize() {
}

status_t MediaCodec::start() {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::start#native");
    sp<AMessage> msg = new AMessage(kWhatStart, this);

    sp<AMessage> callback;
@@ -3282,6 +3286,7 @@ status_t MediaCodec::start() {
}

status_t MediaCodec::stop() {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::stop#native");
    sp<AMessage> msg = new AMessage(kWhatStop, this);

    sp<AMessage> response;
@@ -3330,7 +3335,7 @@ status_t MediaCodec::reset() {
    /* When external-facing MediaCodec object is created,
       it is already initialized.  Thus, reset is essentially
       release() followed by init(), plus clearing the state */

    ScopedTrace trace(ATRACE_TAG, "MediaCodec::reset#native");
    status_t err = release();

    // unregister handlers
@@ -3367,6 +3372,7 @@ status_t MediaCodec::queueInputBuffer(
        int64_t presentationTimeUs,
        uint32_t flags,
        AString *errorDetailMsg) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueInputBuffer#native");
    if (errorDetailMsg != NULL) {
        errorDetailMsg->clear();
    }
@@ -3388,6 +3394,7 @@ status_t MediaCodec::queueInputBuffers(
        size_t size,
        const sp<BufferInfosWrapper> &infos,
        AString *errorDetailMsg) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueInputBuffers#native");
    sp<AMessage> msg = new AMessage(kWhatQueueInputBuffer, this);
    uint32_t bufferFlags = 0;
    uint32_t flagsinAllAU = BUFFER_FLAG_DECODE_ONLY | BUFFER_FLAG_CODECCONFIG;
@@ -3437,6 +3444,7 @@ status_t MediaCodec::queueSecureInputBuffer(
        int64_t presentationTimeUs,
        uint32_t flags,
        AString *errorDetailMsg) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueSecureInputBuffer#native");
    if (errorDetailMsg != NULL) {
        errorDetailMsg->clear();
    }
@@ -3468,6 +3476,7 @@ status_t MediaCodec::queueSecureInputBuffers(
        const sp<BufferInfosWrapper> &auInfo,
        const sp<CryptoInfosWrapper> &cryptoInfos,
        AString *errorDetailMsg) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueSecureInputBuffers#native");
    if (errorDetailMsg != NULL) {
        errorDetailMsg->clear();
    }
@@ -3519,6 +3528,7 @@ status_t MediaCodec::queueBuffer(
        const sp<BufferInfosWrapper> &bufferInfos,
        const sp<AMessage> &tunings,
        AString *errorDetailMsg) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueBuffer#native");
    if (errorDetailMsg != NULL) {
        errorDetailMsg->clear();
    }
@@ -3554,6 +3564,7 @@ status_t MediaCodec::queueEncryptedBuffer(
        const sp<CryptoInfosWrapper> &cryptoInfos,
        const sp<AMessage> &tunings,
        AString *errorDetailMsg) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueEncryptedBuffer#native");
    if (errorDetailMsg != NULL) {
        errorDetailMsg->clear();
    }
@@ -3610,6 +3621,7 @@ status_t MediaCodec::dequeueOutputBuffer(
        int64_t *presentationTimeUs,
        uint32_t *flags,
        int64_t timeoutUs) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::dequeueOutputBuffer#native");
    sp<AMessage> msg = new AMessage(kWhatDequeueOutputBuffer, this);
    msg->setInt64("timeoutUs", timeoutUs);

@@ -3629,6 +3641,7 @@ status_t MediaCodec::dequeueOutputBuffer(
}

status_t MediaCodec::renderOutputBufferAndRelease(size_t index) {
    ScopedTrace (ATRACE_TAG, "MediaCodec::renderOutputBufferAndRelease#native");
    sp<AMessage> msg = new AMessage(kWhatReleaseOutputBuffer, this);
    msg->setSize("index", index);
    msg->setInt32("render", true);
@@ -3638,6 +3651,7 @@ status_t MediaCodec::renderOutputBufferAndRelease(size_t index) {
}

status_t MediaCodec::renderOutputBufferAndRelease(size_t index, int64_t timestampNs) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::renderOutputBufferAndRelease#native");
    sp<AMessage> msg = new AMessage(kWhatReleaseOutputBuffer, this);
    msg->setSize("index", index);
    msg->setInt32("render", true);
@@ -3648,6 +3662,7 @@ status_t MediaCodec::renderOutputBufferAndRelease(size_t index, int64_t timestam
}

status_t MediaCodec::releaseOutputBuffer(size_t index) {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::releaseOutputBuffer#native");
    sp<AMessage> msg = new AMessage(kWhatReleaseOutputBuffer, this);
    msg->setSize("index", index);

@@ -3855,6 +3870,7 @@ status_t MediaCodec::getBufferAndFormat(
}

status_t MediaCodec::flush() {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::flush#native");
    sp<AMessage> msg = new AMessage(kWhatFlush, this);

    sp<AMessage> response;
@@ -6421,6 +6437,7 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
    size_t size = 0;
    int64_t timeUs = 0;
    uint32_t flags = 0;
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::onQueueInputBuffer#native");
    CHECK(msg->findSize("index", &index));
    CHECK(msg->findInt64("timeUs", &timeUs));
    CHECK(msg->findInt32("flags", (int32_t *)&flags));
@@ -7132,6 +7149,7 @@ void MediaCodec::onInputBufferAvailable() {
}

void MediaCodec::onOutputBufferAvailable() {
    ScopedTrace trace(ATRACE_TAG, "MediaCodec::onOutputBufferAvailable#native");
    int32_t index;
    while ((index = dequeuePortBuffer(kPortIndexOutput)) >= 0) {
        if (discardDecodeOnlyOutputBuffer(index)) {