VPLAY-12261: Tune time improvement with preinit Decoder Functionality…#1120
VPLAY-12261: Tune time improvement with preinit Decoder Functionality…#1120psiva01 wants to merge 1 commit intosupport/2.11.1_8.4from
Conversation
… applicable to Sky UK Stream Boxes (#797) RDKEMW-8209: Fake tune integrated with IARM Reason for Change: RCA : Trigger the fake tune only when the device transitions from DEEPSLEEP to ON/STANDBY, we can make sure that HDMI is in the expected state and the playback should work as expected. This pull request implements a decoder pre-initialization feature for Sky UK Stream Boxes to improve tune time. The solution uses a "fake tune" mechanism that pre-warms the decoder when the device transitions from deep sleep to active power states (ON or STANDBY). The implementation integrates with the WPEFramework PowerController to monitor power state changes and trigger the fake tune at appropriate times. Key changes: Integration of PowerController to monitor power state transitions via Thunder/WPEFramework Implementation of a fake tune mechanism using a dummy manifest URL to initialize decoder resources Addition of special handling throughout the codebase to suppress errors and metrics for fake tune operations Test Guidance: refer ticket Risk: Low (has been patched to releases) --------- Signed-off-by: Alsameema <alsameema_ahmedansar@comcast.com> Signed-off-by: Anurag Krishnan <akrish513@cable.comcast.com> Co-authored-by: aahmed878 <Alsameema_Ahmedansar@comcast.com> Co-authored-by: nrames759 <Naren_Ramesh@comcast.com> Co-authored-by: narenr94 <51772499+narenr94@users.noreply.github.com> Co-authored-by: pstroffolino <Philip_Stroffolino@cable.comcast.com>
There was a problem hiding this comment.
Pull request overview
Implements decoder pre-initialization (“fake tune”) to improve tune time on Sky UK Stream Boxes by triggering a warm-up tune on power-state transitions from deep sleep, while suppressing errors/metrics generated by that warm-up flow.
Changes:
- Adds power-event monitoring via PowerController and a callback path to trigger a fake tune.
- Introduces fake-tune suppression for error events, tune metrics, and DRM/licensing paths.
- Extends player/external interfaces and build flags to enable preinit decoding.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| test/utests/fakes/FakePlayerInstanceAamp.cpp | Updates fake PlayerInstanceAAMP ctor signature for new powerEvt arg. |
| test/utests/fakes/FakePlayerExternalsInterface.cpp | Adds stubbed externals APIs for power event + fake-tune callback. |
| priv_aamp.h | Introduces FAKE_TUNE_URL macro used to identify fake tune sessions. |
| priv_aamp.cpp | Suppresses error events and tune-end metrics during fake tune. |
| middleware/externals/rdk/PlayerExternalsRdkInterface.h | Adds power-event flag + fake-tune callback storage to RDK externals interface. |
| middleware/externals/rdk/PlayerExternalsRdkInterface.cpp | Implements setters/getters for power-event flag and fake-tune callback. |
| middleware/externals/rdk/IIarm/DeviceIARMInterface.cpp | Integrates PowerController, monitors power transitions, triggers fake tune in a thread. |
| middleware/externals/PlayerExternalsInterfaceBase.h | Extends externals base interface with power-event + callback APIs. |
| middleware/externals/PlayerExternalsInterface.h | Adds stub implementations and forwards new APIs on PlayerExternalsInterface. |
| middleware/externals/PlayerExternalsInterface.cpp | Implements forwarding methods + adds IsDevicePropertiesPresent(). |
| middleware/externals/CMakeLists.txt | Adds include path and links PowerController when preinit is enabled. |
| main_aamp.h | Declares doFakeTune() and extends PlayerInstanceAAMP ctor with powerEvt. |
| main_aamp.cpp | Implements doFakeTune(), wires callback + powerEvt into externals initialization. |
| jsbindings/jsmediaplayer.cpp | Triggers doFakeTune() during JS load when preinit is enabled. |
| jsbindings/jsbindings.cpp | Constructs PlayerInstanceAAMP with powerEvt=true for JS bindings path. |
| drm/AampDRMLicManager.cpp | Short-circuits license acquisition for fake tune URL. |
| CMakeLists.txt | Adds preinit compile defines for core + jsbindings. |
| AampDRMLicPreFetcher.cpp | Skips DRM failure error event when mIsFakeTune is set. |
| #ifdef USE_PREINIT_DECODING | ||
| doFakeTune(); | ||
| #endif |
There was a problem hiding this comment.
doFakeTune() is invoked during JS load, which will trigger a fake tune on every startup/init rather than “only when the device transitions from DEEPSLEEP to ON/STANDBY” (as described in the PR). This makes the behavior unconditional and can cause unintended background decoder warmups unrelated to the power transition logic; consider removing this call and relying solely on the PowerController transition callback path (or gating it behind an explicit power-transition condition/flag).
| #ifdef USE_PREINIT_DECODING | |
| doFakeTune(); | |
| #endif |
| #ifdef USE_PREINIT_DECODING | ||
| if(mManifestUrl.compare(FAKE_TUNE_URL) == 0) | ||
| { | ||
| AAMPLOG_WARN("PrivateInstanceAAMP: Ignore error for fake tune"); | ||
| return; | ||
| } | ||
| #endif | ||
| bool sendErrorEvent = false; | ||
| std::unique_lock<std::recursive_mutex> lock(mLock); |
There was a problem hiding this comment.
mManifestUrl is read before mLock is acquired, while the rest of SendErrorEvent assumes locking for state/fields. This creates an inconsistent synchronization boundary (and risks a data race if mManifestUrl can be modified under the lock elsewhere). Move the fake-tune check to after the lock acquisition, or prefer a dedicated fake-tune flag (e.g., mIsFakeTune, which is already used in other diffs) that is safely read under the same locking scheme.
| void doFakeTune(); | ||
| #define FAKE_TUNE_URL "file:///etc/manifest.mpd" /**< Fake tune URL for testing purposes */ |
There was a problem hiding this comment.
FAKE_TUNE_URL is defined here and also in priv_aamp.h, which can cause macro redefinition warnings and makes the “fake tune identifier” harder to keep consistent across the codebase. Define it once in a single shared header (or replace the macro with a single constexpr constant) and include that where needed.
| #include "TextTrackInfo.h" | ||
| #include "AAMPAnomalyMessageType.h" | ||
|
|
||
| #define FAKE_TUNE_URL "file:///etc/manifest.mpd" /**< Fake tune URL for testing purposes */ |
There was a problem hiding this comment.
FAKE_TUNE_URL is duplicated with the definition in main_aamp.h. Keeping two macro definitions synchronized is error-prone; consolidate into one shared definition (preferably a constexpr constant) and include/reuse it.
| #define FAKE_TUNE_URL "file:///etc/manifest.mpd" /**< Fake tune URL for testing purposes */ | |
| static constexpr const char FAKE_TUNE_URL[] = "file:///etc/manifest.mpd"; /**< Fake tune URL for testing purposes */ |
| #ifdef USE_PREINIT_DECODING | ||
| if(aampInstance->mManifestUrl == FAKE_TUNE_URL) | ||
| { | ||
| return code; |
There was a problem hiding this comment.
In the fake-tune case this returns code while it is still initialized to KEY_ERROR, which will deterministically mark fake tune license acquisition as an error. That can cause the fake tune to fail early and may prevent the pipeline from reaching the decoder warm-up stages (depending on the DRM/playback flow). If the intent is “skip licensing but allow fake tune to proceed far enough to preinit the decoder,” return a non-error key state that indicates “no license needed / proceed” for this path, or ensure fake tune is configured to avoid navigating DRM/license acquisition in the first place.
| return code; | |
| // For fake-tune preinit, skip licensing but indicate a non-error state so | |
| // that the pipeline can proceed to decoder warm-up stages. | |
| return KEY_PENDING; |
| if(pInstance->GetDoFakeTuneCallBack()) | ||
| { | ||
| MW_LOG_INFO("Calling Fake tune callback"); | ||
| pInstance->GetDoFakeTuneCallBack()(); |
There was a problem hiding this comment.
GetDoFakeTuneCallBack() is invoked twice; if another thread changes/clears the callback between the null-check and the call, this can still crash or behave inconsistently. Store the callback in a local variable once (copy the std::function) and then check/call that local value.
| if(pInstance->GetDoFakeTuneCallBack()) | |
| { | |
| MW_LOG_INFO("Calling Fake tune callback"); | |
| pInstance->GetDoFakeTuneCallBack()(); | |
| auto fakeTuneCallback = pInstance->GetDoFakeTuneCallBack(); | |
| if (fakeTuneCallback) | |
| { | |
| MW_LOG_INFO("Calling Fake tune callback"); | |
| fakeTuneCallback(); |
| #ifdef USE_PREINIT_DECODING | ||
| if(!IsContainerEnvironment()) | ||
| { | ||
| MW_LOG_INFO("\nCalling terminatePowerController()"); | ||
| terminatePowerController(); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
terminatePowerController() unconditionally calls PowerController_UnRegisterPowerModeChangedCallback and PowerController_Term() (later in this diff) even if the PowerController was never initialized/connected/registered in this process. That can produce incorrect teardown behavior or errors depending on the PowerController implementation. Track an “initialized/registered” state flag (set only after successful registration) and only unregister/term when that flag is true.
| /** | ||
| * @brief Set callback function for fake tune operations | ||
| * @param[in] t_doFakeTuneCallback Function to call for fake tune operations | ||
| */ | ||
| void SetDoFakeTuneCallBack(const std::function<void()>& t_doFakeTuneCallback); |
There was a problem hiding this comment.
PlayerExternalsInterfaceBase adds both setter and getter for the fake-tune callback, and PlayerExternalsRdkInterface implements both, but PlayerExternalsInterface only exposes the setter (no corresponding getter). This breaks the abstraction and encourages platform-specific access (as seen in DeviceIARMInterface.cpp using PlayerExternalsRdkInterface directly). Add a GetDoFakeTuneCallBack() forwarder to PlayerExternalsInterface for a complete, platform-agnostic API.
… applicable to Sky UK Stream Boxes (#797)
RDKEMW-8209: Fake tune integrated with IARM
Reason for Change:
RCA : Trigger the fake tune only when the device transitions from DEEPSLEEP to ON/STANDBY, we can make sure that HDMI is in the expected state and the playback should work as expected.
This pull request implements a decoder pre-initialization feature for Sky UK Stream Boxes to improve tune time. The solution uses a "fake tune" mechanism that pre-warms the decoder when the device transitions from deep sleep to active power states (ON or STANDBY). The implementation integrates with the WPEFramework PowerController to monitor power state changes and trigger the fake tune at appropriate times. Key changes:
Integration of PowerController to monitor power state transitions via Thunder/WPEFramework Implementation of a fake tune mechanism using a dummy manifest URL to initialize decoder resources Addition of special handling throughout the codebase to suppress errors and metrics for fake tune operations
Test Guidance: refer ticket
Risk: Low (has been patched to releases)