From: Lars Op den Kamp Date: Thu, 8 Mar 2012 19:57:43 +0000 (+0100) Subject: cec: set the correct logical address mask before switching to autonomous mode. bugzid... X-Git-Tag: upstream/2.2.0~1^2~31^2~88 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=209b7a5c7a749d4bed7b463c3356918cc00d2704;p=deb_libcec.git cec: set the correct logical address mask before switching to autonomous mode. bugzid: 543 --- diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index d676225..aeb16e2 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -644,3 +644,59 @@ cec_device_type CLibCEC::GetType(cec_logical_address address) return CEC_DEVICE_TYPE_RESERVED; } } + +uint16_t CLibCEC::GetMaskForType(cec_logical_address address) +{ + return GetMaskForType(GetType(address)); +} + +uint16_t CLibCEC::GetMaskForType(cec_device_type type) +{ + switch (type) + { + case CEC_DEVICE_TYPE_AUDIO_SYSTEM: + { + cec_logical_addresses addr; + addr.Clear(); + addr.Set(CECDEVICE_AUDIOSYSTEM); + return addr.AckMask(); + } + case CEC_DEVICE_TYPE_PLAYBACK_DEVICE: + { + cec_logical_addresses addr; + addr.Clear(); + addr.Set(CECDEVICE_PLAYBACKDEVICE1); + addr.Set(CECDEVICE_PLAYBACKDEVICE2); + addr.Set(CECDEVICE_PLAYBACKDEVICE3); + return addr.AckMask(); + } + case CEC_DEVICE_TYPE_RECORDING_DEVICE: + { + cec_logical_addresses addr; + addr.Clear(); + addr.Set(CECDEVICE_RECORDINGDEVICE1); + addr.Set(CECDEVICE_RECORDINGDEVICE2); + addr.Set(CECDEVICE_RECORDINGDEVICE3); + return addr.AckMask(); + } + case CEC_DEVICE_TYPE_TUNER: + { + cec_logical_addresses addr; + addr.Clear(); + addr.Set(CECDEVICE_TUNER1); + addr.Set(CECDEVICE_TUNER2); + addr.Set(CECDEVICE_TUNER3); + addr.Set(CECDEVICE_TUNER4); + return addr.AckMask(); + } + case CEC_DEVICE_TYPE_TV: + { + cec_logical_addresses addr; + addr.Clear(); + addr.Set(CECDEVICE_TV); + return addr.AckMask(); + } + default: + return 0; + } +} diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index fb98030..b8c8667 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -123,6 +123,8 @@ namespace CEC const char *ToString(const cec_server_version version); static cec_device_type GetType(cec_logical_address address); + static uint16_t GetMaskForType(cec_logical_address address); + static uint16_t GetMaskForType(cec_device_type type); //@} static void AddLog(const cec_log_level level, const char *strFormat, ...); diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index e130514..ef1be83 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -578,7 +578,7 @@ bool CUSBCECAdapterCommunication::PersistConfiguration(libcec_configuration *con bReturn &= SetAutoEnabled(true); bReturn &= SetDeviceType(CLibCEC::GetType(configuration->logicalAddresses.primary)); bReturn &= SetDefaultLogicalAddress(configuration->logicalAddresses.primary); - bReturn &= SetLogicalAddressMask(configuration->logicalAddresses.AckMask()); + bReturn &= SetLogicalAddressMask(CLibCEC::GetMaskForType(configuration->logicalAddresses.primary)); bReturn &= SetPhysicalAddress(configuration->iPhysicalAddress); bReturn &= SetCECVersion(CEC_VERSION_1_3A); bReturn &= SetOSDName(configuration->strDeviceName);