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

Commit c4871a8a authored by Ray Essick's avatar Ray Essick Committed by Android (Google) Code Review
Browse files

Merge "Finer synchronization for nuplayer stats"

parents dee634ee 83f56b07
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -106,16 +106,17 @@ NuPlayer::Decoder::~Decoder() {
    releaseAndResetMediaBuffers();
}

sp<AMessage> NuPlayer::Decoder::getStats() const {
sp<AMessage> NuPlayer::Decoder::getStats() {

    Mutex::Autolock autolock(mStatsLock);
    mStats->setInt64("frames-total", mNumFramesTotal);
    mStats->setInt64("frames-dropped-input", mNumInputFramesDropped);
    mStats->setInt64("frames-dropped-output", mNumOutputFramesDropped);
    mStats->setFloat("frame-rate-total", mFrameRateTotal);

    // i'm mutexed right now.
    // make our own copy, so we aren't victim to any later changes.
    sp<AMessage> copiedStats = mStats->dup();

    return copiedStats;
}

@@ -362,13 +363,17 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
    CHECK_EQ((status_t)OK, mCodec->getOutputFormat(&mOutputFormat));
    CHECK_EQ((status_t)OK, mCodec->getInputFormat(&mInputFormat));

    {
        Mutex::Autolock autolock(mStatsLock);
        mStats->setString("mime", mime.c_str());
        mStats->setString("component-name", mComponentName.c_str());
    }

    if (!mIsAudio) {
        int32_t width, height;
        if (mOutputFormat->findInt32("width", &width)
                && mOutputFormat->findInt32("height", &height)) {
            Mutex::Autolock autolock(mStatsLock);
            mStats->setInt32("width", width);
            mStats->setInt32("height", height);
        }
@@ -799,6 +804,7 @@ void NuPlayer::Decoder::handleOutputFormatChange(const sp<AMessage> &format) {
        int32_t width, height;
        if (format->findInt32("width", &width)
                && format->findInt32("height", &height)) {
            Mutex::Autolock autolock(mStatsLock);
            mStats->setInt32("width", width);
            mStats->setInt32("height", height);
        }
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ struct NuPlayer::Decoder : public DecoderBase {
            const sp<Surface> &surface = NULL,
            const sp<CCDecoder> &ccDecoder = NULL);

    virtual sp<AMessage> getStats() const;
    virtual sp<AMessage> getStats();

    // sets the output surface of video decoders.
    virtual status_t setVideoSurface(const sp<Surface> &surface);
+2 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ struct NuPlayer::DecoderBase : public AHandler {
    void signalResume(bool notifyComplete);
    void initiateShutdown();

    virtual sp<AMessage> getStats() const {
    virtual sp<AMessage> getStats() {
        return mStats;
    }

@@ -88,6 +88,7 @@ protected:
    int32_t mBufferGeneration;
    bool mPaused;
    sp<AMessage> mStats;
    Mutex mStatsLock;

private:
    enum {