cec: don't replace handlers when not initialised, or the primary device's logical...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 2 Feb 2012 20:06:21 +0000 (21:06 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 2 Feb 2012 20:06:21 +0000 (21:06 +0100)
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h

index 20b63bd7347ad1726d92647de2a80712d73b8751..c63bc57666f846a381571eb84d11042fb06ae818 100644 (file)
@@ -162,6 +162,12 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
   return bReturn;
 }
 
+bool CCECProcessor::IsInitialised(void)
+{
+  CLockObject lock(m_mutex);
+  return m_bInitialised;
+}
+
 void CCECProcessor::SetInitialised(bool bSetTo /* = true */)
 {
   CLockObject lock(m_mutex);
@@ -377,6 +383,8 @@ bool CCECProcessor::FindLogicalAddresses(void)
 
 void CCECProcessor::ReplaceHandlers(void)
 {
+  if (!IsInitialised())
+    return;
   for (uint8_t iPtr = 0; iPtr <= CECDEVICE_PLAYBACKDEVICE3; iPtr++)
     m_busDevices[iPtr]->ReplaceHandler(m_bInitialised);
 }
@@ -1315,10 +1323,10 @@ bool CCECProcessor::PingAdapter(void)
 
 void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination)
 {
-  m_busDevices[initiator]->GetHandler()->HandlePoll(initiator, destination);
+  m_busDevices[initiator]->HandlePoll(destination);
 }
 
 bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator)
 {
-  return !m_busDevices[initiator]->GetHandler()->HandleReceiveFailed();
+  return !m_busDevices[initiator]->HandleReceiveFailed();
 }
index 3e98cc0abc439d694faf4e413f52ed93db6bdaad..0d2446acd065fa57a0b69cfbc6ab1a1cc83c7207 100644 (file)
@@ -76,7 +76,7 @@ namespace CEC
       virtual uint64_t              GetLastTransmission(void) const { return m_iLastTransmission; }
       virtual cec_logical_address   GetActiveSource(void);
       virtual bool                  IsActiveSource(cec_logical_address iAddress);
-      virtual bool                  IsInitialised(void) const { return m_bInitialised; }
+      virtual bool                  IsInitialised(void);
 
       virtual bool SetActiveView(void);
       virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
index 61af7019f3147691a76acfd71ab66033e157c77e..3577518a95305bb7fa0574968d95e696841f3465 100644 (file)
@@ -834,4 +834,16 @@ bool CCECBusDevice::ActivateSource(void)
   return m_handler->ActivateSource();
 }
 
+void CCECBusDevice::HandlePoll(cec_logical_address destination)
+{
+  CLockObject lock(m_handlerMutex);
+  m_handler->HandlePoll(m_iLogicalAddress, destination);
+}
+
+bool CCECBusDevice::HandleReceiveFailed(void)
+{
+  CLockObject lock(m_handlerMutex);
+  return m_handler->HandleReceiveFailed();
+}
+
 //@}
index df7bd96ba2e53c2698661250229568f55eaab42a..0415ad19e08817287b7829b4d5784f46c1c52a88 100644 (file)
@@ -76,6 +76,8 @@ namespace CEC
     virtual bool                  IsActiveSource(void) const { return m_bActiveSource; }
     virtual bool                  IsUnsupportedFeature(cec_opcode opcode) const;
     virtual void                  SetUnsupportedFeature(cec_opcode opcode);
+    virtual void                  HandlePoll(cec_logical_address initiator);
+    virtual bool                  HandleReceiveFailed(void);
 
     virtual void SetInactiveSource(void);
     virtual void SetActiveSource(void);