Skip to content

VPLAY-12261: Tune time improvement with preinit Decoder Functionality…#1120

Closed
psiva01 wants to merge 1 commit intosupport/2.11.1_8.4from
feature/VPLAY-12261_8.4
Closed

VPLAY-12261: Tune time improvement with preinit Decoder Functionality…#1120
psiva01 wants to merge 1 commit intosupport/2.11.1_8.4from
feature/VPLAY-12261_8.4

Conversation

@psiva01
Copy link
Copy Markdown
Contributor

@psiva01 psiva01 commented Mar 3, 2026

… 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)

… 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>
@psiva01 psiva01 requested a review from a team as a code owner March 3, 2026 12:45
Copilot AI review requested due to automatic review settings March 3, 2026 12:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +4149 to +4151
#ifdef USE_PREINIT_DECODING
doFakeTune();
#endif
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
#ifdef USE_PREINIT_DECODING
doFakeTune();
#endif

Copilot uses AI. Check for mistakes.
Comment thread priv_aamp.cpp
Comment on lines +2770 to 2778
#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);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread main_aamp.h
Comment on lines +81 to +82
void doFakeTune();
#define FAKE_TUNE_URL "file:///etc/manifest.mpd" /**< Fake tune URL for testing purposes */
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread priv_aamp.h
#include "TextTrackInfo.h"
#include "AAMPAnomalyMessageType.h"

#define FAKE_TUNE_URL "file:///etc/manifest.mpd" /**< Fake tune URL for testing purposes */
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
#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 */

Copilot uses AI. Check for mistakes.
Comment thread drm/AampDRMLicManager.cpp
#ifdef USE_PREINIT_DECODING
if(aampInstance->mManifestUrl == FAKE_TUNE_URL)
{
return code;
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +151
if(pInstance->GetDoFakeTuneCallBack())
{
MW_LOG_INFO("Calling Fake tune callback");
pInstance->GetDoFakeTuneCallBack()();
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
Comment on lines +128 to +134
#ifdef USE_PREINIT_DECODING
if(!IsContainerEnvironment())
{
MW_LOG_INFO("\nCalling terminatePowerController()");
terminatePowerController();
}
#endif
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +219 to +223
/**
* @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);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@psiva01 psiva01 closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants