Skip to content

Commit

Permalink
RDKTV-18719 : WpeFramework crash fix
Browse files Browse the repository at this point in the history
Reason for change:
HdmiCecSink shared_ptr cross reference in DisplaySettings
plugin is removed.
Test Procedure: None
Risks: Low

Change-Id: I8183fc1563422a1c2a0365504c98e09cc4037267
Signed-off-by:Anooj Cheriyan <[email protected]>
(cherry picked from commit e8859e1)
  • Loading branch information
acheri988 committed Sep 1, 2022
1 parent d750b15 commit 92ae90a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
4 changes: 4 additions & 0 deletions DisplaySettings/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

##[1.0.6] - 2022-09-01
### Changed
- Fixed DisplaySettings dtor crash in LinkType

##[1.0.5] - 2022-09-01
### Changed
- Fixed DisplaySettings::sendHdmiCecSinkAudioDevicePowerOn fprintf.c crash
Expand Down
35 changes: 18 additions & 17 deletions DisplaySettings/DisplaySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ using namespace std;

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 0
#define API_VERSION_NUMBER_PATCH 5
#define API_VERSION_NUMBER_PATCH 6

static bool isCecArcRoutingThreadEnabled = false;
static bool isCecEnabled = false;
Expand Down Expand Up @@ -271,21 +271,17 @@ 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_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 @@ -489,6 +485,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 @@ -529,7 +529,7 @@ namespace WPEFramework {
{
LOGERR("exception in thread join %s", e.what());
}
stopCecTimeAndUnsubscriveEvent();
stopCecTimeAndUnsubscribeEvent();

DeinitializeIARM();
DisplaySettings::_instance = nullptr;
Expand Down Expand Up @@ -4222,7 +4222,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 @@ -4806,8 +4806,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 @@ -4817,13 +4817,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 @@ -220,7 +220,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 92ae90a

Please sign in to comment.