if (activeSource)
return activeSource->GetLogicalAddress();
- if (bRequestActiveSource)
+ if (bRequestActiveSource && m_busDevices->GetActiveSourceAddress() == CEC_INVALID_PHYSICAL_ADDRESS)
{
// 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;
}
if (bWasActivated)
{
- m_processor->SetActiveSource(true, false);
+ if (IsHandledByLibCEC())
+ m_processor->SetActiveSource(true, false);
CCECClient *client = GetClient();
if (client)
client->SourceActivated(m_iLogicalAddress);
if (bWasDeactivated)
{
- m_processor->SetActiveSource(false, bClientUnregistered);
+ if (IsHandledByLibCEC())
+ m_processor->SetActiveSource(false, bClientUnregistered);
CCECClient *client = GetClient();
if (client)
client->SourceDeactivated(m_iLogicalAddress);
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++)
{
{
for (CECDEVICEMAP::const_iterator it = m_busDevices.begin(); it != m_busDevices.end(); it++)
{
+ if (m_iActiveSource != CEC_INVALID_PHYSICAL_ADDRESS && !it->second->IsActiveSource() &&
+ m_iActiveSource == it->second->GetCurrentPhysicalAddress())
+ it->second->MarkAsActiveSource();
if (it->second->IsActiveSource())
return it->second;
}
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);
+}
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;
void GetWakeDevices(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);
if (device)
- {
device->MarkAsActiveSource();
- return COMMAND_HANDLED;
- }
+
+ m_processor->GetDevices()->SignalAll(command.opcode);
+ return COMMAND_HANDLED;
}
return CEC_ABORT_REASON_INVALID_OPERAND;
if (addresses[iPtr])
{
uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr);
- bool bActive = parser->IsActiveSource((cec_logical_address)iPtr);
uint16_t iPhysicalAddress = parser->GetDevicePhysicalAddress((cec_logical_address)iPtr);
+ bool bActive = parser->IsActiveSource((cec_logical_address)iPtr);
cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
cec_osd_name osdName = parser->GetDeviceOSDName((cec_logical_address)iPtr);
}
}
+ activeSource = parser->GetActiveSource();
strLog.AppendFormat("currently active source: %s (%d)", parser->ToString(activeSource), (int)activeSource);
PrintToStdOut(strLog);