X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECDeviceMap.cpp;h=b614e1a9175a1c322e28578fcee55ca2390ebb65;hb=ecc633c51b6c69bebaff4932e90245665ca06373;hp=a21b2b43254149cf51408d43c90365a81bbe6a4a;hpb=f8edb2973d37f3ebfd08291f28be5435d0cf8f64;p=deb_libcec.git diff --git a/src/lib/devices/CECDeviceMap.cpp b/src/lib/devices/CECDeviceMap.cpp index a21b2b4..b614e1a 100644 --- a/src/lib/devices/CECDeviceMap.cpp +++ b/src/lib/devices/CECDeviceMap.cpp @@ -39,12 +39,14 @@ #include "CECTuner.h" #include "CECTV.h" #include "lib/CECProcessor.h" +#include "lib/CECTypeUtils.h" using namespace std; using namespace CEC; CCECDeviceMap::CCECDeviceMap(CCECProcessor *processor) : - m_processor(processor) + m_processor(processor), + m_iActiveSource(CEC_INVALID_PHYSICAL_ADDRESS) { for (uint8_t iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++) { @@ -205,6 +207,10 @@ CCECBusDevice *CCECDeviceMap::GetActiveSource(void) const { for (CECDEVICEMAP::const_iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++) { + if (m_iActiveSource != CEC_INVALID_PHYSICAL_ADDRESS && !it->second->IsActiveSource() && + it->second->GetCurrentPowerStatus() == CEC_POWER_STATUS_ON && + m_iActiveSource == it->second->GetCurrentPhysicalAddress()) + it->second->MarkAsActiveSource(); if (it->second->IsActiveSource()) return it->second; } @@ -266,3 +272,35 @@ cec_logical_addresses CCECDeviceMap::ToLogicalAddresses(const CECDEVICEVEC &devi addresses.Set((*it)->GetLogicalAddress()); return addresses; } + +void CCECDeviceMap::GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) const +{ + devices.clear(); + if (!device) + return; + + uint16_t iPA = device->GetCurrentPhysicalAddress(); + + for (CECDEVICEMAP::const_iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++) + { + uint16_t iCurrentPA = it->second->GetCurrentPhysicalAddress(); + if (CCECTypeUtils::PhysicalAddressIsIncluded(iPA, iCurrentPA)) + devices.push_back(it->second); + } +} + +void CCECDeviceMap::SetActiveSource(uint16_t iPhysicalAddress) +{ + m_iActiveSource = iPhysicalAddress; +} + +uint16_t CCECDeviceMap::GetActiveSourceAddress(void) const +{ + return m_iActiveSource; +} + +void CCECDeviceMap::SignalAll(cec_opcode opcode) +{ + for (CECDEVICEMAP::iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++) + it->second->SignalOpcode(opcode); +}