X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECClient.cpp;h=7cf542bd1766ee445214d6cd718ee4c3b8a28a11;hb=42d28d15d07f893b491051970ade1bd56bb596eb;hp=ae0b9f6e0c7408c5a73758c43db5d37cfc5cc08a;hpb=34fe491f051387fa870da9459ce53892f7bb03ab;p=deb_libcec.git diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index ae0b9f6..7cf542b 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -37,6 +37,7 @@ #include "devices/CECPlaybackDevice.h" #include "devices/CECAudioSystem.h" #include "devices/CECTV.h" +#include "implementations/CECCommandHandler.h" using namespace CEC; using namespace PLATFORM; @@ -120,9 +121,6 @@ bool CCECClient::OnRegister(void) // set the physical address SetPhysicalAddress(m_configuration); - // ensure that we know the vendor id of the TV, so we are using the correct handler - m_processor->GetTV()->GetVendorId(GetPrimaryLogicalAdddress()); - // make the primary device the active source if the option is set if (m_configuration.bActivateSource == 1) GetPrimaryDevice()->ActivateSource(); @@ -250,11 +248,40 @@ bool CCECClient::SetPhysicalAddress(const uint16_t iPhysicalAddress) return true; } +void CCECClient::SetSupportedDeviceTypes(void) +{ + cec_device_type_list types; + types.Clear(); + + // get the command handler for the tv + CCECCommandHandler *tvHandler = m_processor->GetTV()->GetHandler(); + if (!tvHandler) + return; + + // check all device types + for (uint8_t iPtr = 0; iPtr < 5; iPtr++) + { + if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_RESERVED) + continue; + + // get the supported device type. the handler will replace types it doesn't support by one it does support + cec_device_type type = tvHandler->GetReplacementDeviceType(m_configuration.deviceTypes.types[iPtr]); + if (!types.IsSet(type)) + types.Add(type); + } + + // set the new type list + m_configuration.deviceTypes = types; +} + bool CCECClient::AllocateLogicalAddresses(void) { // reset all previous LAs that were set m_configuration.logicalAddresses.Clear(); + // get the supported device types from the command handler of the TV + SetSupportedDeviceTypes(); + // display an error if no device types are set if (m_configuration.deviceTypes.IsEmpty()) {