X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=814f58a63237b9cbb00456bcd54ace9f2b0cdf88;hb=e69d8f191784c77c156ffec90db50767f91421e3;hp=33d472f7acc685f0adadbaf213b51fea867ac06f;hpb=ebb6ddb38f42d6185faf3c30be8ccfeee1889ee2;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 33d472f..814f58a 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -88,7 +88,7 @@ bool CCECBusDevice::HandleCommand(const cec_command &command) 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(); @@ -470,7 +470,7 @@ cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */) if (bNeedsPoll) { bool bPollAcked(false); - if (bNeedsPoll || NeedsPoll()) + if (bNeedsPoll && NeedsPoll()) bPollAcked = m_processor->PollDevice(m_iLogicalAddress); status = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT; @@ -524,6 +524,8 @@ void CCECBusDevice::SetInactiveSource(void) { { CLockObject lock(m_mutex); + if (m_bActiveSource) + CLibCEC::AddLog(CEC_LOG_DEBUG, "marking %s (%X) as inactive source", GetLogicalAddressName(), m_iLogicalAddress); m_bActiveSource = false; } @@ -623,6 +625,20 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* 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(); @@ -901,7 +917,10 @@ bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) { CLockObject lock(m_mutex); if (!IsActiveSource()) + { + CLibCEC::AddLog(CEC_LOG_NOTICE, "power state requested of %s (%X), but we are not the active source. setting power state to standby", GetLogicalAddressName(), m_iLogicalAddress); SetPowerStatus(CEC_POWER_STATUS_STANDBY); + } CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus)); state = m_powerStatus;