* @param iPhysicalAddress The physical address of this device. 0x1000 by default.
* @return True when initialised, false otherwise.
*/
-
#ifdef __cplusplus
extern DECLSPEC bool cec_init(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1, int iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
#else
extern DECLSPEC bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1, int iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
#endif
+/*!
+ * @brief Unload the CEC adapter library.
+ */
+extern DECLSPEC void cec_destroy(void);
+
/*!
* @brief Open a connection to the CEC adapter.
* @param strPort The path to the port.
/*!
* @brief Close the connection to the CEC adapter.
- * @param iTimeout Timeout in ms
*/
-extern DECLSPEC bool cec_close(int iTimeout);
+extern DECLSPEC void cec_close(void);
/*!
* @brief Ping the CEC adapter.
/*!
* @see cec_close
*/
- virtual bool Close(int iTimeoutMs = 2000) = 0;
+ virtual void Close(void) = 0;
/*!
* @see cec_find_devices
CCECParser::~CCECParser(void)
{
- Close(0);
+ Close();
m_communication->Close();
delete m_communication;
}
return false;
}
-bool CCECParser::Close(int iTimeoutMs /* = 2000 */)
+void CCECParser::Close(void)
{
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)
virtual ~CCECParser(void);
virtual bool Open(const char *strPort, int iTimeout = 10000);
- virtual bool Close(int iTimeoutMs = 2000);
+ virtual void Close(void);
virtual int FindDevices(std::vector<cec_device> &deviceList, const char *strDevicePath = NULL);
virtual bool Ping(void);
virtual bool StartBootloader(void);
return (cec_parser != NULL);
}
+void cec_destroy(void)
+{
+ cec_close();
+ delete cec_parser;
+ cec_parser = NULL;
+}
+
bool cec_open(const char *strPort, int iTimeout)
{
if (cec_parser)
return false;
}
-bool cec_close(int iTimeout)
+void cec_close(void)
{
- bool bReturn = false;
if (cec_parser)
- bReturn = cec_parser->Close(iTimeout);
-
- delete cec_parser;
- cec_parser = NULL;
- return bReturn;
+ cec_parser->Close();
}
bool cec_ping(void)
CCondition::Sleep(50);
}
- parser->PowerOffDevices(CECDEVICE_TV);
+ parser->PowerOffDevices(CECDEVICE_BROADCAST);
+ parser->Close();
flush_log(parser);
UnloadLibCec(parser);
return 0;