Skip to content

Commit

Permalink
Merge pull request rdkcentral#3103 from acheri988/sprint_2208_25-Aug-…
Browse files Browse the repository at this point in the history
…2022-16-52-12

RDKTV-18719 : WpeFramework crash fix
  • Loading branch information
anand-ky authored Aug 25, 2022
2 parents ccd805d + e8859e1 commit 59088b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
33 changes: 17 additions & 16 deletions DisplaySettings/DisplaySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,18 @@ namespace WPEFramework {

m_subscribed = false; //HdmiCecSink event subscription
m_hdmiInAudioDeviceConnected = false;
m_arcAudioEnabled = false;
m_arcAudioEnabled = false;
m_hdmiCecAudioDeviceDetected = false;
m_hdmiInAudioDevicePowerState = AUDIO_DEVICE_POWER_STATE_UNKNOWN;
m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED;
m_cecArcRoutingThreadRun = false;
isCecArcRoutingThreadEnabled = true;
m_isPwrMgr2RFCEnabled = false;
m_arcRoutingThread = std::thread(cecArcRoutingThread);
m_timer.connect(std::bind(&DisplaySettings::onTimer, this));
m_AudioDeviceDetectTimer.connect(std::bind(&DisplaySettings::checkAudioDeviceDetectionTimer, this));
}

DisplaySettings::~DisplaySettings()
{
LOGINFO("dtor ");
stopCecTimeAndUnsubscriveEvent();
LOGINFO ("dtor");
}

void DisplaySettings::AudioPortsReInitialize()
Expand Down Expand Up @@ -493,6 +489,10 @@ namespace WPEFramework {

const string DisplaySettings::Initialize(PluginHost::IShell* /* service */)
{
m_arcRoutingThread = std::thread(cecArcRoutingThread);
m_timer.connect(std::bind(&DisplaySettings::onTimer, this));
m_AudioDeviceDetectTimer.connect(std::bind(&DisplaySettings::checkAudioDeviceDetectionTimer, this));

InitializeIARM();

if (IARM_BUS_PWRMGR_POWERSTATE_ON == getSystemPowerState())
Expand Down Expand Up @@ -533,7 +533,7 @@ namespace WPEFramework {
{
LOGERR("exception in thread join %s", e.what());
}
stopCecTimeAndUnsubscriveEvent();
stopCecTimeAndUnsubscribeEvent();

DeinitializeIARM();
DisplaySettings::_instance = nullptr;
Expand Down Expand Up @@ -4321,7 +4321,7 @@ namespace WPEFramework {
if(m_client == nullptr)
{
Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T("127.0.0.1:9998")));
m_client = (WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>*)new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(HDMICECSINK_CALLSIGN_VER), (_T(HDMICECSINK_CALLSIGN_VER)));
m_client = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T(HDMICECSINK_CALLSIGN_VER), (_T(HDMICECSINK_CALLSIGN_VER)));
LOGINFO("DisplaySettings getHdmiCecSinkPlugin init m_client\n");
}
}
Expand Down Expand Up @@ -4905,8 +4905,8 @@ namespace WPEFramework {
LOGINFO("updated isCecEnabled [%d] ... \n", isCecEnabled);
}

void DisplaySettings::stopCecTimeAndUnsubscriveEvent() {
LOGINFO("de-init cec timer and subscribbed event ");
void DisplaySettings::stopCecTimeAndUnsubscribeEvent() {
LOGINFO ("de-init cec timer and subscribbed event \n");
{
lock_guard<mutex> lck(m_callMutex);
if ( m_timer.isActive()) {
Expand All @@ -4916,13 +4916,14 @@ namespace WPEFramework {
if ( m_AudioDeviceDetectTimer.isActive()) {
m_AudioDeviceDetectTimer.stop();
}
for (std::string eventName : m_clientRegisteredEventNames) {
m_client->Unsubscribe(1000, _T(eventName));
LOGINFO("Unsubscribing event %s", eventName.c_str());
}
m_clientRegisteredEventNames.clear();
if (nullptr != m_client) {
LOGINFO("deleting m_client ");
for (std::string eventName : m_clientRegisteredEventNames) {
m_client->Unsubscribe(1000, _T(eventName));
LOGINFO ("Unsubscribing event %s\n", eventName.c_str());
}
m_clientRegisteredEventNames.clear();

LOGINFO ("deleting m_client \n");
delete m_client; m_client = nullptr;
}
}
Expand Down
2 changes: 1 addition & 1 deletion DisplaySettings/DisplaySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace WPEFramework {
bool getHdmiCecSinkAudioDeviceConnectedStatus();
static void cecArcRoutingThread();
void onTimer();
void stopCecTimeAndUnsubscriveEvent();
void stopCecTimeAndUnsubscribeEvent();
void checkAudioDeviceDetectionTimer();

TpTimer m_timer;
Expand Down

0 comments on commit 59088b3

Please sign in to comment.