cec: fixed missing virtual keyword in CCECCommandHandler::GetReplacementDeviceType...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 19 Jun 2012 14:59:12 +0000 (16:59 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 19 Jun 2012 15:00:27 +0000 (17:00 +0200)
src/lib/CECClient.cpp
src/lib/CECProcessor.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/CECCommandHandler.h
src/lib/implementations/VLCommandHandler.cpp

index 7cf542bd1766ee445214d6cd718ee4c3b8a28a11..008831b95527b6438747b4ebc4f6b12e668292a8 100644 (file)
@@ -269,6 +269,7 @@ void CCECClient::SetSupportedDeviceTypes(void)
     if (!types.IsSet(type))
       types.Add(type);
   }
+  m_processor->GetTV()->MarkHandlerReady();
 
   // set the new type list
   m_configuration.deviceTypes = types;
index ca323fc4b67851fd3f26a58ff5b3998595b5bc56..848800ec4cbd9985d6dfab27330f9cccc740bfd9 100644 (file)
@@ -208,6 +208,7 @@ void CCECProcessor::CheckPendingActiveSource(void)
   {
     if (it->second->GetHandler()->ActiveSourcePending())
       it->second->ActivateSource();
+    it->second->MarkHandlerReady();
   }
 }
 
@@ -413,6 +414,7 @@ bool CCECProcessor::Transmit(const cec_command &data)
     m_iLastTransmission = GetTimeMs();
     // set the number of tries
     iMaxTries = initiator->GetHandler()->GetTransmitRetries() + 1;
+    initiator->MarkHandlerReady();
   }
 
   // and try to send the command
@@ -565,7 +567,9 @@ bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator)
 bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
 {
   // stream path changes are sent by the TV
-  return GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
+  bool bReturn = GetTV()->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
+  GetTV()->MarkHandlerReady();
+  return bReturn;
 }
 
 bool CCECProcessor::CanPersistConfiguration(void)
@@ -729,6 +733,7 @@ bool CCECProcessor::RegisterClient(CCECClient *client)
     CCECCommandHandler *handler = GetTV()->GetHandler();
     if (handler)
       handler->InitHandler();
+    GetTV()->MarkHandlerReady();
   }
 
   return bReturn;
index 8f966a233194dd748e76a1a43c1b85263ca1a225..e1697c3b877d1ece1040e8b6ee84cca265108b0b 100644 (file)
@@ -148,6 +148,13 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
   return true;
 }
 
+CCECCommandHandler *CCECBusDevice::GetHandler(void)
+{
+  ReplaceHandler(false);
+  MarkBusy();
+  return m_handler;
+}
+
 bool CCECBusDevice::HandleCommand(const cec_command &command)
 {
   bool bHandled(false);
index 0e11d42725a5591f5670b60a5e02bf52501afa68..dcfbbbc4ab9f28b8c33b054e7bac3c082efeb000 100644 (file)
@@ -56,7 +56,19 @@ namespace CEC
     virtual ~CCECBusDevice(void);
 
     virtual bool                  ReplaceHandler(bool bActivateSource = true);
-    virtual CCECCommandHandler *  GetHandler(void) const        { return m_handler; };
+
+    // TODO use something smarter than this
+    /*!
+     * @brief Get the command handler for this device. Call MarkHandlerReady() when done with it.
+     * @return The current handler.
+     */
+    virtual CCECCommandHandler *  GetHandler(void);
+
+    /*!
+     * @brief To be called after GetHandler(), when no longer using it.
+     */
+    virtual void                  MarkHandlerReady(void) { MarkReady(); }
+
     virtual CCECProcessor *       GetProcessor(void) const      { return m_processor; }
     virtual uint64_t              GetLastActive(void) const     { return m_iLastActive; }
     virtual cec_device_type       GetType(void) const           { return m_type; }
index 3a9bd6f1a3370bcc367bb611183cc2d6f9f691b2..1ede44210f97c8e6a56c1f22631a5c15e3952f33 100644 (file)
@@ -164,7 +164,7 @@ namespace CEC
 
     virtual bool ActiveSourcePending(void);
     virtual bool SupportsDeviceType(const cec_device_type UNUSED(type)) const { return true; };
-    cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type; }
+    virtual cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type; }
 
   protected:
     virtual bool HandleActiveSource(const cec_command &command);
index 3d96004a7f401bdbf5874ac1a0cf69484b74b857..455a062d56811f503b49df407cfead656691e0c5 100644 (file)
@@ -111,6 +111,7 @@ bool CVLCommandHandler::TransmitActiveSource(const cec_logical_address iInitiato
   {
     CVLCommandHandler *handler = static_cast<CVLCommandHandler *>(tv->GetHandler());
     bPowerUpEventReceived = handler ? handler->PowerUpEventReceived() : false;
+    tv->MarkHandlerReady();
   }
 
   if (!bPowerUpEventReceived)