Loading media/codec2/sfplugin/CCodec.cpp +92 −78 Original line number Diff line number Diff line Loading @@ -1798,6 +1798,7 @@ void CCodec::release(bool sendCallback) { } status_t CCodec::setSurface(const sp<Surface> &surface) { { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; if (config->mTunneled && config->mSidebandHandle != nullptr) { Loading @@ -1811,6 +1812,7 @@ status_t CCodec::setSurface(const sp<Surface> &surface) { return err; } } } return mChannel->setSurface(surface); } Loading Loading @@ -2149,9 +2151,12 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { } // handle configuration changes in work done const C2StreamInitDataInfo::output *initData = nullptr; sp<AMessage> outputFormat = nullptr; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; Config::Watcher<C2StreamInitDataInfo::output> initData = Config::Watcher<C2StreamInitDataInfo::output> initDataWatcher = config->watch<C2StreamInitDataInfo::output>(); if (!work->worklets.empty() && (work->worklets.front()->output.flags Loading @@ -2164,10 +2169,13 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { updates.push_back(C2Param::Copy(*param)); } unsigned stream = 0; for (const std::shared_ptr<C2Buffer> &buf : work->worklets.front()->output.buffers) { std::vector<std::shared_ptr<C2Buffer>> &outputBuffers = work->worklets.front()->output.buffers; for (const std::shared_ptr<C2Buffer> &buf : outputBuffers) { for (const std::shared_ptr<const C2Info> &info : buf->info()) { // move all info into output-stream #0 domain updates.emplace_back(C2Param::CopyAsStream(*info, true /* output */, stream)); updates.emplace_back( C2Param::CopyAsStream(*info, true /* output */, stream)); } const std::vector<C2ConstGraphicBlock> blocks = buf->data().graphicBlocks(); Loading @@ -2178,16 +2186,17 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { // block.crop().width, block.crop().height, // block.width(), block.height()); const C2ConstGraphicBlock &block = blocks[0]; updates.emplace_back(new C2StreamCropRectInfo::output(stream, block.crop())); updates.emplace_back(new C2StreamCropRectInfo::output( stream, block.crop())); updates.emplace_back(new C2StreamPictureSizeInfo::output( stream, block.crop().width, block.crop().height)); } ++stream; } sp<AMessage> outputFormat = config->mOutputFormat; sp<AMessage> oldFormat = config->mOutputFormat; config->updateConfiguration(updates, config->mOutputDomain); RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat); RevertOutputFormatIfNeeded(oldFormat, config->mOutputFormat); // copy standard infos to graphic buffers if not already present (otherwise, we // may overwrite the actual intermediate value with a final value) Loading @@ -2201,7 +2210,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { C2StreamPixelAspectRatioInfo::output::PARAM_TYPE, C2StreamSurfaceScalingInfo::output::PARAM_TYPE }; for (const std::shared_ptr<C2Buffer> &buf : work->worklets.front()->output.buffers) { for (const std::shared_ptr<C2Buffer> &buf : outputBuffers) { if (buf->data().graphicBlocks().size()) { for (C2Param::Index ix : stdGfxInfos) { if (!buf->hasInfo(ix)) { Loading @@ -2220,9 +2229,10 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { if (config->mInputSurface) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } mChannel->onWorkDone( std::move(work), config->mOutputFormat, initData.hasChanged() ? initData.update().get() : nullptr); initData = initDataWatcher.hasChanged() ? initDataWatcher.update().get() : nullptr; outputFormat = config->mOutputFormat; } mChannel->onWorkDone(std::move(work), outputFormat, initData); break; } case kWhatWatch: { Loading Loading @@ -2307,9 +2317,13 @@ void CCodec::initiateReleaseIfStuck() { pendingDeadline = true; } } bool tunneled = false; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; if (config->mTunneled == false && name.empty()) { tunneled = config->mTunneled; } if (!tunneled && name.empty()) { constexpr std::chrono::steady_clock::duration kWorkDurationThreshold = 3s; std::chrono::steady_clock::duration elapsed = mChannel->elapsed(); if (elapsed >= kWorkDurationThreshold) { Loading services/oboeservice/AAudioServiceEndpoint.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,10 @@ using namespace android; // TODO just import names needed using namespace aaudio; // TODO just import names needed AAudioServiceEndpoint::~AAudioServiceEndpoint() { ALOGD("%s() called", __func__); } std::string AAudioServiceEndpoint::dump() const NO_THREAD_SAFETY_ANALYSIS { std::stringstream result; Loading services/oboeservice/AAudioServiceEndpoint.h +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ class AAudioServiceEndpoint , public AAudioStreamParameters { public: virtual ~AAudioServiceEndpoint() = default; virtual ~AAudioServiceEndpoint(); virtual std::string dump() const; Loading services/oboeservice/AAudioServiceEndpointMMAP.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ AAudioServiceEndpointMMAP::AAudioServiceEndpointMMAP(AAudioService &audioService : mMmapStream(nullptr) , mAAudioService(audioService) {} AAudioServiceEndpointMMAP::~AAudioServiceEndpointMMAP() {} std::string AAudioServiceEndpointMMAP::dump() const { std::stringstream result; Loading Loading @@ -357,7 +355,10 @@ void AAudioServiceEndpointMMAP::handleTearDownAsync(audio_port_handle_t portHand // This is called by AudioFlinger when it wants to destroy a stream. void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { ALOGD("%s(portHandle = %d) called", __func__, portHandle); std::thread asyncTask(&AAudioServiceEndpointMMAP::handleTearDownAsync, this, portHandle); android::sp<AAudioServiceEndpointMMAP> holdEndpoint(this); std::thread asyncTask([holdEndpoint, portHandle]() { holdEndpoint->handleTearDownAsync(portHandle); }); asyncTask.detach(); } Loading @@ -378,9 +379,11 @@ void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t portHandle) ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId()); if (getDeviceId() != deviceId) { if (getDeviceId() != AUDIO_PORT_HANDLE_NONE) { std::thread asyncTask([this, deviceId]() { disconnectRegisteredStreams(); setDeviceId(deviceId); android::sp<AAudioServiceEndpointMMAP> holdEndpoint(this); std::thread asyncTask([holdEndpoint, deviceId]() { ALOGD("onRoutingChanged() asyncTask launched"); holdEndpoint->disconnectRegisteredStreams(); holdEndpoint->setDeviceId(deviceId); }); asyncTask.detach(); } else { Loading services/oboeservice/AAudioServiceEndpointMMAP.h +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class AAudioServiceEndpointMMAP public: explicit AAudioServiceEndpointMMAP(android::AAudioService &audioService); virtual ~AAudioServiceEndpointMMAP(); virtual ~AAudioServiceEndpointMMAP() = default; std::string dump() const override; Loading Loading
media/codec2/sfplugin/CCodec.cpp +92 −78 Original line number Diff line number Diff line Loading @@ -1798,6 +1798,7 @@ void CCodec::release(bool sendCallback) { } status_t CCodec::setSurface(const sp<Surface> &surface) { { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; if (config->mTunneled && config->mSidebandHandle != nullptr) { Loading @@ -1811,6 +1812,7 @@ status_t CCodec::setSurface(const sp<Surface> &surface) { return err; } } } return mChannel->setSurface(surface); } Loading Loading @@ -2149,9 +2151,12 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { } // handle configuration changes in work done const C2StreamInitDataInfo::output *initData = nullptr; sp<AMessage> outputFormat = nullptr; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; Config::Watcher<C2StreamInitDataInfo::output> initData = Config::Watcher<C2StreamInitDataInfo::output> initDataWatcher = config->watch<C2StreamInitDataInfo::output>(); if (!work->worklets.empty() && (work->worklets.front()->output.flags Loading @@ -2164,10 +2169,13 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { updates.push_back(C2Param::Copy(*param)); } unsigned stream = 0; for (const std::shared_ptr<C2Buffer> &buf : work->worklets.front()->output.buffers) { std::vector<std::shared_ptr<C2Buffer>> &outputBuffers = work->worklets.front()->output.buffers; for (const std::shared_ptr<C2Buffer> &buf : outputBuffers) { for (const std::shared_ptr<const C2Info> &info : buf->info()) { // move all info into output-stream #0 domain updates.emplace_back(C2Param::CopyAsStream(*info, true /* output */, stream)); updates.emplace_back( C2Param::CopyAsStream(*info, true /* output */, stream)); } const std::vector<C2ConstGraphicBlock> blocks = buf->data().graphicBlocks(); Loading @@ -2178,16 +2186,17 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { // block.crop().width, block.crop().height, // block.width(), block.height()); const C2ConstGraphicBlock &block = blocks[0]; updates.emplace_back(new C2StreamCropRectInfo::output(stream, block.crop())); updates.emplace_back(new C2StreamCropRectInfo::output( stream, block.crop())); updates.emplace_back(new C2StreamPictureSizeInfo::output( stream, block.crop().width, block.crop().height)); } ++stream; } sp<AMessage> outputFormat = config->mOutputFormat; sp<AMessage> oldFormat = config->mOutputFormat; config->updateConfiguration(updates, config->mOutputDomain); RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat); RevertOutputFormatIfNeeded(oldFormat, config->mOutputFormat); // copy standard infos to graphic buffers if not already present (otherwise, we // may overwrite the actual intermediate value with a final value) Loading @@ -2201,7 +2210,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { C2StreamPixelAspectRatioInfo::output::PARAM_TYPE, C2StreamSurfaceScalingInfo::output::PARAM_TYPE }; for (const std::shared_ptr<C2Buffer> &buf : work->worklets.front()->output.buffers) { for (const std::shared_ptr<C2Buffer> &buf : outputBuffers) { if (buf->data().graphicBlocks().size()) { for (C2Param::Index ix : stdGfxInfos) { if (!buf->hasInfo(ix)) { Loading @@ -2220,9 +2229,10 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { if (config->mInputSurface) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } mChannel->onWorkDone( std::move(work), config->mOutputFormat, initData.hasChanged() ? initData.update().get() : nullptr); initData = initDataWatcher.hasChanged() ? initDataWatcher.update().get() : nullptr; outputFormat = config->mOutputFormat; } mChannel->onWorkDone(std::move(work), outputFormat, initData); break; } case kWhatWatch: { Loading Loading @@ -2307,9 +2317,13 @@ void CCodec::initiateReleaseIfStuck() { pendingDeadline = true; } } bool tunneled = false; { Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; if (config->mTunneled == false && name.empty()) { tunneled = config->mTunneled; } if (!tunneled && name.empty()) { constexpr std::chrono::steady_clock::duration kWorkDurationThreshold = 3s; std::chrono::steady_clock::duration elapsed = mChannel->elapsed(); if (elapsed >= kWorkDurationThreshold) { Loading
services/oboeservice/AAudioServiceEndpoint.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,10 @@ using namespace android; // TODO just import names needed using namespace aaudio; // TODO just import names needed AAudioServiceEndpoint::~AAudioServiceEndpoint() { ALOGD("%s() called", __func__); } std::string AAudioServiceEndpoint::dump() const NO_THREAD_SAFETY_ANALYSIS { std::stringstream result; Loading
services/oboeservice/AAudioServiceEndpoint.h +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ class AAudioServiceEndpoint , public AAudioStreamParameters { public: virtual ~AAudioServiceEndpoint() = default; virtual ~AAudioServiceEndpoint(); virtual std::string dump() const; Loading
services/oboeservice/AAudioServiceEndpointMMAP.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -51,8 +51,6 @@ AAudioServiceEndpointMMAP::AAudioServiceEndpointMMAP(AAudioService &audioService : mMmapStream(nullptr) , mAAudioService(audioService) {} AAudioServiceEndpointMMAP::~AAudioServiceEndpointMMAP() {} std::string AAudioServiceEndpointMMAP::dump() const { std::stringstream result; Loading Loading @@ -357,7 +355,10 @@ void AAudioServiceEndpointMMAP::handleTearDownAsync(audio_port_handle_t portHand // This is called by AudioFlinger when it wants to destroy a stream. void AAudioServiceEndpointMMAP::onTearDown(audio_port_handle_t portHandle) { ALOGD("%s(portHandle = %d) called", __func__, portHandle); std::thread asyncTask(&AAudioServiceEndpointMMAP::handleTearDownAsync, this, portHandle); android::sp<AAudioServiceEndpointMMAP> holdEndpoint(this); std::thread asyncTask([holdEndpoint, portHandle]() { holdEndpoint->handleTearDownAsync(portHandle); }); asyncTask.detach(); } Loading @@ -378,9 +379,11 @@ void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t portHandle) ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId()); if (getDeviceId() != deviceId) { if (getDeviceId() != AUDIO_PORT_HANDLE_NONE) { std::thread asyncTask([this, deviceId]() { disconnectRegisteredStreams(); setDeviceId(deviceId); android::sp<AAudioServiceEndpointMMAP> holdEndpoint(this); std::thread asyncTask([holdEndpoint, deviceId]() { ALOGD("onRoutingChanged() asyncTask launched"); holdEndpoint->disconnectRegisteredStreams(); holdEndpoint->setDeviceId(deviceId); }); asyncTask.detach(); } else { Loading
services/oboeservice/AAudioServiceEndpointMMAP.h +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class AAudioServiceEndpointMMAP public: explicit AAudioServiceEndpointMMAP(android::AAudioService &audioService); virtual ~AAudioServiceEndpointMMAP(); virtual ~AAudioServiceEndpointMMAP() = default; std::string dump() const override; Loading