cec: persist the configuration after switching sources
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 27 Apr 2012 23:44:37 +0000 (01:44 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 27 Apr 2012 23:44:37 +0000 (01:44 +0200)
src/lib/CECProcessor.cpp

index b4f612b26bdfd94f8b895a642dda8624918243c8..861a9ac6ca5ef380effa53cef73a8378ae330833 100644 (file)
@@ -1689,18 +1689,15 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   if (m_configuration.deviceTypes.IsEmpty())
     m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
 
-  // persist the configuration
-  if (IsRunning())
-    m_communication->PersistConfiguration(&m_configuration);
-
+  bool bReturn(true);
   if (bReinit || m_configuration.logicalAddresses.IsEmpty())
   {
     if (bDeviceTypeChanged)
-      return ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]);
+      bReturn = ChangeDeviceType(oldPrimaryType, m_configuration.deviceTypes[0]);
     else if (IsValidPhysicalAddress(m_configuration.iPhysicalAddress))
-      return SetPhysicalAddress(m_configuration.iPhysicalAddress);
+      bReturn = SetPhysicalAddress(m_configuration.iPhysicalAddress);
     else if (m_configuration.baseDevice != CECDEVICE_UNKNOWN && m_configuration.iHDMIPort != CEC_HDMI_PORTNUMBER_NONE)
-      return SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort);
+      bReturn = SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort);
   }
   else if (m_configuration.bActivateSource == 1 && IsRunning() && !IsActiveSource(m_configuration.logicalAddresses.primary))
   {
@@ -1708,7 +1705,11 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
     SetActiveSource(m_configuration.deviceTypes.types[0]);
   }
 
-  return true;
+  // persist the configuration
+  if (IsRunning())
+    m_communication->PersistConfiguration(&m_configuration);
+
+  return bReturn;
 }
 
 bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)