repositories
/
deb_libcec.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b001544
)
cec: hold a lock when changing the ackmask in CUSBCECAdapterCommunication::Open
author
Lars Op den Kamp
<lars@opdenkamp.eu>
Thu, 31 May 2012 22:30:07 +0000
(
00:30
+0200)
committer
Lars Op den Kamp
<lars@opdenkamp.eu>
Thu, 31 May 2012 22:30:07 +0000
(
00:30
+0200)
src/lib/CECProcessor.cpp
patch
|
blob
|
blame
|
history
src/lib/adapter/USBCECAdapterCommunication.cpp
patch
|
blob
|
blame
|
history
src/lib/adapter/USBCECAdapterCommunication.h
patch
|
blob
|
blame
|
history
diff --git
a/src/lib/CECProcessor.cpp
b/src/lib/CECProcessor.cpp
index fe40990553d2a4ea2dc278e70cda437262f2c666..0012a53d289f52591cb398f4c1bf1d152a68a120 100644
(file)
--- a/
src/lib/CECProcessor.cpp
+++ b/
src/lib/CECProcessor.cpp
@@
-148,9
+148,6
@@
bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
m_libcec->AddLog(CEC_LOG_NOTICE, "connection opened");
m_libcec->AddLog(CEC_LOG_NOTICE, "connection opened");
- // always start by setting the ackmask to 0, to clear previous values
- SetAckMask(0);
-
// mark as initialised
SetCECInitialised(true);
// mark as initialised
SetCECInitialised(true);
diff --git
a/src/lib/adapter/USBCECAdapterCommunication.cpp
b/src/lib/adapter/USBCECAdapterCommunication.cpp
index 33eb26080081f467f572450db4f0860a511fc0ae..d6d9b5c0fab383d2023f5a62ddee1a129fda80d6 100644
(file)
--- a/
src/lib/adapter/USBCECAdapterCommunication.cpp
+++ b/
src/lib/adapter/USBCECAdapterCommunication.cpp
@@
-66,6
+66,7
@@
CUSBCECAdapterCommunication::CUSBCECAdapterCommunication(IAdapterCommunicationCa
for (unsigned int iPtr = CECDEVICE_TV; iPtr < CECDEVICE_BROADCAST; iPtr++)
m_bWaitingForAck[iPtr] = false;
m_port = new CSerialPort(strPort, iBaudRate);
for (unsigned int iPtr = CECDEVICE_TV; iPtr < CECDEVICE_BROADCAST; iPtr++)
m_bWaitingForAck[iPtr] = false;
m_port = new CSerialPort(strPort, iBaudRate);
+ m_commands = new CUSBCECAdapterCommands(this);
}
CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
}
CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
@@
-76,6
+77,13
@@
CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
DELETE_AND_NULL(m_port);
}
DELETE_AND_NULL(m_port);
}
+void CUSBCECAdapterCommunication::ResetMessageQueue(void)
+{
+ DELETE_AND_NULL(m_adapterMessageQueue);
+ m_adapterMessageQueue = new CCECAdapterMessageQueue(this);
+ m_adapterMessageQueue->CreateThread();
+}
+
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool bSkipChecks /* = false */, bool bStartListening /* = true */)
{
bool bConnectionOpened(false);
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool bSkipChecks /* = false */, bool bStartListening /* = true */)
{
bool bConnectionOpened(false);
@@
-96,15
+104,7
@@
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONN
return true;
}
return true;
}
- /* adapter commands */
- if (!m_commands)
- m_commands = new CUSBCECAdapterCommands(this);
-
- if (!m_adapterMessageQueue)
- {
- m_adapterMessageQueue = new CCECAdapterMessageQueue(this);
- m_adapterMessageQueue->CreateThread();
- }
+ ResetMessageQueue();
/* try to open the connection */
CStdString strError;
/* try to open the connection */
CStdString strError;
@@
-145,6
+145,9
@@
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONN
ClearInputBytes();
}
ClearInputBytes();
}
+ // always start by setting the ackmask to 0, to clear previous values
+ SetAckMask(0);
+
if (!CreateThread())
{
bConnectionOpened = false;
if (!CreateThread())
{
bConnectionOpened = false;
@@
-493,11
+496,15
@@
bool CUSBCECAdapterCommunication::StartBootloader(void)
bool CUSBCECAdapterCommunication::SetAckMask(uint16_t iMask)
{
bool CUSBCECAdapterCommunication::SetAckMask(uint16_t iMask)
{
- if (m_iAckMask == iMask)
- return true;
+ {
+ CLockObject lock(m_mutex);
+ if (m_iAckMask == iMask)
+ return true;
+ }
if (IsOpen() && m_commands->SetAckMask(iMask))
{
if (IsOpen() && m_commands->SetAckMask(iMask))
{
+ CLockObject lock(m_mutex);
m_iAckMask = iMask;
return true;
}
m_iAckMask = iMask;
return true;
}
@@
-508,6
+515,7
@@
bool CUSBCECAdapterCommunication::SetAckMask(uint16_t iMask)
uint16_t CUSBCECAdapterCommunication::GetAckMask(void)
{
uint16_t CUSBCECAdapterCommunication::GetAckMask(void)
{
+ CLockObject lock(m_mutex);
return m_iAckMask;
}
return m_iAckMask;
}
diff --git
a/src/lib/adapter/USBCECAdapterCommunication.h
b/src/lib/adapter/USBCECAdapterCommunication.h
index 7409e86d874b002b356a16a39cdea1b3931f2e70..0177f0850c7273fdf0e1b102e5324f48243c4d5b 100644
(file)
--- a/
src/lib/adapter/USBCECAdapterCommunication.h
+++ b/
src/lib/adapter/USBCECAdapterCommunication.h
@@
-157,6
+157,11
@@
namespace CEC
*/
void MarkAsWaiting(const cec_logical_address dest);
*/
void MarkAsWaiting(const cec_logical_address dest);
+ /*!
+ * @brief Clear and reset the message queue.
+ */
+ void ResetMessageQueue(void);
+
PLATFORM::ISocket * m_port; /**< the com port connection */
PLATFORM::CMutex m_mutex; /**< mutex for changes in this class */
uint8_t m_iLineTimeout; /**< the current line timeout on the CEC line */
PLATFORM::ISocket * m_port; /**< the com port connection */
PLATFORM::CMutex m_mutex; /**< mutex for changes in this class */
uint8_t m_iLineTimeout; /**< the current line timeout on the CEC line */