-
Notifications
You must be signed in to change notification settings - Fork 3
[RDKEMW-6163] [RDKEMW-6164] CEC source and sink changes #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/RDKEMW-6163-k1
Are you sure you want to change the base?
Changes from 5 commits
5b1743f
55ceafa
f8c01b3
7a0d569
bef0aa3
7c031cf
a0fa4dc
eac3ee0
08b3562
e7f3075
b334b82
81cc8f5
5979423
2bf6395
1ea0522
ff6eeee
922fb7f
3501b16
f2c5780
bc803aa
0623a75
e9cd34f
f8ea54c
76a6dd1
6ae6bd0
73a1113
0c48f19
97af88f
8f16519
27b02c7
2e3aada
8b5c432
8b0cc04
60c25bd
ff83a02
da3518c
24d314b
14f2003
ebd3200
6993a8d
a22b587
51b2c7f
a0ccdbb
6eacd50
96b094d
cc42754
a3c694f
abc1156
7415208
72bfc2a
f73190e
2515fdd
91b669a
6e18267
11c0a7d
408cdc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||
Check failure on line 1 in HdmiCecSink/HdmiCecSink.cpp
|
||||||||||||||||||||||||||||||||||
* If not stated otherwise in this file or this component's LICENSE | ||||||||||||||||||||||||||||||||||
* file the following copyright and licenses apply: | ||||||||||||||||||||||||||||||||||
* | ||||||||||||||||||||||||||||||||||
|
@@ -692,132 +692,159 @@ | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
const std::string HdmiCecSink::Initialize(PluginHost::IShell *service) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
InitializePowerManager(service); | ||||||||||||||||||||||||||||||||||
profileType = searchRdkProfile(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
if (profileType == STB || profileType == NOT_FOUND) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGINFO("Invalid profile type for TV \n"); | ||||||||||||||||||||||||||||||||||
return (std::string("Not supported")); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
HdmiCecSink::_instance = this; | ||||||||||||||||||||||||||||||||||
smConnection=NULL; | ||||||||||||||||||||||||||||||||||
cecEnableStatus = false; | ||||||||||||||||||||||||||||||||||
HdmiCecSink::_instance->m_numberOfDevices = 0; | ||||||||||||||||||||||||||||||||||
m_logicalAddressAllocated = LogicalAddress::UNREGISTERED; | ||||||||||||||||||||||||||||||||||
m_currentActiveSource = -1; | ||||||||||||||||||||||||||||||||||
m_isHdmiInConnected = false; | ||||||||||||||||||||||||||||||||||
hdmiCecAudioDeviceConnected = false; | ||||||||||||||||||||||||||||||||||
m_isAudioStatusInfoUpdated = false; | ||||||||||||||||||||||||||||||||||
m_audioStatusRequestedCount = 0; | ||||||||||||||||||||||||||||||||||
m_audioStatusReceived = false; | ||||||||||||||||||||||||||||||||||
m_audioStatusTimerStarted = false; | ||||||||||||||||||||||||||||||||||
m_audioDevicePowerStatusRequested = false; | ||||||||||||||||||||||||||||||||||
m_pollNextState = POLL_THREAD_STATE_NONE; | ||||||||||||||||||||||||||||||||||
m_pollThreadState = POLL_THREAD_STATE_NONE; | ||||||||||||||||||||||||||||||||||
m_video_latency = DEFAULT_VIDEO_LATENCY; | ||||||||||||||||||||||||||||||||||
m_latency_flags = DEFAULT_LATENCY_FLAGS ; | ||||||||||||||||||||||||||||||||||
m_audio_output_delay = DEFAULT_AUDIO_OUTPUT_DELAY; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ENABLED, &HdmiCecSink::setEnabledWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_ENABLED, &HdmiCecSink::getEnabledWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_OSD_NAME, &HdmiCecSink::setOSDNameWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_OSD_NAME, &HdmiCecSink::getOSDNameWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_VENDOR_ID, &HdmiCecSink::setVendorIdWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_VENDOR_ID, &HdmiCecSink::getVendorIdWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_PRINT_DEVICE_LIST, &HdmiCecSink::printDeviceListWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ACTIVE_PATH, &HdmiCecSink::setActivePathWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ROUTING_CHANGE, &HdmiCecSink::setRoutingChangeWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_DEVICE_LIST, &HdmiCecSink::getDeviceListWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_ACTIVE_SOURCE, &HdmiCecSink::getActiveSourceWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ACTIVE_SOURCE, &HdmiCecSink::setActiveSourceWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_ACTIVE_ROUTE, &HdmiCecSink::getActiveRouteWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_REQUEST_ACTIVE_SOURCE, &HdmiCecSink::requestActiveSourceWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SETUP_ARC, &HdmiCecSink::setArcEnableDisableWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_MENU_LANGUAGE, &HdmiCecSink::setMenuLanguageWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_REQUEST_SHORT_AUDIO_DESCRIPTOR, &HdmiCecSink::requestShortAudioDescriptorWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_STANDBY_MESSAGE, &HdmiCecSink::sendStandbyMessageWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_AUDIO_DEVICE_POWER_ON, &HdmiCecSink::sendAudioDevicePowerOnMsgWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_KEY_PRESS,&HdmiCecSink::sendRemoteKeyPressWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_USER_CONTROL_PRESSED,&HdmiCecSink::sendUserControlPressedWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_USER_CONTROL_RELEASED,&HdmiCecSink::sendUserControlReleasedWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_GIVE_AUDIO_STATUS,&HdmiCecSink::sendGiveAudioStatusWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_AUDIO_DEVICE_CONNECTED_STATUS,&HdmiCecSink::getAudioDeviceConnectedStatusWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_REQUEST_AUDIO_DEVICE_POWER_STATUS,&HdmiCecSink::requestAudioDevicePowerStatusWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_LATENCY_INFO, &HdmiCecSink::setLatencyInfoWrapper, this); | ||||||||||||||||||||||||||||||||||
logicalAddressDeviceType = "None"; | ||||||||||||||||||||||||||||||||||
logicalAddress = 0xFF; | ||||||||||||||||||||||||||||||||||
// load persistence setting | ||||||||||||||||||||||||||||||||||
loadSettings(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
int err; | ||||||||||||||||||||||||||||||||||
dsHdmiInGetNumberOfInputsParam_t hdmiInput; | ||||||||||||||||||||||||||||||||||
InitializeIARM(); | ||||||||||||||||||||||||||||||||||
m_sendKeyEventThreadExit = false; | ||||||||||||||||||||||||||||||||||
m_sendKeyEventThread = std::thread(threadSendKeyEvent); | ||||||||||||||||||||||||||||||||||
string msg = ""; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; | ||||||||||||||||||||||||||||||||||
m_semSignaltoArcRoutingThread.acquire(); | ||||||||||||||||||||||||||||||||||
m_arcRoutingThread = std::thread(threadArcRouting); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
m_audioStatusDetectionTimer.connect( std::bind( &HdmiCecSink::audioStatusTimerFunction, this ) ); | ||||||||||||||||||||||||||||||||||
m_audioStatusDetectionTimer.setSingleShot(true); | ||||||||||||||||||||||||||||||||||
m_arcStartStopTimer.connect( std::bind( &HdmiCecSink::arcStartStopTimerFunction, this ) ); | ||||||||||||||||||||||||||||||||||
m_arcStartStopTimer.setSingleShot(true); | ||||||||||||||||||||||||||||||||||
// get power state: | ||||||||||||||||||||||||||||||||||
Core::hresult res = Core::ERROR_GENERAL; | ||||||||||||||||||||||||||||||||||
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; | ||||||||||||||||||||||||||||||||||
PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
ASSERT (_powerManagerPlugin); | ||||||||||||||||||||||||||||||||||
if (_powerManagerPlugin) { | ||||||||||||||||||||||||||||||||||
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); | ||||||||||||||||||||||||||||||||||
if (Core::ERROR_NONE == res) { | ||||||||||||||||||||||||||||||||||
powerState = (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) ? DEVICE_POWER_STATE_ON : DEVICE_POWER_STATE_OFF; | ||||||||||||||||||||||||||||||||||
LOGINFO("Current state is PowerManagerPlugin: (%d) powerState :%d \n", pwrStateCur, powerState); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
err = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, | ||||||||||||||||||||||||||||||||||
IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs, | ||||||||||||||||||||||||||||||||||
(void *)&hdmiInput, | ||||||||||||||||||||||||||||||||||
sizeof(hdmiInput)); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
if (err == IARM_RESULT_SUCCESS && hdmiInput.result == dsERR_NONE) | ||||||||||||||||||||||||||||||||||
try | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGINFO("Number of Inputs [%d] \n", hdmiInput.numHdmiInputs ); | ||||||||||||||||||||||||||||||||||
m_numofHdmiInput = hdmiInput.numHdmiInputs; | ||||||||||||||||||||||||||||||||||
}else{ | ||||||||||||||||||||||||||||||||||
LOGINFO("Not able to get Numebr of inputs so defaulting to 3 \n"); | ||||||||||||||||||||||||||||||||||
m_numofHdmiInput = 3; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
device::Manager::Initialize(); | ||||||||||||||||||||||||||||||||||
LOGINFO("device::Manager::Initialize success"); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
catch(const device::Exception& err) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGINFO("device::Manager::Initialize failed"); | ||||||||||||||||||||||||||||||||||
msg = "HdmiCecSink plugin Initialize failed"; | ||||||||||||||||||||||||||||||||||
LOG_DEVICE_EXCEPTION0(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
LOGINFO("initalize inputs \n"); | ||||||||||||||||||||||||||||||||||
if (0 == msg.length()) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
InitializePowerManager(service); | ||||||||||||||||||||||||||||||||||
profileType = searchRdkProfile(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
for (int i = 0; i < m_numofHdmiInput; i++){ | ||||||||||||||||||||||||||||||||||
HdmiPortMap hdmiPort((uint8_t)i); | ||||||||||||||||||||||||||||||||||
LOGINFO(" Add to vector [%d] \n", i); | ||||||||||||||||||||||||||||||||||
hdmiInputs.push_back(hdmiPort); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
if (profileType == STB || profileType == NOT_FOUND) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGINFO("Invalid profile type for TV \n"); | ||||||||||||||||||||||||||||||||||
msg = "Not supported"; | ||||||||||||||||||||||||||||||||||
return msg; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
HdmiCecSink::_instance = this; | ||||||||||||||||||||||||||||||||||
smConnection=NULL; | ||||||||||||||||||||||||||||||||||
cecEnableStatus = false; | ||||||||||||||||||||||||||||||||||
HdmiCecSink::_instance->m_numberOfDevices = 0; | ||||||||||||||||||||||||||||||||||
m_logicalAddressAllocated = LogicalAddress::UNREGISTERED; | ||||||||||||||||||||||||||||||||||
m_currentActiveSource = -1; | ||||||||||||||||||||||||||||||||||
m_isHdmiInConnected = false; | ||||||||||||||||||||||||||||||||||
hdmiCecAudioDeviceConnected = false; | ||||||||||||||||||||||||||||||||||
m_isAudioStatusInfoUpdated = false; | ||||||||||||||||||||||||||||||||||
m_audioStatusRequestedCount = 0; | ||||||||||||||||||||||||||||||||||
m_audioStatusReceived = false; | ||||||||||||||||||||||||||||||||||
m_audioStatusTimerStarted = false; | ||||||||||||||||||||||||||||||||||
m_audioDevicePowerStatusRequested = false; | ||||||||||||||||||||||||||||||||||
m_pollNextState = POLL_THREAD_STATE_NONE; | ||||||||||||||||||||||||||||||||||
m_pollThreadState = POLL_THREAD_STATE_NONE; | ||||||||||||||||||||||||||||||||||
m_video_latency = DEFAULT_VIDEO_LATENCY; | ||||||||||||||||||||||||||||||||||
m_latency_flags = DEFAULT_LATENCY_FLAGS ; | ||||||||||||||||||||||||||||||||||
m_audio_output_delay = DEFAULT_AUDIO_OUTPUT_DELAY; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ENABLED, &HdmiCecSink::setEnabledWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_ENABLED, &HdmiCecSink::getEnabledWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_OSD_NAME, &HdmiCecSink::setOSDNameWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_OSD_NAME, &HdmiCecSink::getOSDNameWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_VENDOR_ID, &HdmiCecSink::setVendorIdWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_VENDOR_ID, &HdmiCecSink::getVendorIdWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_PRINT_DEVICE_LIST, &HdmiCecSink::printDeviceListWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ACTIVE_PATH, &HdmiCecSink::setActivePathWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ROUTING_CHANGE, &HdmiCecSink::setRoutingChangeWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_DEVICE_LIST, &HdmiCecSink::getDeviceListWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_ACTIVE_SOURCE, &HdmiCecSink::getActiveSourceWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_ACTIVE_SOURCE, &HdmiCecSink::setActiveSourceWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_ACTIVE_ROUTE, &HdmiCecSink::getActiveRouteWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_REQUEST_ACTIVE_SOURCE, &HdmiCecSink::requestActiveSourceWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SETUP_ARC, &HdmiCecSink::setArcEnableDisableWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_MENU_LANGUAGE, &HdmiCecSink::setMenuLanguageWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_REQUEST_SHORT_AUDIO_DESCRIPTOR, &HdmiCecSink::requestShortAudioDescriptorWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_STANDBY_MESSAGE, &HdmiCecSink::sendStandbyMessageWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_AUDIO_DEVICE_POWER_ON, &HdmiCecSink::sendAudioDevicePowerOnMsgWrapper, this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_KEY_PRESS,&HdmiCecSink::sendRemoteKeyPressWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_USER_CONTROL_PRESSED,&HdmiCecSink::sendUserControlPressedWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_USER_CONTROL_RELEASED,&HdmiCecSink::sendUserControlReleasedWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SEND_GIVE_AUDIO_STATUS,&HdmiCecSink::sendGiveAudioStatusWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_GET_AUDIO_DEVICE_CONNECTED_STATUS,&HdmiCecSink::getAudioDeviceConnectedStatusWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_REQUEST_AUDIO_DEVICE_POWER_STATUS,&HdmiCecSink::requestAudioDevicePowerStatusWrapper,this); | ||||||||||||||||||||||||||||||||||
Register(HDMICECSINK_METHOD_SET_LATENCY_INFO, &HdmiCecSink::setLatencyInfoWrapper, this); | ||||||||||||||||||||||||||||||||||
logicalAddressDeviceType = "None"; | ||||||||||||||||||||||||||||||||||
logicalAddress = 0xFF; | ||||||||||||||||||||||||||||||||||
// load persistence setting | ||||||||||||||||||||||||||||||||||
loadSettings(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
int err; | ||||||||||||||||||||||||||||||||||
dsHdmiInGetNumberOfInputsParam_t hdmiInput; | ||||||||||||||||||||||||||||||||||
#ifdef IO_HCEC_ENABLE_IARM | ||||||||||||||||||||||||||||||||||
InitializeIARM(); | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
device::Host::getInstance().Register(baseInterface<device::Host::IHdmiInEvents>(), "WPE[HdmiCecSink]"); | ||||||||||||||||||||||||||||||||||
#endif /* IO_HCEC_ENABLE_IARM */ | ||||||||||||||||||||||||||||||||||
m_sendKeyEventThreadExit = false; | ||||||||||||||||||||||||||||||||||
m_sendKeyEventThread = std::thread(threadSendKeyEvent); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
m_currentArcRoutingState = ARC_STATE_ARC_TERMINATED; | ||||||||||||||||||||||||||||||||||
m_semSignaltoArcRoutingThread.acquire(); | ||||||||||||||||||||||||||||||||||
m_arcRoutingThread = std::thread(threadArcRouting); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
m_audioStatusDetectionTimer.connect( std::bind( &HdmiCecSink::audioStatusTimerFunction, this ) ); | ||||||||||||||||||||||||||||||||||
m_audioStatusDetectionTimer.setSingleShot(true); | ||||||||||||||||||||||||||||||||||
m_arcStartStopTimer.connect( std::bind( &HdmiCecSink::arcStartStopTimerFunction, this ) ); | ||||||||||||||||||||||||||||||||||
m_arcStartStopTimer.setSingleShot(true); | ||||||||||||||||||||||||||||||||||
// get power state: | ||||||||||||||||||||||||||||||||||
Core::hresult res = Core::ERROR_GENERAL; | ||||||||||||||||||||||||||||||||||
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; | ||||||||||||||||||||||||||||||||||
PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
ASSERT (_powerManagerPlugin); | ||||||||||||||||||||||||||||||||||
if (_powerManagerPlugin) { | ||||||||||||||||||||||||||||||||||
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev); | ||||||||||||||||||||||||||||||||||
if (Core::ERROR_NONE == res) { | ||||||||||||||||||||||||||||||||||
powerState = (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) ? DEVICE_POWER_STATE_ON : DEVICE_POWER_STATE_OFF; | ||||||||||||||||||||||||||||||||||
LOGINFO("Current state is PowerManagerPlugin: (%d) powerState :%d \n", pwrStateCur, powerState); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
LOGINFO("Check the HDMI State \n"); | ||||||||||||||||||||||||||||||||||
#ifdef IO_HCEC_ENABLE_IARM | ||||||||||||||||||||||||||||||||||
err = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, | ||||||||||||||||||||||||||||||||||
IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs, | ||||||||||||||||||||||||||||||||||
(void *)&hdmiInput, | ||||||||||||||||||||||||||||||||||
sizeof(hdmiInput)); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
CheckHdmiInState(); | ||||||||||||||||||||||||||||||||||
if (cecSettingEnabled) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
try | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
CECEnable(); | ||||||||||||||||||||||||||||||||||
if (err == IARM_RESULT_SUCCESS && hdmiInput.result == dsERR_NONE) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGINFO("Number of Inputs [%d] \n", hdmiInput.numHdmiInputs ); | ||||||||||||||||||||||||||||||||||
m_numofHdmiInput = hdmiInput.numHdmiInputs; | ||||||||||||||||||||||||||||||||||
}else{ | ||||||||||||||||||||||||||||||||||
LOGINFO("Not able to get Numebr of inputs so defaulting to 3 \n"); | ||||||||||||||||||||||||||||||||||
m_numofHdmiInput = 3; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
catch(...) | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
m_numofHdmiInput = device::HdmiInput::getInstance().getNumberOfInputs(); | ||||||||||||||||||||||||||||||||||
#endif /* IO_HCEC_ENABLE_IARM */ | ||||||||||||||||||||||||||||||||||
LOGINFO("initalize inputs \n"); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
for (int i = 0; i < m_numofHdmiInput; i++){ | ||||||||||||||||||||||||||||||||||
HdmiPortMap hdmiPort((uint8_t)i); | ||||||||||||||||||||||||||||||||||
LOGINFO(" Add to vector [%d] \n", i); | ||||||||||||||||||||||||||||||||||
hdmiInputs.push_back(hdmiPort); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
LOGINFO("Check the HDMI State \n"); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
CheckHdmiInState(); | ||||||||||||||||||||||||||||||||||
if (cecSettingEnabled) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGWARN("Exception while enabling CEC settings .\r\n"); | ||||||||||||||||||||||||||||||||||
try | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
CECEnable(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
catch(...) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGWARN("Exception while enabling CEC settings .\r\n"); | ||||||||||||||||||||||||||||||||||
msg = "Exception while enabling CEC settings"; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
getCecVersion(); | ||||||||||||||||||||||||||||||||||
LOGINFO(" HdmiCecSink plugin Initialize completed \n"); | ||||||||||||||||||||||||||||||||||
return (std::string()); | ||||||||||||||||||||||||||||||||||
getCecVersion(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
LOGINFO(" HdmiCecSink plugin Initialize completed \n"); | ||||||||||||||||||||||||||||||||||
return msg; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
@@ -879,7 +906,23 @@ | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
HdmiCecSink::_instance = nullptr; | ||||||||||||||||||||||||||||||||||
DeinitializeIARM(); | ||||||||||||||||||||||||||||||||||
#ifdef IO_HCEC_ENABLE_IARM | ||||||||||||||||||||||||||||||||||
DeinitializeIARM(); | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
device::Host::getInstance().UnRegister(baseInterface<device::Host::IHdmiInEvents>()); | ||||||||||||||||||||||||||||||||||
#endif /* IO_HCEC_ENABLE_IARM */ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
try | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
device::Manager::DeInitialize(); | ||||||||||||||||||||||||||||||||||
LOGINFO("device::Manager::DeInitialize success"); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
catch(const device::Exception& err) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
LOGINFO("device::Manager::DeInitialize failed"); | ||||||||||||||||||||||||||||||||||
LOG_DEVICE_EXCEPTION0(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
LOGWARN(" HdmiCecSink Deinitialize() Done"); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
@@ -920,6 +963,7 @@ | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#ifdef IO_HCEC_ENABLE_IARM | ||||||||||||||||||||||||||||||||||
void HdmiCecSink::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
if(!HdmiCecSink::_instance) | ||||||||||||||||||||||||||||||||||
|
@@ -934,6 +978,16 @@ | |||||||||||||||||||||||||||||||||
HdmiCecSink::_instance->onHdmiHotPlug(portId,isHdmiConnected); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
void HdmiCecSink::OnHdmiInEventHotPlug(dsHdmiInPort_t port, bool isConnected) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
if(!HdmiCecSink::_instance) | ||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event port: %d isConnected: %d \r\n", port, isConnected); | ||||||||||||||||||||||||||||||||||
HdmiCecSink::_instance->onHdmiHotPlug((int) port, isConnected); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
#endif /* IO_HCEC_ENABLE_IARM */ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
void HdmiCecSink::onPowerModeChanged(const PowerState currentState, const PowerState newState) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
|
@@ -2061,6 +2115,8 @@ | |||||||||||||||||||||||||||||||||
int err; | ||||||||||||||||||||||||||||||||||
bool isAnyPortConnected = false; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#ifdef IO_HCEC_ENABLE_IARM | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
dsHdmiInGetStatusParam_t params; | ||||||||||||||||||||||||||||||||||
err = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, | ||||||||||||||||||||||||||||||||||
IARM_BUS_DSMGR_API_dsHdmiInGetStatus, | ||||||||||||||||||||||||||||||||||
|
@@ -2081,7 +2137,21 @@ | |||||||||||||||||||||||||||||||||
hdmiInputs[i].update(params.status.isPortConnected[i]); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
for( int i = 0; i < m_numofHdmiInput; i++ ) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
//LOGINFO("update Port Status [%d] \n", i); | ||||||||||||||||||||||||||||||||||
hdmiInputs[i].update(device::HdmiInput::getInstance().isPortConnected(i)); | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The isPortConnected call could throw an exception if the port index is invalid or the HdmiInput instance is not properly initialized. Consider adding bounds checking and exception handling around this call.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
//LOGINFO("Is HDMI In Port [%d] connected [%d] \n",i, params.status.isPortConnected[i]); | ||||||||||||||||||||||||||||||||||
if ( hdmiInputs[i].m_isConnected ) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
isAnyPortConnected = true; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#endif /* IO_HCEC_ENABLE_IARM */ | ||||||||||||||||||||||||||||||||||
if ( isAnyPortConnected ) { | ||||||||||||||||||||||||||||||||||
m_isHdmiInConnected = true; | ||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||
|
@@ -3542,6 +3612,7 @@ | |||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#ifdef IO_HCEC_ENABLE_IARM | ||||||||||||||||||||||||||||||||||
void HdmiCecSink::getHdmiArcPortID() | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
int err; | ||||||||||||||||||||||||||||||||||
|
@@ -3566,6 +3637,33 @@ | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} while(retryCount++ <= 6); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
void HdmiCecSink::getHdmiArcPortID() | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
int portId; | ||||||||||||||||||||||||||||||||||
unsigned int retryCount = 1; | ||||||||||||||||||||||||||||||||||
do { | ||||||||||||||||||||||||||||||||||
usleep(50000); // Sleep for 50ms before retrying | ||||||||||||||||||||||||||||||||||
portId = -1; | ||||||||||||||||||||||||||||||||||
#if 0 //just to verify compilation | ||||||||||||||||||||||||||||||||||
device::HdmiInput::getInstance().getHDMIARCPortId(&portId); | ||||||||||||||||||||||||||||||||||
#else | ||||||||||||||||||||||||||||||||||
portId = 0; | ||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||
|
#if 0 //just to verify compilation | |
device::HdmiInput::getInstance().getHDMIARCPortId(&portId); | |
#else | |
portId = 0; | |
#endif | |
// TODO: Replace hardcoded portId assignment with actual device API call when available. | |
// device::HdmiInput::getInstance().getHDMIARCPortId(&portId); | |
portId = 0; |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Numebr" is misspelled and should be "Number".
Copilot uses AI. Check for mistakes.