#define ToString(p) m_processor->ToString(p)
CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) :
- m_type(CEC_DEVICE_TYPE_RESERVED),
- m_iPhysicalAddress(iPhysicalAddress),
- m_iStreamPath(0),
- m_iLogicalAddress(iLogicalAddress),
- m_powerStatus(CEC_POWER_STATUS_UNKNOWN),
- m_processor(processor),
- m_vendor(CEC_VENDOR_UNKNOWN),
- m_bReplaceHandler(false),
- m_menuState(CEC_MENU_STATE_ACTIVATED),
- m_bActiveSource(false),
- m_iLastActive(0),
- m_iLastPowerStateUpdate(0),
- m_cecVersion(CEC_VERSION_UNKNOWN),
- m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN),
- m_iHandlerUseCount(0),
+ m_type (CEC_DEVICE_TYPE_RESERVED),
+ m_iPhysicalAddress (iPhysicalAddress),
+ m_iStreamPath (0),
+ m_iLogicalAddress (iLogicalAddress),
+ m_powerStatus (CEC_POWER_STATUS_UNKNOWN),
+ m_processor (processor),
+ m_vendor (CEC_VENDOR_UNKNOWN),
+ m_bReplaceHandler (false),
+ m_menuState (CEC_MENU_STATE_ACTIVATED),
+ m_bActiveSource (false),
+ m_iLastActive (0),
+ m_iLastPowerStateUpdate (0),
+ m_cecVersion (CEC_VERSION_UNKNOWN),
+ m_deviceStatus (CEC_DEVICE_STATUS_UNKNOWN),
+ m_iHandlerUseCount (0),
m_bAwaitingReceiveFailed(false),
- m_bVendorIdRequested(false)
+ m_bVendorIdRequested (false)
{
m_handler = new CCECCommandHandler(this);
return bReturn;
}
-uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */, bool bSuppressPoll /* = false */)
+uint16_t CCECBusDevice::GetPhysicalAddress(bool bSuppressUpdate /* = true */)
{
- bool bIsPresent(GetStatus(false, bSuppressPoll) == CEC_DEVICE_STATUS_PRESENT);
- bool bRequestUpdate(false);
+ if (!bSuppressUpdate)
{
- CLockObject lock(m_mutex);
- bRequestUpdate = bIsPresent &&
- (m_iPhysicalAddress == 0xFFFF || bUpdate);
- }
+ bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT);
+ bool bRequestUpdate(false);
+ {
+ CLockObject lock(m_mutex);
+ bRequestUpdate = bIsPresent && m_iPhysicalAddress == 0xFFFF;
+ }
- if (bRequestUpdate)
- {
- CheckVendorIdRequested();
- if (!RequestPhysicalAddress())
- CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address");
+ if (bRequestUpdate)
+ {
+ CheckVendorIdRequested();
+ if (!RequestPhysicalAddress())
+ CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address");
+ }
}
CLockObject lock(m_mutex);
SetOSDName (ToString(m_iLogicalAddress));
SetInactiveSource();
m_iLastActive = 0;
+ m_unsupportedFeatures.clear();
}
void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
m_iStreamPath = iNewAddress;
// suppress polls when searching for a device
- CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress, false, true);
+ CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
if (device)
{
// if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive
else
{
// try to find the device with the old address, and mark it as inactive when found
- device = m_processor->GetDeviceByPhysicalAddress(iOldAddress, false, true);
+ device = m_processor->GetDeviceByPhysicalAddress(iOldAddress);
if (device)
device->SetInactiveSource();
}
CLockObject lock(m_mutex);
bool bUnsupported = (m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end());
if (bUnsupported)
- CLibCEC::AddLog(CEC_LOG_NOTICE, "'%s' is marked as unsupported feature for device '%s'", ToString(opcode), GetLogicalAddressName());
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "'%s' is marked as unsupported feature for device '%s'", ToString(opcode), GetLogicalAddressName());
return bUnsupported;
}
void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode)
{
- CLockObject lock(m_mutex);
- CLibCEC::AddLog(CEC_LOG_DEBUG, "marking opcode '%s' as unsupported feature for device '%s'", ToString(opcode), GetLogicalAddressName());
- m_unsupportedFeatures.insert(opcode);
+ // some commands should never be marked as unsupported
+ if (opcode == CEC_OPCODE_VENDOR_COMMAND ||
+ opcode == CEC_OPCODE_VENDOR_COMMAND_WITH_ID ||
+ opcode == CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN ||
+ opcode == CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP ||
+ opcode == CEC_OPCODE_ABORT ||
+ opcode == CEC_OPCODE_FEATURE_ABORT ||
+ opcode == CEC_OPCODE_NONE)
+ return;
+
+ {
+ CLockObject lock(m_mutex);
+ if (m_unsupportedFeatures.find(opcode) == m_unsupportedFeatures.end())
+ {
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "marking opcode '%s' as unsupported feature for device '%s'", ToString(opcode), GetLogicalAddressName());
+ m_unsupportedFeatures.insert(opcode);
+ }
+ }
+
+ // signal threads that are waiting for a reponse
+ MarkBusy();
+ m_handler->SignalOpcode(cec_command::GetResponseOpcode(opcode));
+ MarkReady();
}
bool CCECBusDevice::ActivateSource(void)