cec: set the correct logical address mask before switching to autonomous mode. bugzid...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Mar 2012 19:57:43 +0000 (20:57 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Mar 2012 19:57:43 +0000 (20:57 +0100)
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/adapter/USBCECAdapterCommunication.cpp

index d676225eaa74ecf9e92fc6bee6f26dfd2aac1f5b..aeb16e2a5b55abb90423c2f4220b3cac52f9feca 100644 (file)
@@ -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;
+  }
+}
index fb98030fd6e46d96546c9b9eace927638b184b32..b8c8667d67ab9bd8b50d4b374d4e8243af53e823 100644 (file)
@@ -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, ...);
index e130514ee807df6bbac77affde5dc40d068b52a9..ef1be8362a76524f78a6729de4fe5859593f0ad2 100644 (file)
@@ -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);