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

Commit 2ef05177 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11876238 from 4a525245 to 24Q3-release

Change-Id: I8740acd30884339ab8994fc9f28500884698f0a3
parents a3e21cfb 4a525245
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -362,8 +362,8 @@ static status_t prepareVirtualDisplay(
        const ui::DisplayState& displayState,
        const sp<IGraphicBufferProducer>& bufferProducer,
        sp<IBinder>* pDisplayHandle, sp<SurfaceControl>* mirrorRoot) {
    sp<IBinder> dpy = SurfaceComposerClient::createDisplay(
            String8("ScreenRecorder"), gSecureDisplay);
    static const std::string kDisplayName("ScreenRecorder");
    sp<IBinder> dpy = SurfaceComposerClient::createVirtualDisplay(kDisplayName, gSecureDisplay);
    SurfaceComposerClient::Transaction t;
    t.setDisplaySurface(dpy, bufferProducer);
    setDisplayProjection(t, dpy, displayState);
@@ -797,7 +797,7 @@ struct RecordingData {
    sp<Overlay> overlay;

    ~RecordingData() {
        if (dpy != nullptr) SurfaceComposerClient::destroyDisplay(dpy);
        if (dpy != nullptr) SurfaceComposerClient::destroyVirtualDisplay(dpy);
        if (overlay != nullptr) overlay->stop();
        if (encoder != nullptr) {
            encoder->stop();
+6 −5
Original line number Diff line number Diff line
@@ -49,11 +49,6 @@ public:
            std::weak_ptr<FilterWrapper> filterWrapper)
        : mIntf(intf), mFilterWrapper(filterWrapper) {
        takeFilters(std::move(filters));
        for (size_t i = 0; i < mFilters.size(); ++i) {
            mControlParamTypes.insert(
                    mFilters[i].desc.controlParams.begin(),
                    mFilters[i].desc.controlParams.end());
        }
    }

    ~WrappedDecoderInterface() override = default;
@@ -91,6 +86,12 @@ public:

        // TODO: documentation
        mFilters = std::move(filters);
        mControlParamTypes.clear();
        for (size_t i = 0; i < mFilters.size(); ++i) {
            mControlParamTypes.insert(
                    mFilters[i].desc.controlParams.begin(),
                    mFilters[i].desc.controlParams.end());
        }
        mTypeToIndexForQuery.clear();
        mTypeToIndexForConfig.clear();
        for (size_t i = 0; i < mFilters.size(); ++i) {
+16 −4
Original line number Diff line number Diff line
@@ -2229,9 +2229,15 @@ void CCodec::stop(bool pushBlankBuffer) {
    // See also b/300350761.
    //
    // The workaround is no longer needed with fetchGraphicBlock & C2Fence changes.
    // so we are reverting back to the logical sequence of the operations.
    // so we are reverting back to the logical sequence of the operations when
    // AIDL HALs are selected.
    // When the HIDL HALs are selected, we retained workaround(the reversed
    // order) as default in order to keep legacy behavior.
    bool stopHalBeforeSurface =
            Codec2Client::IsAidlSelected() ||
            property_get_bool("debug.codec2.stop_hal_before_surface", false);
    status_t err = C2_OK;
    if (android::media::codec::provider_->stop_hal_before_surface()) {
    if (stopHalBeforeSurface && android::media::codec::provider_->stop_hal_before_surface()) {
        err = comp->stop();
        mChannel->stopUseOutputSurface(pushBlankBuffer);
    } else {
@@ -2334,8 +2340,14 @@ void CCodec::release(bool sendCallback, bool pushBlankBuffer) {
    // See also b/300350761.
    //
    // The workaround is no longer needed with fetchGraphicBlock & C2Fence changes.
    // so we are reverting back to the logical sequence of the operations.
    if (android::media::codec::provider_->stop_hal_before_surface()) {
    // so we are reverting back to the logical sequence of the operations when
    // AIDL HALs are selected.
    // When the HIDL HALs are selected, we retained workaround(the reversed
    // order) as default in order to keep legacy behavior.
    bool stopHalBeforeSurface =
            Codec2Client::IsAidlSelected() ||
            property_get_bool("debug.codec2.stop_hal_before_surface", false);
    if (stopHalBeforeSurface && android::media::codec::provider_->stop_hal_before_surface()) {
        comp->release();
        mChannel->stopUseOutputSurface(pushBlankBuffer);
    } else {
+10 −1
Original line number Diff line number Diff line
@@ -2784,7 +2784,16 @@ void CCodecBufferChannel::resetBuffersPixelFormat(bool isEncoder) {
}

void CCodecBufferChannel::setInfoBuffer(const std::shared_ptr<C2InfoBuffer> &buffer) {
    if (mInputSurface == nullptr) {
        mInfoBuffers.push_back(buffer);
    } else {
        std::list<std::unique_ptr<C2Work>> items;
        std::unique_ptr<C2Work> work(new C2Work);
        work->input.infoBuffers.emplace_back(*buffer);
        work->worklets.emplace_back(new C2Worklet);
        items.push_back(std::move(work));
        c2_status_t err = mComponent->queue(&items);
    }
}

status_t toStatusT(c2_status_t c2s, c2_operation_t c2op) {
+59 −21
Original line number Diff line number Diff line
@@ -285,11 +285,12 @@ status_t StreamHalAidl::getLatency(uint32_t *latency) {
    return OK;
}

status_t StreamHalAidl::getObservablePosition(int64_t *frames, int64_t *timestamp) {
status_t StreamHalAidl::getObservablePosition(int64_t* frames, int64_t* timestamp,
        StatePositions* statePositions) {
    ALOGV("%p %s::%s", this, getClassName().c_str(), __func__);
    if (!mStream) return NO_INIT;
    StreamDescriptor::Reply reply;
    RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply));
    RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply, statePositions));
    *frames = std::max<int64_t>(0, reply.observable.frames);
    *timestamp = std::max<int64_t>(0, reply.observable.timeNs);
    return OK;
@@ -446,8 +447,12 @@ void StreamHalAidl::onAsyncDrainReady() {
    if (auto state = getState(); state == StreamDescriptor::State::DRAINING) {
        // Retrieve the current state together with position counters unconditionally
        // to ensure that the state on our side gets updated.
        sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(),
                nullptr, true /*safeFromNonWorkerThread */);
        sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(), nullptr,
                    true /*safeFromNonWorkerThread */);
        // For compatibility with HIDL behavior, apply a "soft" position reset
        // after receiving the "drain ready" callback.
        std::lock_guard l(mLock);
        mStatePositions.framesAtFlushOrDrain = mLastReply.observable.frames;
    } else {
        ALOGW("%s: unexpected onDrainReady in the state %s", __func__, toString(state).c_str());
    }
@@ -455,15 +460,8 @@ void StreamHalAidl::onAsyncDrainReady() {

void StreamHalAidl::onAsyncError() {
    std::lock_guard l(mLock);
    if (mLastReply.state == StreamDescriptor::State::IDLE ||
        mLastReply.state == StreamDescriptor::State::DRAINING ||
        mLastReply.state == StreamDescriptor::State::TRANSFERRING) {
    ALOGW("%s: received in the state %s", __func__, toString(mLastReply.state).c_str());
    mLastReply.state = StreamDescriptor::State::ERROR;
        ALOGW("%s: onError received", __func__);
    } else {
        ALOGW("%s: unexpected onError in the state %s", __func__,
                toString(mLastReply.state).c_str());
    }
}

status_t StreamHalAidl::createMmapBuffer(int32_t minSizeFrames __unused,
@@ -516,7 +514,7 @@ status_t StreamHalAidl::legacyReleaseAudioPatch() {
status_t StreamHalAidl::sendCommand(
        const ::aidl::android::hardware::audio::core::StreamDescriptor::Command& command,
        ::aidl::android::hardware::audio::core::StreamDescriptor::Reply* reply,
        bool safeFromNonWorkerThread) {
        bool safeFromNonWorkerThread, StatePositions* statePositions) {
    // TIME_CHECK();  // TODO(b/243839867) reenable only when optimized.
    if (!safeFromNonWorkerThread) {
        const pid_t workerTid = mWorkerTid.load(std::memory_order_acquire);
@@ -548,6 +546,23 @@ status_t StreamHalAidl::sendCommand(
            }
            mLastReply = *reply;
            mLastReplyExpirationNs = uptimeNanos() + mLastReplyLifeTimeNs;
            if (!mIsInput && reply->status == STATUS_OK) {
                if (command.getTag() == StreamDescriptor::Command::standby &&
                        reply->state == StreamDescriptor::State::STANDBY) {
                    mStatePositions.framesAtStandby = reply->observable.frames;
                } else if (command.getTag() == StreamDescriptor::Command::flush &&
                           reply->state == StreamDescriptor::State::IDLE) {
                    mStatePositions.framesAtFlushOrDrain = reply->observable.frames;
                } else if (!mContext.isAsynchronous() &&
                        command.getTag() == StreamDescriptor::Command::drain &&
                        (reply->state == StreamDescriptor::State::IDLE ||
                                reply->state == StreamDescriptor::State::DRAINING)) {
                    mStatePositions.framesAtFlushOrDrain = reply->observable.frames;
                } // for asynchronous drain, the frame count is saved in 'onAsyncDrainReady'
            }
            if (statePositions != nullptr) {
                *statePositions = mStatePositions;
            }
        }
    }
    switch (reply->status) {
@@ -563,7 +578,8 @@ status_t StreamHalAidl::sendCommand(
}

status_t StreamHalAidl::updateCountersIfNeeded(
        ::aidl::android::hardware::audio::core::StreamDescriptor::Reply* reply) {
        ::aidl::android::hardware::audio::core::StreamDescriptor::Reply* reply,
        StatePositions* statePositions) {
    bool doUpdate = false;
    {
        std::lock_guard l(mLock);
@@ -573,10 +589,13 @@ status_t StreamHalAidl::updateCountersIfNeeded(
        // Since updates are paced, it is OK to perform them from any thread, they should
        // not interfere with I/O operations of the worker.
        return sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(),
                reply, true /*safeFromNonWorkerThread */);
                reply, true /*safeFromNonWorkerThread */, statePositions);
    } else if (reply != nullptr) {  // provide cached reply
        std::lock_guard l(mLock);
        *reply = mLastReply;
        if (statePositions != nullptr) {
            *statePositions = mStatePositions;
        }
    }
    return OK;
}
@@ -668,8 +687,19 @@ status_t StreamOutHalAidl::getRenderPosition(uint64_t *dspFrames) {
        return BAD_VALUE;
    }
    int64_t aidlFrames = 0, aidlTimestamp = 0;
    RETURN_STATUS_IF_ERROR(getObservablePosition(&aidlFrames, &aidlTimestamp));
    *dspFrames = aidlFrames;
    StatePositions statePositions{};
    RETURN_STATUS_IF_ERROR(
            getObservablePosition(&aidlFrames, &aidlTimestamp, &statePositions));
    // Number of audio frames since the stream has exited standby.
    // See the table at the start of 'StreamHalInterface' on when it needs to reset.
    int64_t mostRecentResetPoint;
    if (!mContext.isAsynchronous() && audio_has_proportional_frames(mConfig.format)) {
        mostRecentResetPoint = statePositions.framesAtStandby;
    } else {
        mostRecentResetPoint =
                std::max(statePositions.framesAtStandby, statePositions.framesAtFlushOrDrain);
    }
    *dspFrames = aidlFrames <= mostRecentResetPoint ? 0 : aidlFrames - mostRecentResetPoint;
    return OK;
}

@@ -726,8 +756,16 @@ status_t StreamOutHalAidl::getPresentationPosition(uint64_t *frames, struct time
        return BAD_VALUE;
    }
    int64_t aidlFrames = 0, aidlTimestamp = 0;
    RETURN_STATUS_IF_ERROR(getObservablePosition(&aidlFrames, &aidlTimestamp));
    StatePositions statePositions{};
    RETURN_STATUS_IF_ERROR(getObservablePosition(&aidlFrames, &aidlTimestamp, &statePositions));
    // See the table at the start of 'StreamHalInterface'.
    if (!mContext.isAsynchronous() && audio_has_proportional_frames(mConfig.format)) {
        *frames = aidlFrames;
    } else {
        const int64_t mostRecentResetPoint =
                std::max(statePositions.framesAtStandby, statePositions.framesAtFlushOrDrain);
        *frames = aidlFrames <= mostRecentResetPoint ? 0 : aidlFrames - mostRecentResetPoint;
    }
    timestamp->tv_sec = aidlTimestamp / NANOS_PER_SECOND;
    timestamp->tv_nsec = aidlTimestamp - timestamp->tv_sec * NANOS_PER_SECOND;
    return OK;
Loading