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();
{
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;
}
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++)
{
{
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;
}
}
}
-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++)
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;
CECDEVICEMAP m_busDevices;
CCECProcessor *m_processor;
- uint16_t m_iActiveSource;
};
}
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;