MCPcopy Create free account
hub / github.com/Pulse-Eight/libcec / SetDevicePhysicalAddress

Method SetDevicePhysicalAddress

src/libcec/CECClient.cpp:1439–1482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1437}
1438
1439bool CCECClient::SetDevicePhysicalAddress(const uint16_t iPhysicalAddress)
1440{
1441 if (!CLibCEC::IsValidPhysicalAddress(iPhysicalAddress))
1442 {
1443 LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - not setting invalid physical address %04x", __FUNCTION__, iPhysicalAddress);
1444 return false;
1445 }
1446
1447 // reconfigure all devices
1448 cec_logical_address reactivateSource(CECDEVICE_UNKNOWN);
1449 CECDEVICEVEC devices;
1450 m_processor->GetDevices()->GetByLogicalAddresses(devices, m_configuration.logicalAddresses);
1451 for (CECDEVICEVEC::iterator it = devices.begin(); it != devices.end(); it++)
1452 {
1453 // if this device was the active source, reactivate it afterwards
1454 if ((*it)->IsActiveSource())
1455 reactivateSource = (*it)->GetLogicalAddress();
1456
1457 // mark the device as inactive source
1458 if (IsInitialised())
1459 (*it)->MarkAsInactiveSource();
1460
1461 // set the new physical address
1462 (*it)->SetPhysicalAddress(iPhysicalAddress);
1463
1464 // and transmit it
1465 if (IsInitialised())
1466 (*it)->TransmitPhysicalAddress(false);
1467 }
1468
1469 // reactivate the previous active source
1470 if (reactivateSource != CECDEVICE_UNKNOWN &&
1471 m_processor->CECInitialised() &&
1472 IsInitialised())
1473 {
1474 CCECBusDevice *device = m_processor->GetDevice(reactivateSource);
1475 if (device)
1476 device->ActivateSource();
1477 }
1478
1479 SaveConfiguration(m_configuration);
1480
1481 return true;
1482}
1483
1484bool CCECClient::SwitchMonitoring(bool bEnable)
1485{

Callers

nothing calls this directly

Calls 11

GetByLogicalAddressesMethod · 0.80
GetDevicesMethod · 0.80
MarkAsInactiveSourceMethod · 0.80
CECInitialisedMethod · 0.80
AddLogMethod · 0.45
IsActiveSourceMethod · 0.45
GetLogicalAddressMethod · 0.45
SetPhysicalAddressMethod · 0.45
GetDeviceMethod · 0.45
ActivateSourceMethod · 0.45

Tested by

no test coverage detected