From: Lars Op den Kamp Date: Thu, 29 Sep 2011 20:31:13 +0000 (+0200) Subject: cec: fix the command buffer X-Git-Tag: upstream/2.2.0~1^2~315 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c49c485b94c3670438d329c15f4a785609a126f6;hp=fac23b028a858e6c8e4773b8a1670b4f96c96ce7;p=deb_libcec.git cec: fix the command buffer --- diff --git a/src/lib/CECParser.cpp b/src/lib/CECParser.cpp index 97fbcd3..547d626 100644 --- a/src/lib/CECParser.cpp +++ b/src/lib/CECParser.cpp @@ -761,6 +761,12 @@ void CCECParser::ParseCurrentFrame(void) BroadcastActiveSource(); } } + else + { + cec_frame params = m_currentframe; + params.erase(params.begin(), params.begin() + 2); + AddCommand((cec_logical_address) initiator, (cec_logical_address) destination, opCode, ¶ms); + } } else { @@ -867,7 +873,16 @@ void CCECParser::AddCommand(cec_logical_address source, cec_logical_address dest command.opcode = opcode; if (parameters) command.parameters = *parameters; - m_commandBuffer.Push(command); + if (m_commandBuffer.Push(command)) + { + CStdString strDebug; + strDebug.Format("stored command '%d' in the command buffer. buffer size = %d", opcode, m_commandBuffer.Size()); + AddLog(CEC_LOG_DEBUG, strDebug); + } + else + { + AddLog(CEC_LOG_WARNING, "command buffer is full"); + } } int CCECParser::GetMinVersion(void) diff --git a/src/lib/util/buffer.h b/src/lib/util/buffer.h index dc7af83..cafa655 100644 --- a/src/lib/util/buffer.h +++ b/src/lib/util/buffer.h @@ -44,6 +44,8 @@ template } virtual ~CecBuffer(void) {} + int Size(void) const { return m_buffer.size(); } + bool Push(_BType entry) { CLockObject lock(&m_mutex);