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)
+ if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC && command.opcode_set == 1)
m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
MarkBusy();
void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
{
- CLockObject lock(m_mutex);
- switch (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;
- 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;
- break;
- case CEC_DEVICE_STATUS_PRESENT:
- if (m_deviceStatus != newStatus)
- CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'present'", ToString(m_iLogicalAddress));
- 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;
- break;
+ {
+ CLockObject lock(m_mutex);
+ switch (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;
+ 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;
+ break;
+ case CEC_DEVICE_STATUS_PRESENT:
+ if (m_deviceStatus != newStatus)
+ CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'present'", ToString(m_iLogicalAddress));
+ 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;
+ break;
+ }
}
+
+ if (newStatus == CEC_DEVICE_STATUS_PRESENT)
+ RequestVendorId();
}
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);
+ 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
+ device->SetActiveSource();
+ }
+ else
+ {
+ // try to find the device with the old address, and mark it as inactive when found
+ device = m_processor->GetDeviceByPhysicalAddress(iOldAddress, false);
+ if (device)
+ device->SetInactiveSource();
+ }
+
if (iNewAddress > 0)
{
lock.Unlock();