stall outgoing messages when the logical address was lost, until we got a new address
[deb_libcec.git] / src / lib / CECProcessor.h
index 5f496d2631558506045e645ecf450e4ba37c5995..e1f6d68517eee2908cc7f1b6906e72db0f29240b 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <string>
-#include "../../include/cectypes.h"
 
 #include "platform/threads/threads.h"
 #include "platform/util/buffer.h"
@@ -52,6 +51,18 @@ namespace CEC
   class CCECTuner;
   class CCECTV;
   class CCECClient;
+  class CCECProcessor;
+
+  class CCECAllocateLogicalAddress : public PLATFORM::CThread
+  {
+  public:
+    CCECAllocateLogicalAddress(CCECProcessor* processor, CCECClient* client);
+    void* Process(void);
+
+  private:
+    CCECProcessor* m_processor;
+    CCECClient*    m_client;
+  };
 
   class CCECProcessor : public PLATFORM::CThread, public IAdapterCommunicationCallback
   {
@@ -70,6 +81,7 @@ namespace CEC
       CCECClient *GetClient(const cec_logical_address address);
 
       bool                  OnCommandReceived(const cec_command &command);
+      void                  HandleLogicalAddressLost(cec_logical_address oldAddress);
 
       CCECBusDevice *       GetDevice(cec_logical_address address) const;
       CCECAudioSystem *     GetAudioSystem(void) const;
@@ -89,7 +101,6 @@ namespace CEC
       cec_logical_address   GetActiveSource(bool bRequestActiveSource = true);
       bool                  IsActiveSource(cec_logical_address iAddress);
       bool                  CECInitialised(void);
-      bool                  SetStreamPath(uint16_t iPhysicalAddress);
 
       bool                  StandbyDevices(const cec_logical_address initiator, const CECDEVICEVEC &devices);
       bool                  StandbyDevice(const cec_logical_address initiator, cec_logical_address address);
@@ -109,7 +120,7 @@ namespace CEC
 
       bool SetLineTimeout(uint8_t iTimeout);
 
-      bool Transmit(const cec_command &data);
+      bool Transmit(const cec_command &data, bool bIsReply);
       void TransmitAbort(cec_logical_address source, cec_logical_address destination, cec_opcode opcode, cec_abort_reason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
 
       bool StartBootloader(const char *strPort = NULL);
@@ -126,16 +137,21 @@ namespace CEC
 
       bool IsHandledByLibCEC(const cec_logical_address address) const;
 
-      bool TryLogicalAddress(cec_logical_address address);
+      bool TryLogicalAddress(cec_logical_address address, cec_version libCECSpecVersion = CEC_VERSION_1_4);
 
       bool IsRunningLatestFirmware(void);
-  private:
+      void SwitchMonitoring(bool bSwitchTo);
+
+      bool AllocateLogicalAddresses(CCECClient* client);
+    private:
       bool OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs, bool bStartListening = true);
       void SetCECInitialised(bool bSetTo = true);
 
       void ReplaceHandlers(void);
       bool PhysicalAddressInUse(uint16_t iPhysicalAddress);
-      bool SetAckMask(uint16_t iMask);
+
+      bool ClearLogicalAddresses(void);
+      bool SetLogicalAddresses(const cec_logical_addresses &addresses);
 
       void LogOutput(const cec_command &data);
       void ProcessCommand(const cec_command &command);
@@ -152,5 +168,8 @@ namespace CEC
       CCECInputBuffer                             m_inBuffer;
       CCECDeviceMap *                             m_busDevices;
       std::map<cec_logical_address, CCECClient *> m_clients;
+      bool                                        m_bMonitor;
+      CCECAllocateLogicalAddress*                 m_addrAllocator;
+      bool                                        m_bStallCommunication;
   };
 };