cec: add a Close() method to the interface
[deb_libcec.git] / src / lib / CECParserC.cpp
index 1aae849a7815f47550ee9784d726b0afeb1c32ba..b21f1c0b461a3d17358983e3dfdda9afd8ec4821 100644 (file)
@@ -47,13 +47,6 @@ bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress /*
   return (cec_parser != NULL);
 }
 
-bool cec_close(void)
-{
-  delete cec_parser;
-  cec_parser = NULL;
-  return true;
-}
-
 bool cec_open(const char *strPort, int iTimeout)
 {
   if (cec_parser)
@@ -61,6 +54,17 @@ bool cec_open(const char *strPort, int iTimeout)
   return false;
 }
 
+bool cec_close(int iTimeout)
+{
+  bool bReturn = false;
+  if (cec_parser)
+    bReturn = cec_parser->Close(iTimeout);
+
+  delete cec_parser;
+  cec_parser = NULL;
+  return bReturn;
+}
+
 bool cec_ping(void)
 {
   if (cec_parser)
@@ -124,6 +128,13 @@ bool cec_get_next_keypress(cec_keypress *key)
   return false;
 }
 
+bool cec_get_next_command(cec_command *command)
+{
+  if (cec_parser)
+    return cec_parser->GetNextCommand(command);
+  return false;
+}
+
 bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 2000 */)
 {
   if (cec_parser)
@@ -131,10 +142,17 @@ bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */, int
   return false;
 }
 
-bool cec_set_ack_mask(uint16_t ackmask)
+bool cec_set_logical_address(cec_logical_address iLogicalAddress)
+{
+  if (cec_parser)
+    return cec_parser->SetLogicalAddress(iLogicalAddress);
+  return false;
+}
+
+bool cec_set_ack_mask(uint16_t iMask)
 {
   if (cec_parser)
-    return cec_parser->SetAckMask((cec_logical_address) ackmask);
+    return cec_parser->SetAckMask(iMask);
   return false;
 }