/* update "last active" */
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
m_iLastActive = GetTimeMs();
+
+ if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+ m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
}
/* handle the command */
/* change status to present */
if (bHandled)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
{
if (m_deviceStatus != CEC_DEVICE_STATUS_PRESENT)
{
{
CLockObject lock(&m_mutex);
- m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
- }
- cec_power_status status = GetPowerStatus();
- if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
- {
- /* sending the normal power on command appears to have failed */
- CStdString strLog;
- strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
- TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
- return TransmitKeyRelease();
+// m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
+ m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON;
}
+// cec_power_status status = GetPowerStatus();
+// if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
+// {
+// /* sending the normal power on command appears to have failed */
+// CStdString strLog;
+// strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+// AddLog(CEC_LOG_DEBUG, strLog.c_str());
+//
+// TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
+// return TransmitKeyRelease();
+// }
return true;
}
bool CCECBusDevice::RequestMenuLanguage(void)
{
bool bReturn(false);
- if (!MyLogicalAddressContains(m_iLogicalAddress))
+ if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+ !IsUnsupportedFeature(CEC_OPCODE_GET_MENU_LANGUAGE))
{
CStdString strLog;
strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bool CCECBusDevice::RequestOSDName(void)
{
bool bReturn(false);
- if (!MyLogicalAddressContains(m_iLogicalAddress))
+ if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+ !IsUnsupportedFeature(CEC_OPCODE_GIVE_OSD_NAME))
{
CStdString strLog;
strLog.Format("<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bool CCECBusDevice::RequestPowerStatus(void)
{
bool bReturn(false);
- if (!MyLogicalAddressContains(m_iLogicalAddress))
+ if (!MyLogicalAddressContains(m_iLogicalAddress) &&
+ !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
{
CStdString strLog;
strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC &&
(m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll))
{
void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (language.device == m_iLogicalAddress)
{
CStdString strLog;
void CCECBusDevice::SetOSDName(CStdString strName)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_strDeviceName != strName)
{
CStdString strLog;
void CCECBusDevice::SetMenuState(const cec_menu_state state)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_menuState != state)
{
CStdString strLog;
}
}
-void CCECBusDevice::SetInactiveDevice(void)
+void CCECBusDevice::SetInactiveSource(void)
{
- CLockObject lock(&m_writeMutex);
- m_bActiveSource = false;
+ {
+ CLockObject lock(&m_mutex);
+ m_bActiveSource = false;
+ }
+
+ if (MyLogicalAddressContains(m_iLogicalAddress))
+ SetPowerStatus(CEC_POWER_STATUS_STANDBY);
}
-void CCECBusDevice::SetActiveDevice(void)
+void CCECBusDevice::SetActiveSource(void)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
for (int iPtr = 0; iPtr < 16; iPtr++)
if (iPtr != m_iLogicalAddress)
- m_processor->m_busDevices[iPtr]->SetInactiveDevice();
+ m_processor->m_busDevices[iPtr]->SetInactiveSource();
m_bActiveSource = true;
m_powerStatus = CEC_POWER_STATUS_ON;
void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
switch (newStatus)
{
case CEC_DEVICE_STATUS_UNKNOWN:
void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (iNewAddress > 0 && m_iPhysicalAddress != iNewAddress)
{
CStdString strLog;
void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (iNewAddress > 0)
{
CStdString strLog;
void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_powerStatus != powerStatus)
{
CStdString strLog;
bool bVendorChanged(false);
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
bVendorChanged = (m_vendor != (cec_vendor_id)iVendorId);
m_vendor = (cec_vendor_id)iVendorId;
}
}
- if (bVendorChanged && bInitHandler)
+ if (bVendorChanged && bInitHandler && m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN)
m_handler->InitHandler();
CStdString strLog;
bool bSendActiveSource(false);
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_powerStatus != CEC_POWER_STATUS_ON)
{
CStdString strLog;
{
cec_version version;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
CStdString strLog;
strLog.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion));
AddLog(CEC_LOG_NOTICE, strLog);
{
uint16_t iPhysicalAddress;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
CStdString strLog;
strLog.Format("<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress);
AddLog(CEC_LOG_NOTICE, strLog);
{
cec_menu_state menuState;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
CStdString strLog;
strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState));
AddLog(CEC_LOG_NOTICE, strLog);
{
CStdString strDeviceName;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
CStdString strLog;
strLog.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str());
AddLog(CEC_LOG_NOTICE, strLog.c_str());
bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage)
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
- AddLog(CEC_LOG_NOTICE, strLog.c_str());
+ if (!IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING))
+ {
+ CStdString strLog;
+ strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
- return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage);
+ return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage);
+ }
+ return false;
}
bool CCECBusDevice::TransmitPhysicalAddress(void)
uint16_t iPhysicalAddress;
cec_device_type type;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (m_iPhysicalAddress == 0xffff)
return false;
bReturn = m_handler->TransmitPoll(m_iLogicalAddress, dest);
AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
if (bReturn)
{
m_iLastActive = GetTimeMs();
{
cec_power_status state;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
CStdString strLog;
strLog.Format("<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus));
AddLog(CEC_LOG_NOTICE, strLog.c_str());
return m_handler->TransmitPowerState(m_iLogicalAddress, dest, state);
}
-bool CCECBusDevice::TransmitVendorID(cec_logical_address dest)
+bool CCECBusDevice::TransmitVendorID(cec_logical_address dest, bool bSendAbort /* = true */)
{
uint64_t iVendorId;
{
- CLockObject lock(&m_writeMutex);
+ CLockObject lock(&m_mutex);
iVendorId = (uint64_t)m_vendor;
}
if (iVendorId == CEC_VENDOR_UNKNOWN)
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
- AddLog(CEC_LOG_NOTICE, strLog);
+ if (bSendAbort)
+ {
+ CStdString strLog;
+ strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
+ AddLog(CEC_LOG_NOTICE, strLog);
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ }
return false;
}
else
}
}
-bool CCECBusDevice::TransmitKeypress(cec_user_control_code key)
+bool CCECBusDevice::TransmitKeypress(cec_user_control_code key, bool bWait /* = true */)
+{
+ return m_handler->TransmitKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key, bWait);
+}
+
+bool CCECBusDevice::TransmitKeyRelease(bool bWait /* = true */)
+{
+ return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress, bWait);
+}
+
+bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode) const
{
- return m_handler->TransmitKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key);
+ return m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end();
}
-bool CCECBusDevice::TransmitKeyRelease(void)
+void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode)
{
- return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress);
+ m_unsupportedFeatures.insert(opcode);
}
//@}