return m_cecVersion;
}
-bool CCECBusDevice::RequestCecVersion(void)
+bool CCECBusDevice::RequestCecVersion(bool bWaitForResponse /* = true */)
{
bool bReturn(false);
MarkBusy();
CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- bReturn = m_handler->TransmitRequestCecVersion(GetMyLogicalAddress(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestCecVersion(GetMyLogicalAddress(), m_iLogicalAddress, bWaitForResponse);
MarkReady();
}
return bReturn;
return m_menuLanguage;
}
-bool CCECBusDevice::RequestMenuLanguage(void)
+bool CCECBusDevice::RequestMenuLanguage(bool bWaitForResponse /* = true */)
{
bool bReturn(false);
{
MarkBusy();
CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- bReturn = m_handler->TransmitRequestMenuLanguage(GetMyLogicalAddress(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestMenuLanguage(GetMyLogicalAddress(), m_iLogicalAddress, bWaitForResponse);
MarkReady();
}
return bReturn;
return m_strDeviceName;
}
-bool CCECBusDevice::RequestOSDName(void)
+bool CCECBusDevice::RequestOSDName(bool bWaitForResponse /* = true */)
{
bool bReturn(false);
{
MarkBusy();
CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- bReturn = m_handler->TransmitRequestOSDName(GetMyLogicalAddress(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestOSDName(GetMyLogicalAddress(), m_iLogicalAddress, bWaitForResponse);
MarkReady();
}
return bReturn;
}
-uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */)
+uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */, bool bSuppressPoll /* = false */)
{
- bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT);
+ bool bIsPresent(GetStatus(false, bSuppressPoll) == CEC_DEVICE_STATUS_PRESENT);
bool bRequestUpdate(false);
{
CLockObject lock(m_mutex);
return m_iPhysicalAddress;
}
-bool CCECBusDevice::RequestPhysicalAddress(void)
+bool CCECBusDevice::RequestPhysicalAddress(bool bWaitForResponse /* = true */)
{
bool bReturn(false);
{
MarkBusy();
CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting physical address of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- bReturn = m_handler->TransmitRequestPhysicalAddress(GetMyLogicalAddress(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestPhysicalAddress(GetMyLogicalAddress(), m_iLogicalAddress, bWaitForResponse);
MarkReady();
}
return bReturn;
return m_powerStatus;
}
-bool CCECBusDevice::RequestPowerStatus(void)
+bool CCECBusDevice::RequestPowerStatus(bool bWaitForResponse /* = true */)
{
bool bReturn(false);
{
MarkBusy();
CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- bReturn = m_handler->TransmitRequestPowerStatus(GetMyLogicalAddress(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestPowerStatus(GetMyLogicalAddress(), m_iLogicalAddress, bWaitForResponse);
MarkReady();
}
return bReturn;
return m_vendor;
}
-bool CCECBusDevice::RequestVendorId(void)
+bool CCECBusDevice::RequestVendorId(bool bWaitForResponse /* = true */)
{
bool bReturn(false);
- if (!MyLogicalAddressContains(m_iLogicalAddress))
+ if (!MyLogicalAddressContains(m_iLogicalAddress) && GetMyLogicalAddress() != CECDEVICE_UNKNOWN)
{
MarkBusy();
CLibCEC::AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- bReturn = m_handler->TransmitRequestVendorId(GetMyLogicalAddress(), m_iLogicalAddress);
+ bReturn = m_handler->TransmitRequestVendorId(GetMyLogicalAddress(), m_iLogicalAddress, bWaitForResponse);
MarkReady();
- ReplaceHandler(true);
+ if (bWaitForResponse)
+ ReplaceHandler(true);
}
return bReturn;
}
return bSendPoll;
}
-cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */)
+cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */, bool bSuppressPoll /* = false */)
{
cec_bus_device_status status(CEC_DEVICE_STATUS_UNKNOWN);
bool bNeedsPoll(false);
{
CLockObject lock(m_mutex);
status = m_deviceStatus;
- bNeedsPoll = (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC &&
- (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll));
+ bNeedsPoll = !bSuppressPoll &&
+ (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN);
}
if (bNeedsPoll)
//@{
void CCECBusDevice::SetCecVersion(const cec_version newVersion)
{
+ if (m_cecVersion != newVersion)
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion));
m_cecVersion = newVersion;
- CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion));
}
void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
{
CLockObject lock(m_mutex);
- if (language.device == m_iLogicalAddress)
+ if (language.device == m_iLogicalAddress &&
+ strcmp(language.language, m_menuLanguage.language))
{
CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language);
m_menuLanguage = language;
return false;
}
+void CCECBusDevice::ResetDeviceStatus(void)
+{
+ CLockObject lock(m_mutex);
+ SetPowerStatus (CEC_POWER_STATUS_UNKNOWN);
+ SetVendorId (CEC_VENDOR_UNKNOWN);
+ SetMenuState (CEC_MENU_STATE_ACTIVATED);
+ SetCecVersion (CEC_VERSION_UNKNOWN);
+ SetStreamPath (0);
+ SetOSDName (ToString(m_iLogicalAddress));
+ SetInactiveSource();
+ m_iLastActive = 0;
+}
+
void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
{
{
case CEC_DEVICE_STATUS_UNKNOWN:
if (m_deviceStatus != newStatus)
CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'unknown'", ToString(m_iLogicalAddress));
- m_iStreamPath = 0;
- m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
- m_vendor = CEC_VENDOR_UNKNOWN;
- m_menuState = CEC_MENU_STATE_ACTIVATED;
- m_bActiveSource = false;
- m_iLastActive = 0;
- m_cecVersion = CEC_VERSION_UNKNOWN;
- m_deviceStatus = newStatus;
+ ResetDeviceStatus();
+ m_deviceStatus = newStatus;
break;
case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC:
if (m_deviceStatus != newStatus)
CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'handled by libCEC'", ToString(m_iLogicalAddress));
- m_iStreamPath = 0;
- m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON;
- m_vendor = CEC_VENDOR_UNKNOWN;
- m_menuState = CEC_MENU_STATE_ACTIVATED;
- m_bActiveSource = false;
- m_iLastActive = 0;
- m_cecVersion = CEC_VERSION_1_3A;
- m_deviceStatus = newStatus;
+ SetPowerStatus (CEC_POWER_STATUS_ON);
+ SetVendorId (CEC_VENDOR_UNKNOWN);
+ SetMenuState (CEC_MENU_STATE_ACTIVATED);
+ SetCecVersion (CEC_VERSION_1_3A);
+ SetStreamPath (0);
+ SetInactiveSource();
+ m_iLastActive = 0;
+ m_deviceStatus = newStatus;
break;
case CEC_DEVICE_STATUS_PRESENT:
if (m_deviceStatus != newStatus)
break;
case CEC_DEVICE_STATUS_NOT_PRESENT:
if (m_deviceStatus != newStatus)
+ {
CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'not present'", ToString(m_iLogicalAddress));
- m_deviceStatus = newStatus;
+ ResetDeviceStatus();
+ m_deviceStatus = newStatus;
+ }
break;
}
}
if (newStatus == CEC_DEVICE_STATUS_PRESENT)
- RequestVendorId();
+ RequestVendorId(false);
}
void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress);
m_iStreamPath = iNewAddress;
- CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress, false);
+ // suppress polls when searching for a device
+ CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress, false, true);
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);
+ device = m_processor->GetDeviceByPhysicalAddress(iOldAddress, false, true);
if (device)
device->SetInactiveSource();
}
m_vendor = (cec_vendor_id)iVendorId;
}
- CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor);
+ if (bVendorChanged)
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor);
return bVendorChanged;
}
return bReturn;
}
-bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode) const
+bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode)
{
+ 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());
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);
}
bool CCECBusDevice::ActivateSource(void)
{
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "activating source '%s'", ToString(m_iLogicalAddress));
MarkBusy();
bool bReturn = m_handler->ActivateSource();
MarkReady();
return bReturn;
}
-void CCECBusDevice::HandlePoll(cec_logical_address iDestination)
+void CCECBusDevice::HandlePoll(cec_logical_address destination)
{
- CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", ToString(m_iLogicalAddress), m_iLogicalAddress, ToString(iDestination), iDestination);
+ if (destination >= 0 && destination < CECDEVICE_BROADCAST)
+ {
+ CCECBusDevice *device = m_processor->m_busDevices[destination];
+ if (device)
+ device->HandlePollFrom(m_iLogicalAddress);
+ }
+}
+
+void CCECBusDevice::HandlePollFrom(cec_logical_address initiator)
+{
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", ToString(initiator), initiator, ToString(m_iLogicalAddress), m_iLogicalAddress);
m_bAwaitingReceiveFailed = true;
}
}
}
+bool CCECBusDevice::TransmitPendingActiveSourceCommands(void)
+{
+ MarkBusy();
+ bool bReturn = m_handler->TransmitPendingActiveSourceCommands();
+ MarkReady();
+ return bReturn;
+}
+
//@}