repositories
/
deb_libcec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
timeout parameter removed from Close()/cec_close(). return type changed to void....
[deb_libcec.git]
/
src
/
lib
/
CECParser.cpp
diff --git
a/src/lib/CECParser.cpp
b/src/lib/CECParser.cpp
index 5ac1d8ea76c0278a24fdccee6d380728aa5790fc..7a6d871700a7d701ec0eccf572a9c62d3e883afa 100644
(file)
--- a/
src/lib/CECParser.cpp
+++ b/
src/lib/CECParser.cpp
@@
-48,6
+48,7
@@
using namespace CEC;
using namespace std;
#define CEC_MAX_RETRY 5
using namespace std;
#define CEC_MAX_RETRY 5
+#define CEC_BUTTON_TIMEOUT 500
/*!
* ICECDevice implementation
/*!
* ICECDevice implementation
@@
-65,7
+66,7
@@
CCECParser::CCECParser(const char *strDeviceName, cec_logical_address iLogicalAd
CCECParser::~CCECParser(void)
{
CCECParser::~CCECParser(void)
{
- Close(
0
);
+ Close();
m_communication->Close();
delete m_communication;
}
m_communication->Close();
delete m_communication;
}
@@
-109,22
+110,10
@@
bool CCECParser::Open(const char *strPort, int iTimeoutMs /* = 10000 */)
return false;
}
return false;
}
-
bool CCECParser::Close(int iTimeoutMs /* = 2000 */
)
+
void CCECParser::Close(void
)
{
m_bRunning = false;
{
m_bRunning = false;
- bool bExit(false);
- if (iTimeoutMs > 0)
- {
- bExit = m_exitCondition.Wait(&m_mutex, iTimeoutMs);
- m_mutex.Unlock();
- }
- else
- {
- pthread_join(m_thread, NULL);
- bExit = true;
- }
-
- return bExit;
+ pthread_join(m_thread, NULL);
}
void *CCECParser::ThreadHandler(CCECParser *parser)
}
void *CCECParser::ThreadHandler(CCECParser *parser)
@@
-140,7
+129,7
@@
bool CCECParser::Process(void)
while (m_bRunning)
{
cec_frame msg;
while (m_bRunning)
{
cec_frame msg;
- while (m_bRunning && m_communication->IsOpen() && m_communication->Read(msg,
500
))
+ while (m_bRunning && m_communication->IsOpen() && m_communication->Read(msg,
CEC_BUTTON_TIMEOUT
))
ParseMessage(msg);
now = GetTimeMs();
ParseMessage(msg);
now = GetTimeMs();
@@
-165,7
+154,7
@@
bool CCECParser::Ping(void)
PushEscaped(output, MSGCODE_PING);
output.push_back(MSGEND);
PushEscaped(output, MSGCODE_PING);
output.push_back(MSGEND);
- if (!TransmitFormatted(output, false
, (int64_t) 5000
))
+ if (!TransmitFormatted(output, false))
{
AddLog(CEC_LOG_ERROR, "could not send ping command");
return false;
{
AddLog(CEC_LOG_ERROR, "could not send ping command");
return false;
@@
-188,7
+177,7
@@
bool CCECParser::StartBootloader(void)
PushEscaped(output, MSGCODE_START_BOOTLOADER);
output.push_back(MSGEND);
PushEscaped(output, MSGCODE_START_BOOTLOADER);
output.push_back(MSGEND);
- if (!TransmitFormatted(output, false
, (int64_t) 5000
))
+ if (!TransmitFormatted(output, false))
{
AddLog(CEC_LOG_ERROR, "could not start the bootloader");
return false;
{
AddLog(CEC_LOG_ERROR, "could not start the bootloader");
return false;
@@
-376,9
+365,9
@@
void CCECParser::BroadcastActiveSource(void)
Transmit(frame);
}
Transmit(frame);
}
-bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = true */
, int64_t iTimeout /* = 2000 */
)
+bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = true */)
{
{
- if (!m_communication ||
m_communication->Write(data) != data.size(
))
+ if (!m_communication ||
!m_communication->Write(data
))
return false;
CCondition::Sleep((int) data.size() * 24 /*data*/ + 5 /*start bit (4.5 ms)*/ + 50 /* to be on the safe side */);
return false;
CCondition::Sleep((int) data.size() * 24 /*data*/ + 5 /*start bit (4.5 ms)*/ + 50 /* to be on the safe side */);
@@
-391,7
+380,7
@@
bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* =
return true;
}
return true;
}
-bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */
, int64_t iTimeout /* = 5000 */
)
+bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */)
{
CStdString txStr = "transmit ";
for (unsigned int i = 0; i < data.size(); i++)
{
CStdString txStr = "transmit ";
for (unsigned int i = 0; i < data.size(); i++)
@@
-432,16
+421,16
@@
bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */,
output.push_back(MSGEND);
}
output.push_back(MSGEND);
}
- return TransmitFormatted(output, bWaitForAck
, iTimeout
);
+ return TransmitFormatted(output, bWaitForAck);
}
}
-bool CCECParser::WaitForAck(int
64_t
iTimeout /* = 1000 */)
+bool CCECParser::WaitForAck(int iTimeout /* = 1000 */)
{
bool bGotAck(false);
bool bError(false);
int64_t iNow = GetTimeMs();
{
bool bGotAck(false);
bool bError(false);
int64_t iNow = GetTimeMs();
- int64_t iTargetTime = iNow + iTimeout;
+ int64_t iTargetTime = iNow +
(int64_t)
iTimeout;
while (!bGotAck && !bError && (iTimeout <= 0 || iNow < iTargetTime))
{
while (!bGotAck && !bError && (iTimeout <= 0 || iNow < iTargetTime))
{
@@
-677,7
+666,7
@@
void CCECParser::PushEscaped(cec_frame &vec, uint8_t byte)
void CCECParser::CheckKeypressTimeout(int64_t now)
{
void CCECParser::CheckKeypressTimeout(int64_t now)
{
- if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && now - m_buttontime >
500
)
+ if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && now - m_buttontime >
CEC_BUTTON_TIMEOUT
)
{
AddKey();
m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN;
{
AddKey();
m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN;
@@
-708,7
+697,7
@@
bool CCECParser::SetAckMask(uint16_t iMask)
PushEscaped(output, (uint8_t)iMask);
output.push_back(MSGEND);
PushEscaped(output, (uint8_t)iMask);
output.push_back(MSGEND);
- if (
m_communication->Write(output) == -1
)
+ if (
!m_communication->Write(output)
)
{
AddLog(CEC_LOG_ERROR, "could not set the ackmask");
return false;
{
AddLog(CEC_LOG_ERROR, "could not set the ackmask");
return false;