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

Method ChangeDeviceType

src/libcec/CECClient.cpp:443–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443bool CCECClient::ChangeDeviceType(const cec_device_type from, const cec_device_type to)
444{
445 if (from == to)
446 return true;
447
448 LIB_CEC->AddLog(CEC_LOG_NOTICE, "changing device type '%s' into '%s'", ToString(from), ToString(to));
449
450 {
451 CLockObject lock(m_mutex);
452
453 // get the previous device that was allocated
454 CCECBusDevice *previousDevice = GetDeviceByType(from);
455 if (!previousDevice)
456 return false;
457
458 // change the type in the device type list
459 bool bChanged(false);
460 for (uint8_t iPtr = 0; iPtr < 5; iPtr++)
461 {
462 if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_RESERVED)
463 continue;
464
465 if (m_configuration.deviceTypes.types[iPtr] == from)
466 {
467 bChanged = true;
468 m_configuration.deviceTypes.types[iPtr] = to;
469 }
470 else if (m_configuration.deviceTypes.types[iPtr] == to && bChanged)
471 {
472 // ensure that dupes are removed
473 m_configuration.deviceTypes.types[iPtr] = CEC_DEVICE_TYPE_RESERVED;
474 }
475 }
476 }
477
478 // re-register the client to set the new ackmask
479 if (!m_processor->RegisterClient(this))
480 return false;
481
482 SaveConfiguration(m_configuration);
483
484 return true;
485}
486
487bool CCECClient::SetLogicalAddress(const cec_logical_address iLogicalAddress)
488{

Callers 1

InitHandlerMethod · 0.45

Calls 3

ToStringFunction · 0.85
AddLogMethod · 0.45
RegisterClientMethod · 0.45

Tested by

no test coverage detected