Loading media/codec2/hal/client/client.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -2370,6 +2370,11 @@ void Codec2Client::Component::stopUsingOutputSurface( mOutputBufferQueue->expireOldWaiters(); } void Codec2Client::Component::onBufferReleasedFromOutputSurface( uint32_t generation) { (void) generation; } c2_status_t Codec2Client::Component::connectToInputSurface( const std::shared_ptr<InputSurface>& inputSurface, std::shared_ptr<InputSurfaceConnection>* connection) { Loading media/codec2/hal/client/include/codec2/hidl/client.h +4 −0 Original line number Diff line number Diff line Loading @@ -474,6 +474,10 @@ struct Codec2Client::Component : public Codec2Client::Configurable { void stopUsingOutputSurface( C2BlockPool::local_id_t blockPoolId); // Notify a buffer is released from output surface. void onBufferReleasedFromOutputSurface( uint32_t generation); // Connect to a given InputSurface. c2_status_t connectToInputSurface( const std::shared_ptr<InputSurface>& inputSurface, Loading media/codec2/sfplugin/CCodec.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -862,6 +862,8 @@ void CCodec::configure(const sp<AMessage> &msg) { sp<Surface> surface; if (msg->findObject("native-window", &obj)) { surface = static_cast<Surface *>(obj.get()); int32_t generation; (void)msg->findInt32("native-window-generation", &generation); // setup tunneled playback if (surface != nullptr) { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -896,7 +898,7 @@ void CCodec::configure(const sp<AMessage> &msg) { } } } setSurface(surface); setSurface(surface, (uint32_t)generation); } Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2033,7 +2035,7 @@ void CCodec::release(bool sendCallback, bool pushBlankBuffer) { } } status_t CCodec::setSurface(const sp<Surface> &surface) { status_t CCodec::setSurface(const sp<Surface> &surface, uint32_t generation) { bool pushBlankBuffer = false; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2062,7 +2064,7 @@ status_t CCodec::setSurface(const sp<Surface> &surface) { } pushBlankBuffer = config->mPushBlankBuffersOnStop; } return mChannel->setSurface(surface, pushBlankBuffer); return mChannel->setSurface(surface, generation, pushBlankBuffer); } void CCodec::signalFlush() { Loading media/codec2/sfplugin/CCodecBufferChannel.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -1121,6 +1121,10 @@ void CCodecBufferChannel::pollForRenderedBuffers() { processRenderedFrames(delta); } void CCodecBufferChannel::onBufferReleasedFromOutputSurface(uint32_t generation) { mComponent->onBufferReleasedFromOutputSurface(generation); } status_t CCodecBufferChannel::discardBuffer(const sp<MediaCodecBuffer> &buffer) { ALOGV("[%s] discardBuffer: %p", mName, buffer.get()); bool released = false; Loading Loading @@ -2265,12 +2269,8 @@ void CCodecBufferChannel::sendOutputBuffers() { } } status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, bool pushBlankBuffer) { static std::atomic_uint32_t surfaceGeneration{0}; uint32_t generation = (getpid() << 10) | ((surfaceGeneration.fetch_add(1, std::memory_order_relaxed) + 1) & ((1 << 10) - 1)); status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, uint32_t generation, bool pushBlankBuffer) { sp<IGraphicBufferProducer> producer; int maxDequeueCount; sp<Surface> oldSurface; Loading @@ -2284,7 +2284,6 @@ status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, bool pus newSurface->setDequeueTimeout(kDequeueTimeoutNs); newSurface->setMaxDequeuedBufferCount(maxDequeueCount); producer = newSurface->getIGraphicBufferProducer(); producer->setGenerationNumber(generation); } else { ALOGE("[%s] setting output surface to null", mName); return INVALID_OPERATION; Loading media/codec2/sfplugin/CCodecBufferChannel.h +2 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ public: status_t renderOutputBuffer( const sp<MediaCodecBuffer> &buffer, int64_t timestampNs) override; void pollForRenderedBuffers() override; void onBufferReleasedFromOutputSurface(uint32_t generation) override; status_t discardBuffer(const sp<MediaCodecBuffer> &buffer) override; void getInputBufferArray(Vector<sp<MediaCodecBuffer>> *array) override; void getOutputBufferArray(Vector<sp<MediaCodecBuffer>> *array) override; Loading @@ -105,7 +106,7 @@ public: /** * Set output graphic surface for rendering. */ status_t setSurface(const sp<Surface> &surface, bool pushBlankBuffer); status_t setSurface(const sp<Surface> &surface, uint32_t generation, bool pushBlankBuffer); /** * Set GraphicBufferSource object from which the component extracts input Loading Loading
media/codec2/hal/client/client.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -2370,6 +2370,11 @@ void Codec2Client::Component::stopUsingOutputSurface( mOutputBufferQueue->expireOldWaiters(); } void Codec2Client::Component::onBufferReleasedFromOutputSurface( uint32_t generation) { (void) generation; } c2_status_t Codec2Client::Component::connectToInputSurface( const std::shared_ptr<InputSurface>& inputSurface, std::shared_ptr<InputSurfaceConnection>* connection) { Loading
media/codec2/hal/client/include/codec2/hidl/client.h +4 −0 Original line number Diff line number Diff line Loading @@ -474,6 +474,10 @@ struct Codec2Client::Component : public Codec2Client::Configurable { void stopUsingOutputSurface( C2BlockPool::local_id_t blockPoolId); // Notify a buffer is released from output surface. void onBufferReleasedFromOutputSurface( uint32_t generation); // Connect to a given InputSurface. c2_status_t connectToInputSurface( const std::shared_ptr<InputSurface>& inputSurface, Loading
media/codec2/sfplugin/CCodec.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -862,6 +862,8 @@ void CCodec::configure(const sp<AMessage> &msg) { sp<Surface> surface; if (msg->findObject("native-window", &obj)) { surface = static_cast<Surface *>(obj.get()); int32_t generation; (void)msg->findInt32("native-window-generation", &generation); // setup tunneled playback if (surface != nullptr) { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -896,7 +898,7 @@ void CCodec::configure(const sp<AMessage> &msg) { } } } setSurface(surface); setSurface(surface, (uint32_t)generation); } Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2033,7 +2035,7 @@ void CCodec::release(bool sendCallback, bool pushBlankBuffer) { } } status_t CCodec::setSurface(const sp<Surface> &surface) { status_t CCodec::setSurface(const sp<Surface> &surface, uint32_t generation) { bool pushBlankBuffer = false; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); Loading Loading @@ -2062,7 +2064,7 @@ status_t CCodec::setSurface(const sp<Surface> &surface) { } pushBlankBuffer = config->mPushBlankBuffersOnStop; } return mChannel->setSurface(surface, pushBlankBuffer); return mChannel->setSurface(surface, generation, pushBlankBuffer); } void CCodec::signalFlush() { Loading
media/codec2/sfplugin/CCodecBufferChannel.cpp +6 −7 Original line number Diff line number Diff line Loading @@ -1121,6 +1121,10 @@ void CCodecBufferChannel::pollForRenderedBuffers() { processRenderedFrames(delta); } void CCodecBufferChannel::onBufferReleasedFromOutputSurface(uint32_t generation) { mComponent->onBufferReleasedFromOutputSurface(generation); } status_t CCodecBufferChannel::discardBuffer(const sp<MediaCodecBuffer> &buffer) { ALOGV("[%s] discardBuffer: %p", mName, buffer.get()); bool released = false; Loading Loading @@ -2265,12 +2269,8 @@ void CCodecBufferChannel::sendOutputBuffers() { } } status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, bool pushBlankBuffer) { static std::atomic_uint32_t surfaceGeneration{0}; uint32_t generation = (getpid() << 10) | ((surfaceGeneration.fetch_add(1, std::memory_order_relaxed) + 1) & ((1 << 10) - 1)); status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, uint32_t generation, bool pushBlankBuffer) { sp<IGraphicBufferProducer> producer; int maxDequeueCount; sp<Surface> oldSurface; Loading @@ -2284,7 +2284,6 @@ status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, bool pus newSurface->setDequeueTimeout(kDequeueTimeoutNs); newSurface->setMaxDequeuedBufferCount(maxDequeueCount); producer = newSurface->getIGraphicBufferProducer(); producer->setGenerationNumber(generation); } else { ALOGE("[%s] setting output surface to null", mName); return INVALID_OPERATION; Loading
media/codec2/sfplugin/CCodecBufferChannel.h +2 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ public: status_t renderOutputBuffer( const sp<MediaCodecBuffer> &buffer, int64_t timestampNs) override; void pollForRenderedBuffers() override; void onBufferReleasedFromOutputSurface(uint32_t generation) override; status_t discardBuffer(const sp<MediaCodecBuffer> &buffer) override; void getInputBufferArray(Vector<sp<MediaCodecBuffer>> *array) override; void getOutputBufferArray(Vector<sp<MediaCodecBuffer>> *array) override; Loading @@ -105,7 +106,7 @@ public: /** * Set output graphic surface for rendering. */ status_t setSurface(const sp<Surface> &surface, bool pushBlankBuffer); status_t setSurface(const sp<Surface> &surface, uint32_t generation, bool pushBlankBuffer); /** * Set GraphicBufferSource object from which the component extracts input Loading