cec: fixed possible crash when command handler were switched while it was being used
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 48b75d7dda6ad936424c1801817a73c94e453f6f..2aa29c1d31c2f09818a4833ab100280f2c71ece5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
@@ -37,6 +37,7 @@
 #include "../implementations/SLCommandHandler.h"
 #include "../implementations/VLCommandHandler.h"
 #include "../LibCEC.h"
+#include "../platform/util/timeutils.h"
 
 using namespace CEC;
 using namespace PLATFORM;
@@ -833,4 +834,19 @@ bool CCECBusDevice::ActivateSource(void)
   return m_handler->ActivateSource();
 }
 
+void CCECBusDevice::HandlePoll(cec_logical_address iDestination)
+{
+  CLockObject lock(m_mutex);
+  CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", ToString(m_iLogicalAddress), m_iLogicalAddress, ToString(iDestination), iDestination);
+  m_bAwaitingReceiveFailed = true;
+}
+
+bool CCECBusDevice::HandleReceiveFailed(void)
+{
+  CLockObject lock(m_handlerMutex);
+  bool bReturn = m_bAwaitingReceiveFailed;
+  m_bAwaitingReceiveFailed = false;
+  return bReturn;
+}
+
 //@}