{
CLockObject lock(m_mutex);
m_iLastActive = GetTimeMs();
-
- /* don't call GetStatus() here, just read the value with the mutex locked */
- if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC && command.opcode_set == 1)
- m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
-
MarkBusy();
}
!IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
{
MarkBusy();
- LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse);
MarkReady();
}
CLockObject lock(m_mutex);
status = m_deviceStatus;
bNeedsPoll = !bSuppressPoll &&
- (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN);
+ m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC &&
+ // poll forced
+ (bForcePoll ||
+ // don't know the status
+ m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN ||
+ // always poll the TV if it's marked as not present
+ (m_deviceStatus == CEC_DEVICE_STATUS_NOT_PRESENT && m_iLogicalAddress == CECDEVICE_TV));
}
if (bNeedsPoll)
void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus, cec_version libCECSpecVersion /* = CEC_VERSION_1_4 */)
{
+ if (m_iLogicalAddress == CECDEVICE_UNREGISTERED)
+ return;
+
{
CLockObject lock(m_mutex);
switch (newStatus)
if (m_deviceStatus != newStatus)
LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'present'", GetLogicalAddressName(), m_iLogicalAddress);
m_deviceStatus = newStatus;
+ m_iLastActive = GetTimeMs();
break;
case CEC_DEVICE_STATUS_NOT_PRESENT:
if (m_deviceStatus != newStatus)
m_deviceStatus = CEC_DEVICE_STATUS_UNKNOWN;
}
-bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply)
+bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bUpdateDeviceStatus)
{
bool bReturn(false);
cec_logical_address destination(dest);
MarkBusy();
LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
- bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, bIsReply);
+ bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, false);
LIB_CEC->AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
- CLockObject lock(m_mutex);
- if (bReturn)
- {
- m_iLastActive = GetTimeMs();
- destDevice->m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
- }
- else
- destDevice->m_deviceStatus = CEC_DEVICE_STATUS_NOT_PRESENT;
+ if (bUpdateDeviceStatus)
+ destDevice->SetDeviceStatus(bReturn ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT);
MarkReady();
return bReturn;
return bReturn;
}
+void CCECBusDevice::SetActiveRoute(uint16_t iRoute)
+{
+ CCECDeviceMap* map = m_processor->GetDevices();
+ if (!map)
+ return;
+
+ CCECBusDevice* previouslyActive = map->GetActiveSource();
+ if (!previouslyActive)
+ return;
+
+ CECDEVICEVEC devices;
+ m_processor->GetDevices()->GetChildrenOf(devices, this);
+
+ for (CECDEVICEVEC::iterator it = devices.begin(); it != devices.end(); it++)
+ {
+ if (!CCECTypeUtils::PhysicalAddressIsIncluded(iRoute, (*it)->GetCurrentPhysicalAddress()))
+ (*it)->MarkAsInactiveSource();
+ }
+}
+
void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */)
{
CLockObject lock(m_mutex);
GetVendorId(initiator); // ensure that we got the vendor id, because the implementations vary per vendor
MarkBusy();
- cec_power_status currentStatus = GetPowerStatus(initiator, false);
- if (currentStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON &&
- currentStatus != CEC_POWER_STATUS_ON)
+ cec_power_status currentStatus;
+ if (m_iLogicalAddress == CECDEVICE_TV ||
+ ((currentStatus = GetPowerStatus(initiator, false)) != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON &&
+ currentStatus != CEC_POWER_STATUS_ON))
{
LIB_CEC->AddLog(CEC_LOG_NOTICE, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- if (m_handler->PowerOn(initiator, m_iLogicalAddress))
- {
- SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
- bReturn = true;
- }
+ bReturn = m_handler->PowerOn(initiator, m_iLogicalAddress);
}
else
{