X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECClient.cpp;h=008831b95527b6438747b4ebc4f6b12e668292a8;hb=92eea1e751ae678059402e04688b3b94700b7013;hp=24f196f49287008800a01c1b88f76ff4d0463259;hpb=cc938f166e50b0c9e4fdccf55e0a8cffb2c56602;p=deb_libcec.git diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index 24f196f..008831b 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -33,15 +33,17 @@ #include "CECClient.h" #include "CECProcessor.h" #include "LibCEC.h" +#include "CECTypeUtils.h" #include "devices/CECPlaybackDevice.h" #include "devices/CECAudioSystem.h" #include "devices/CECTV.h" +#include "implementations/CECCommandHandler.h" using namespace CEC; using namespace PLATFORM; #define LIB_CEC m_processor->GetLib() -#define ToString(x) LIB_CEC->ToString(x) +#define ToString(x) CCECTypeUtils::ToString(x) CCECClient::CCECClient(CCECProcessor *processor, const libcec_configuration &configuration) : m_processor(processor), @@ -119,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(); @@ -194,15 +193,19 @@ void CCECClient::ResetPhysicalAddress(void) void CCECClient::SetPhysicalAddress(const libcec_configuration &configuration) { - // try to autodetect the address bool bPASet(false); - if (m_processor->CECInitialised() && configuration.bAutodetectAddress == 1) - bPASet = AutodetectPhysicalAddress(); - // try to use physical address setting + // override the physical address from configuration.iPhysicalAddress if it's set if (!bPASet && CLibCEC::IsValidPhysicalAddress(configuration.iPhysicalAddress)) bPASet = SetPhysicalAddress(configuration.iPhysicalAddress); + // try to autodetect the address + if (!bPASet && m_processor->CECInitialised()) + { + bPASet = AutodetectPhysicalAddress(); + m_configuration.bAutodetectAddress = bPASet ? 1 : 0; + } + // use the base device + hdmi port settings if (!bPASet) bPASet = SetHDMIPort(configuration.baseDevice, configuration.iHDMIPort); @@ -245,11 +248,41 @@ 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); + } + m_processor->GetTV()->MarkHandlerReady(); + + // 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()) { @@ -678,21 +711,19 @@ uint8_t CCECClient::SendMuteAudio(void) bool CCECClient::SendKeypress(const cec_logical_address iDestination, const cec_user_control_code key, bool bWait /* = true */) { - CCECBusDevice *device = GetPrimaryDevice(); CCECBusDevice *dest = m_processor->GetDevice(iDestination); - return device && dest ? - device->TransmitKeypress(GetPrimaryLogicalAdddress(), key, bWait) : + return dest ? + dest->TransmitKeypress(GetPrimaryLogicalAdddress(), key, bWait) : false; } bool CCECClient::SendKeyRelease(const cec_logical_address iDestination, bool bWait /* = true */) { - CCECBusDevice *device = GetPrimaryDevice(); CCECBusDevice *dest = m_processor->GetDevice(iDestination); - return device && dest ? - device->TransmitKeyRelease(GetPrimaryLogicalAdddress(), bWait) : + return dest ? + dest->TransmitKeyRelease(GetPrimaryLogicalAdddress(), bWait) : false; }