From: Lars Op den Kamp Date: Fri, 9 Dec 2011 12:28:37 +0000 (+0100) Subject: cec: fixed - set power state to powered off when a device handled by libcec is made... X-Git-Tag: upstream/2.2.0~1^2~44^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3fd2a2b89c3f6f9d8e28c19e45622386a981ef8d;p=deb_libcec.git cec: fixed - set power state to powered off when a device handled by libcec is made inactive. transmit an active source message and the deck status when made active --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 565d226..60a6d19 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -530,7 +530,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) for (uint8_t iPtr = 0; iPtr < 15; iPtr++) if (m_logicalAddresses[iPtr]) { - m_busDevices[iPtr]->SetInactiveDevice(); + m_busDevices[iPtr]->SetInactiveSource(); m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress); m_busDevices[iPtr]->TransmitPhysicalAddress(); } diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index f03f0cb..41643a3 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -434,10 +434,15 @@ void CCECBusDevice::SetMenuState(const cec_menu_state state) } } -void CCECBusDevice::SetInactiveDevice(void) +void CCECBusDevice::SetInactiveSource(void) { - CLockObject lock(&m_writeMutex); - m_bActiveSource = false; + { + CLockObject lock(&m_writeMutex); + m_bActiveSource = false; + } + + if (MyLogicalAddressContains(m_iLogicalAddress)) + SetPowerStatus(CEC_POWER_STATUS_STANDBY); } void CCECBusDevice::SetActiveSource(void) @@ -446,7 +451,7 @@ void CCECBusDevice::SetActiveSource(void) for (int iPtr = 0; iPtr < 16; iPtr++) if (iPtr != m_iLogicalAddress) - m_processor->m_busDevices[iPtr]->SetInactiveDevice(); + m_processor->m_busDevices[iPtr]->SetInactiveSource(); m_bActiveSource = true; m_powerStatus = CEC_POWER_STATUS_ON; diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index f1786f9..b8a9aa9 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -75,7 +75,7 @@ namespace CEC virtual bool IsActiveSource(void) const { return m_bActiveSource; } - virtual void SetInactiveDevice(void); + virtual void SetInactiveSource(void); virtual void SetActiveSource(void); virtual bool TryLogicalAddress(void); diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 11d550c..80bc280 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -564,7 +564,18 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) { CCECBusDevice *device = GetDevice(command.destination); if (device) + { device->SetPowerStatus(CEC_POWER_STATUS_ON); + if (device->MyLogicalAddressContains(device->GetLogicalAddress())) + { + device->SetActiveSource(); + device->TransmitActiveSource(); + + if (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || + device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) + ((CCECPlaybackDevice *)device)->TransmitDeckStatus(command.initiator); + } + } } m_processor->SetCurrentButton((cec_user_control_code) command.parameters[0]);