From: Lars Op den Kamp Date: Wed, 14 Nov 2012 01:26:52 +0000 (+0100) Subject: no need to cache the physical address of the active source in the device map; the... X-Git-Tag: upstream/2.2.0~1^2~12^2~22 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=d5890d16af8ca61857553a4285ee34c1d104353c no need to cache the physical address of the active source in the device map; the address of the active source is sent along with the message --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 399e065..e432033 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -351,7 +351,7 @@ cec_logical_address CCECProcessor::GetActiveSource(bool bRequestActiveSource /* if (activeSource) return activeSource->GetLogicalAddress(); - if (bRequestActiveSource && m_busDevices->GetActiveSourceAddress() == CEC_INVALID_PHYSICAL_ADDRESS) + if (bRequestActiveSource) { // request the active source from the bus CCECBusDevice *primary = GetPrimaryDevice(); diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index d50045a..fd2a348 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -537,9 +537,6 @@ bool CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress); m_iPhysicalAddress = iNewAddress; - - if (m_processor->GetDevices()->GetActiveSourceAddress() == iNewAddress) - MarkAsActiveSource(); } return true; } diff --git a/src/lib/devices/CECDeviceMap.cpp b/src/lib/devices/CECDeviceMap.cpp index b614e1a..b7f3ab2 100644 --- a/src/lib/devices/CECDeviceMap.cpp +++ b/src/lib/devices/CECDeviceMap.cpp @@ -45,8 +45,7 @@ using namespace std; using namespace CEC; CCECDeviceMap::CCECDeviceMap(CCECProcessor *processor) : - m_processor(processor), - m_iActiveSource(CEC_INVALID_PHYSICAL_ADDRESS) + m_processor(processor) { for (uint8_t iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++) { @@ -207,10 +206,6 @@ 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; } @@ -289,16 +284,6 @@ void CCECDeviceMap::GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) } } -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++) diff --git a/src/lib/devices/CECDeviceMap.h b/src/lib/devices/CECDeviceMap.h index 50271dc..6037fa3 100644 --- a/src/lib/devices/CECDeviceMap.h +++ b/src/lib/devices/CECDeviceMap.h @@ -63,8 +63,6 @@ namespace CEC void GetActive(CECDEVICEVEC &devices) const; void GetByType(const cec_device_type type, CECDEVICEVEC &devices) const; void GetChildrenOf(CECDEVICEVEC& devices, CCECBusDevice* device) const; - void SetActiveSource(uint16_t iPhysicalAddress); - uint16_t GetActiveSourceAddress(void) const; void SignalAll(cec_opcode opcode); void GetPowerOffDevices(const libcec_configuration &configuration, CECDEVICEVEC &devices) const; @@ -82,6 +80,5 @@ namespace CEC CECDEVICEMAP m_busDevices; CCECProcessor *m_processor; - uint16_t m_iActiveSource; }; } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 3423c28..0e00e4c 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -209,10 +209,12 @@ int CCECCommandHandler::HandleActiveSource(const cec_command &command) if (command.parameters.size == 2) { uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); - m_processor->GetDevices()->SetActiveSource(iAddress); - CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iAddress); + CCECBusDevice *device = m_processor->GetDevice(command.initiator); if (device) + { + device->SetPhysicalAddress(iAddress); device->MarkAsActiveSource(); + } m_processor->GetDevices()->SignalAll(command.opcode); return COMMAND_HANDLED;