From: Lars Op den Kamp Date: Wed, 2 Nov 2011 23:13:09 +0000 (+0100) Subject: cec: drop shared_ptr and use a normal pointer. removed boost dependency X-Git-Tag: upstream/2.2.0~1^2~135 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=28352a04776bccbcdf79945528808af27d2a5c0a;p=deb_libcec.git cec: drop shared_ptr and use a normal pointer. removed boost dependency --- diff --git a/configure.ac b/configure.ac index 3285c89..b350c82 100644 --- a/configure.ac +++ b/configure.ac @@ -23,13 +23,6 @@ libs_pre_dl=$LIBS AC_SUBST([LIBS_DL]) LIBS=$libs_pre_dl -AC_LANG_PUSH([C++]) -AC_CHECK_HEADERS([boost/shared_ptr.hpp], [], - [AC_MSG_ERROR(You need the Boost libraries.)]) -AC_CHECK_HEADERS([boost/enable_shared_from_this.hpp], [], - [AC_MSG_ERROR(You need the Boost libraries.)]) -AC_LANG_POP([C++]) - CXXFLAGS="-fPIC -Wall -Wextra $CXXFLAGS" AC_SUBST(REQUIRES) diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 2286a01..00fa87e 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -353,7 +353,7 @@ void CAdapterCommunication::AddData(uint8_t *data, uint8_t iLen) void CAdapterCommunication::WriteNextCommand(void) { - CCECAdapterMessagePtr msg; + CCECAdapterMessage *msg; if (m_outBuffer.Pop(msg)) { CLockObject lock(&msg->mutex); @@ -374,7 +374,7 @@ void CAdapterCommunication::WriteNextCommand(void) } } -bool CAdapterCommunication::Write(CCECAdapterMessagePtr data) +bool CAdapterCommunication::Write(CCECAdapterMessage *data) { data->state = ADAPTER_MESSAGE_STATE_WAITING; m_outBuffer.Push(data); @@ -442,47 +442,45 @@ std::string CAdapterCommunication::GetError(void) const bool CAdapterCommunication::StartBootloader(void) { + bool bReturn(false); if (!IsRunning()) - return false; + return bReturn; m_controller->AddLog(CEC_LOG_DEBUG, "starting the bootloader"); - CCECAdapterMessagePtr output(new CCECAdapterMessage); + CCECAdapterMessage *output = new CCECAdapterMessage; output->push_back(MSGSTART); output->push_escaped(MSGCODE_START_BOOTLOADER); output->push_back(MSGEND); - if (!Write(output)) - { + if ((bReturn = Write(output)) == false) m_controller->AddLog(CEC_LOG_ERROR, "could not start the bootloader"); - return false; - } - m_controller->AddLog(CEC_LOG_DEBUG, "bootloader start command transmitted"); - return true; + + delete output; + + return bReturn; } bool CAdapterCommunication::PingAdapter(void) { + bool bReturn(false); if (!IsRunning()) - return false; + return bReturn; m_controller->AddLog(CEC_LOG_DEBUG, "sending ping"); - CCECAdapterMessagePtr output(new CCECAdapterMessage); + CCECAdapterMessage *output = new CCECAdapterMessage; output->push_back(MSGSTART); output->push_escaped(MSGCODE_PING); output->push_back(MSGEND); - if (!Write(output)) - { + if ((bReturn = Write(output)) == false) m_controller->AddLog(CEC_LOG_ERROR, "could not send ping command"); - return false; - } - - m_controller->AddLog(CEC_LOG_DEBUG, "ping tranmitted"); // TODO check for pong - return true; + delete output; + + return bReturn; } bool CAdapterCommunication::IsOpen(void) const diff --git a/src/lib/AdapterCommunication.h b/src/lib/AdapterCommunication.h index ef5e0aa..31de379 100644 --- a/src/lib/AdapterCommunication.h +++ b/src/lib/AdapterCommunication.h @@ -36,8 +36,6 @@ #include "util/buffer.h" #include "util/StdString.h" #include -#include -#include namespace CEC { @@ -51,7 +49,7 @@ namespace CEC } cec_adapter_message_state; - class CCECAdapterMessage : public boost::enable_shared_from_this + class CCECAdapterMessage { public: CCECAdapterMessage(void) { clear(); } @@ -81,7 +79,6 @@ namespace CEC CMutex mutex; CCondition condition; }; - typedef boost::shared_ptr CCECAdapterMessagePtr; class CSerialPort; class CLibCEC; @@ -94,7 +91,7 @@ namespace CEC bool Open(const char *strPort, uint16_t iBaudRate = 38400, uint32_t iTimeoutMs = 10000); bool Read(CCECAdapterMessage &msg, uint32_t iTimeout = 1000); - bool Write(CCECAdapterMessagePtr data); + bool Write(CCECAdapterMessage *data); bool PingAdapter(void); void Close(void); bool IsOpen(void) const; @@ -112,7 +109,7 @@ namespace CEC CSerialPort * m_port; CLibCEC * m_controller; CecBuffer m_inBuffer; - CecBuffer m_outBuffer; + CecBuffer m_outBuffer; CMutex m_mutex; CCondition m_rcvCondition; CCondition m_startCondition; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 0749e53..563f2aa 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -231,13 +231,17 @@ cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddres bool CCECProcessor::Transmit(const cec_command &data) { + bool bReturn(false); LogOutput(data); - CCECAdapterMessagePtr output(new CCECAdapterMessage(data)); - return Transmit(output); + CCECAdapterMessage *output = new CCECAdapterMessage(data); + bReturn = Transmit(output); + delete output; + + return bReturn; } -bool CCECProcessor::Transmit(CCECAdapterMessagePtr output) +bool CCECProcessor::Transmit(CCECAdapterMessage *output) { bool bReturn(false); CLockObject lock(&m_mutex); @@ -402,11 +406,12 @@ void CCECProcessor::AddLog(cec_log_level level, const CStdString &strMessage) bool CCECProcessor::SetAckMask(uint16_t iMask) { + bool bReturn(false); CStdString strLog; strLog.Format("setting ackmask to %2x", iMask); m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str()); - CCECAdapterMessagePtr output(new CCECAdapterMessage); + CCECAdapterMessage *output = new CCECAdapterMessage; output->push_back(MSGSTART); output->push_escaped(MSGCODE_SET_ACK_MASK); @@ -414,11 +419,10 @@ bool CCECProcessor::SetAckMask(uint16_t iMask) output->push_escaped((uint8_t)iMask); output->push_back(MSGEND); - if (!Transmit(output)) - { + if ((bReturn = Transmit(output)) == false) m_controller->AddLog(CEC_LOG_ERROR, "could not set the ackmask"); - return false; - } - return true; + delete output; + + return bReturn; } diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index e2793a3..895445f 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -70,7 +70,7 @@ namespace CEC virtual bool SwitchMonitoring(bool bEnable); virtual bool Transmit(const cec_command &data); - virtual bool Transmit(CCECAdapterMessagePtr output); + virtual bool Transmit(CCECAdapterMessage *output); virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); virtual void SetCurrentButton(cec_user_control_code iButtonCode); diff --git a/src/lib/platform/linux/serialport.cpp b/src/lib/platform/linux/serialport.cpp index e362396..56bdc30 100644 --- a/src/lib/platform/linux/serialport.cpp +++ b/src/lib/platform/linux/serialport.cpp @@ -46,7 +46,7 @@ CSerialPort::~CSerialPort() Close(); } -int8_t CSerialPort::Write(CCECAdapterMessagePtr data) +int8_t CSerialPort::Write(CCECAdapterMessage *data) { fd_set port; diff --git a/src/lib/platform/serialport.h b/src/lib/platform/serialport.h index 4fb2954..a88ebec 100644 --- a/src/lib/platform/serialport.h +++ b/src/lib/platform/serialport.h @@ -47,7 +47,7 @@ namespace CEC bool IsOpen(); void Close(); - int8_t Write(CCECAdapterMessagePtr data); + int8_t Write(CCECAdapterMessage *data); int32_t Read(uint8_t* data, uint32_t len, uint64_t iTimeoutMs = 0); std::string GetError() { return m_error; } diff --git a/src/lib/platform/windows/serialport.cpp b/src/lib/platform/windows/serialport.cpp index b028ff3..df619ef 100644 --- a/src/lib/platform/windows/serialport.cpp +++ b/src/lib/platform/windows/serialport.cpp @@ -166,7 +166,7 @@ void CSerialPort::Close(void) } } -int8_t CSerialPort::Write(CCECAdapterMessagePtr data) +int8_t CSerialPort::Write(CCECAdapterMessage *data) { CLockObject lock(&m_mutex); DWORD iBytesWritten = 0;