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

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

Snap for 9957928 from 06f98204 to udc-release

Change-Id: I385933d4788e9205284da6bd8a984380165271d6
parents 9239d521 06f98204
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@ CCodecBufferChannel::CCodecBufferChannel(
      mCCodecCallback(callback),
      mFrameIndex(0u),
      mFirstValidFrameIndex(0u),
      mIsSurfaceToDisplay(false),
      mHasPresentFenceTimes(false),
      mMetaMode(MODE_NONE),
      mInputMetEos(false),
      mSendEncryptedInfoBuffer(false) {
@@ -988,20 +990,36 @@ status_t CCodecBufferChannel::renderOutputBuffer(

    int64_t mediaTimeUs = 0;
    (void)buffer->meta()->findInt64("timeUs", &mediaTimeUs);
    if (mIsSurfaceToDisplay) {
        trackReleasedFrame(qbo, mediaTimeUs, timestampNs);
        processRenderedFrames(qbo.frameTimestamps);
    } else {
        // When the surface is an intermediate surface, onFrameRendered is triggered immediately
        // when the frame is queued to the non-display surface
        mCCodecCallback->onOutputFramesRendered(mediaTimeUs, timestampNs);
    }

    return OK;
}

void CCodecBufferChannel::initializeFrameTrackingFor(ANativeWindow * window) {
    mTrackedFrames.clear();

    int isSurfaceToDisplay = 0;
    window->query(window, NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER, &isSurfaceToDisplay);
    mIsSurfaceToDisplay = isSurfaceToDisplay == 1;
    // No frame tracking is needed if we're not sending frames to the display
    if (!mIsSurfaceToDisplay) {
        // Return early so we don't call into SurfaceFlinger (requiring permissions)
        return;
    }

    int hasPresentFenceTimes = 0;
    window->query(window, NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT, &hasPresentFenceTimes);
    mHasPresentFenceTimes = hasPresentFenceTimes == 1;
    if (mHasPresentFenceTimes) {
        ALOGI("Using latch times for frame rendered signals - present fences not supported");
    }
    mTrackedFrames.clear();
}

void CCodecBufferChannel::trackReleasedFrame(const IGraphicBufferProducer::QueueBufferOutput& qbo,
+1 −0
Original line number Diff line number Diff line
@@ -331,6 +331,7 @@ private:
    sp<MemoryDealer> makeMemoryDealer(size_t heapSize);

    std::deque<TrackedFrame> mTrackedFrames;
    bool mIsSurfaceToDisplay;
    bool mHasPresentFenceTimes;

    struct OutputSurface {
+2 −0
Original line number Diff line number Diff line
@@ -425,6 +425,8 @@ public:

    bool        btNrecIsOff() const { return mBtNrecIsOff.load(); }

    void             lock() ACQUIRE(mLock) { mLock.lock(); }
    void             unlock() RELEASE(mLock) { mLock.unlock(); }

private:

+8 −2
Original line number Diff line number Diff line
@@ -135,6 +135,10 @@ status_t AudioFlinger::PatchPanel::getAudioPort(struct audio_port_v7 *port)
status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *patch,
                                   audio_patch_handle_t *handle,
                                   bool endpointPatch)
 //unlocks AudioFlinger::mLock when calling ThreadBase::sendCreateAudioPatchConfigEvent
 //to avoid deadlocks if the thread loop needs to acquire AudioFlinger::mLock
 //before processing the create patch request.
 NO_THREAD_SAFETY_ANALYSIS
{
    if (handle == NULL || patch == NULL) {
        return BAD_VALUE;
@@ -245,7 +249,6 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
                        status = INVALID_OPERATION;
                        goto exit;
                    }

                    sp<ThreadBase> thread =
                            mAudioFlinger.checkPlaybackThread_l(patch->sources[1].ext.mix.handle);
                    if (thread == 0) {
@@ -356,11 +359,12 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
                            goto exit;
                        }
                    }
                    mAudioFlinger.unlock();
                    status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle);
                    mAudioFlinger.lock();
                    if (status == NO_ERROR) {
                        newPatch.setThread(thread);
                    }

                    // remove stale audio patch with same input as sink if any
                    for (auto& iter : mPatches) {
                        if (iter.second.mAudioPatch.sinks[0].ext.mix.handle == thread->id()) {
@@ -422,7 +426,9 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
                mAudioFlinger.updateOutDevicesForRecordThreads_l(devices);
            }

            mAudioFlinger.unlock();
            status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle);
            mAudioFlinger.lock();
            if (status == NO_ERROR) {
                newPatch.setThread(thread);
            }
+6 −6
Original line number Diff line number Diff line
@@ -4976,7 +4976,7 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
        const NBAIO_Format offersFast[1] = {format};
        size_t numCounterOffersFast = 0;
#if !LOG_NDEBUG
        ssize_t index =
        index =
#else
        (void)
#endif
@@ -7874,15 +7874,15 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger,
        Pipe *pipe = new Pipe(pipeFramesP2, format, pipeBuffer);
        const NBAIO_Format offersFast[1] = {format};
        size_t numCounterOffersFast = 0;
        [[maybe_unused]] ssize_t index = pipe->negotiate(offersFast, std::size(offersFast),
        [[maybe_unused]] ssize_t index2 = pipe->negotiate(offersFast, std::size(offersFast),
                nullptr /* counterOffers */, numCounterOffersFast);
        ALOG_ASSERT(index == 0);
        ALOG_ASSERT(index2 == 0);
        mPipeSink = pipe;
        PipeReader *pipeReader = new PipeReader(*pipe);
        numCounterOffersFast = 0;
        index = pipeReader->negotiate(offersFast, std::size(offersFast),
        index2 = pipeReader->negotiate(offersFast, std::size(offersFast),
                nullptr /* counterOffers */, numCounterOffersFast);
        ALOG_ASSERT(index == 0);
        ALOG_ASSERT(index2 == 0);
        mPipeSource = pipeReader;
        mPipeFramesP2 = pipeFramesP2;
        mPipeMemory = pipeMemory;
@@ -9297,7 +9297,7 @@ void AudioFlinger::RecordThread::ResamplerBufferProvider::releaseBuffer(
    if (stepCount == 0) {
        return;
    }
    ALOG_ASSERT(stepCount <= mRsmpInUnrel);
    ALOG_ASSERT(stepCount <= (int32_t)mRsmpInUnrel);
    mRsmpInUnrel -= stepCount;
    mRsmpInFront = audio_utils::safe_add_overflow(mRsmpInFront, stepCount);
    buffer->raw = NULL;