cec: fix active source switches for the standard CEC implementation. added some log...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 16 Feb 2012 00:58:29 +0000 (01:58 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 16 Feb 2012 00:58:29 +0000 (01:58 +0100)
src/lib/CECProcessor.cpp
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/implementations/CECCommandHandler.cpp

index 20b8e059f329f210400fd9570af8c0c5f571fa25..00d7744825254abba1c8f09b04d2a7fcec16dd1c 100644 (file)
@@ -853,6 +853,12 @@ bool CCECProcessor::IsActiveSource(cec_logical_address iAddress)
 
 bool CCECProcessor::Transmit(const cec_command &data)
 {
+  if (m_logicalAddresses[(uint8_t)data.destination])
+  {
+    CLibCEC::AddLog(CEC_LOG_WARNING, "not sending data to myself!");
+    return false;
+  }
+
   cec_adapter_message_state retVal(ADAPTER_MESSAGE_STATE_UNKNOWN);
   {
     CLockObject lock(m_mutex);
index 7037c78eff960357f2842e3f8cd5a154dfcb61cb..96571cc3dc52bcb5fb4df06ea55e7fdfcae4d17c 100644 (file)
@@ -173,12 +173,12 @@ bool CUSBCECAdapterCommunication::Open(IAdapterCommunicationCallback *cb, uint32
 
 void CUSBCECAdapterCommunication::Close(void)
 {
-  SetAckMask(0);
   {
     CLockObject lock(m_mutex);
     m_bHasData = true;
     m_rcvCondition.Broadcast();
   }
+  SetAckMask(0);
   StopThread();
 }
 
index 59dcb4662d40ba9d813973e8713546a04325f242..a5d884e5e397b7424d66e78d397cf9277af8effe 100644 (file)
@@ -534,6 +534,8 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
   switch (newStatus)
   {
   case CEC_DEVICE_STATUS_UNKNOWN:
+    if (m_deviceStatus != newStatus)
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'unknown'", ToString(m_iLogicalAddress));
     m_iStreamPath      = 0;
     m_powerStatus      = CEC_POWER_STATUS_UNKNOWN;
     m_vendor           = CEC_VENDOR_UNKNOWN;
@@ -544,6 +546,8 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
     m_deviceStatus     = newStatus;
     break;
   case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC:
+    if (m_deviceStatus != newStatus)
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'handled by libCEC'", ToString(m_iLogicalAddress));
     m_iStreamPath      = 0;
     m_powerStatus      = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON;
     m_vendor           = CEC_VENDOR_UNKNOWN;
@@ -554,7 +558,13 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus)
     m_deviceStatus     = newStatus;
     break;
   case CEC_DEVICE_STATUS_PRESENT:
+    if (m_deviceStatus != newStatus)
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'present'", ToString(m_iLogicalAddress));
+    m_deviceStatus = newStatus;
+    break;
   case CEC_DEVICE_STATUS_NOT_PRESENT:
+    if (m_deviceStatus != newStatus)
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'not present'", ToString(m_iLogicalAddress));
     m_deviceStatus = newStatus;
     break;
   }
index 8ec93eee09d22a9902bbc24f55dc776441d61d3d..83d993682b510d97132aa98af76e969410c2536a 100644 (file)
@@ -983,22 +983,20 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /*
 
 bool CCECCommandHandler::ActivateSource(void)
 {
-  if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
-  {
-    CCECBusDevice *primary = m_processor->GetPrimaryDevice();
-    primary->SetPowerStatus(CEC_POWER_STATUS_ON);
-    primary->SetMenuState(CEC_MENU_STATE_ACTIVATED);
-
-    if (m_busDevice->GetStatus(false) == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
-    {
-      m_busDevice->TransmitMenuState(CECDEVICE_TV);
-
-      if ((m_busDevice->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
-          m_busDevice->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) &&
-          SendDeckStatusUpdateOnActiveSource())
-        ((CCECPlaybackDevice *)m_busDevice)->TransmitDeckStatus(CECDEVICE_TV);
-      m_bHandlerInited = true;
-    }
+  if (m_busDevice->IsActiveSource() &&
+    m_busDevice->GetStatus(false) == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+  {
+    m_busDevice->SetPowerStatus(CEC_POWER_STATUS_ON);
+    m_busDevice->SetMenuState(CEC_MENU_STATE_ACTIVATED);
+
+    m_busDevice->TransmitImageViewOn();
+    m_busDevice->TransmitActiveSource();
+    m_busDevice->TransmitMenuState(CECDEVICE_TV);
+    if ((m_busDevice->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
+      m_busDevice->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) &&
+      SendDeckStatusUpdateOnActiveSource())
+      ((CCECPlaybackDevice *)m_busDevice)->TransmitDeckStatus(CECDEVICE_TV);
+    m_bHandlerInited = true;
   }
   return true;
 }