From: Lars Op den Kamp Date: Thu, 9 Feb 2012 21:42:31 +0000 (+0100) Subject: cec: added a new initialiser method: CecInitialise()/cec_initialise(), that accepts... X-Git-Tag: upstream/2.2.0~1^2~35^2~125 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=caca2d81263ae8fd7400298329a4a2e95bdb99e1;p=deb_libcec.git cec: added a new initialiser method: CecInitialise()/cec_initialise(), that accepts a "libc_configuration" struct as parameter. this way, the signature of the init method can stay the same when adding new options. --- diff --git a/include/cec.h b/include/cec.h index 9f15206..c3fbe10 100644 --- a/include/cec.h +++ b/include/cec.h @@ -379,6 +379,7 @@ namespace CEC virtual const char *ToString(const cec_system_audio_status mode) = 0; virtual const char *ToString(const cec_audio_status status) = 0; virtual const char *ToString(const cec_vendor_id vendor) = 0; + virtual const char *ToString(const cec_client_version version) = 0; }; }; @@ -389,7 +390,14 @@ namespace CEC * @param iPhysicalAddress The physical address to assume on the bus. If set to 0, libCEC will try to autodetect the address, with the data provided via SetHDMIPort() * @return An instance of ICECAdapter or NULL on error. */ -extern "C" DECLSPEC void * CECInit(const char *strDeviceName, CEC::cec_device_type_list devicesTypes, uint16_t iPhysicalAddress = 0); +extern "C" DECLSPEC void * CECInit(const char *strDeviceName, CEC::cec_device_type_list deviceTypes, uint16_t iPhysicalAddress = 0); + +/*! + * @brief Load the CEC adapter library. + * @param configuration The configuration to pass to libCEC + * @return An instance of ICECAdapter or NULL on error. + */ +extern "C" DECLSPEC void * CECInitialise(const CEC::libcec_configuration *configuration); /*! * @brief Unload the CEC adapter library. diff --git a/include/cecc.h b/include/cecc.h index a720e7f..050271b 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -41,9 +41,15 @@ extern "C" { #endif #ifdef __cplusplus -extern DECLSPEC int cec_init_typed(const char *strDeviceName, CEC::cec_device_type_list devicesTypes); +extern DECLSPEC int cec_initialise(CEC::libcec_configuration *configuration); #else -extern DECLSPEC int cec_init_typed(const char *strDeviceName, cec_device_type_list devicesTypes); +extern DECLSPEC int cec_initialise(libcec_configuration *configuration); +#endif + +#ifdef __cplusplus +extern DECLSPEC int cec_init_typed(const char *strDeviceName, CEC::cec_device_type_list deviceTypes); +#else +extern DECLSPEC int cec_init_typed(const char *strDeviceName, cec_device_type_list deviceTypes); #endif extern DECLSPEC void cec_destroy(void); diff --git a/include/cecloader.h b/include/cecloader.h index 33a2e3f..bfb3929 100644 --- a/include/cecloader.h +++ b/include/cecloader.h @@ -66,6 +66,35 @@ CEC::ICECAdapter *LibCecInit(const char *strDeviceName, CEC::cec_device_type_lis return static_cast< CEC::ICECAdapter* > (LibCecInit(strDeviceName, types)); } +/*! + * @brief Create a new libCEC instance. + * @param configuration The configuration to pass to libCEC + * @param strLib The name of and/or path to libCEC + * @return An instance of ICECAdapter or NULL on error. + */ +CEC::ICECAdapter *LibCecInitialise(const CEC::libcec_configuration *configuration, const char *strLib = NULL) +{ + if (!g_libCEC) +#if defined(_WIN64) + g_libCEC = LoadLibrary(strLib ? strLib : "libcec.x64.dll"); +#else + g_libCEC = LoadLibrary(strLib ? strLib : "libcec.dll"); +#endif + if (!g_libCEC) + return NULL; + + typedef void* (__cdecl*_LibCecInitialise)(const CEC::libcec_configuration *); + _LibCecInitialise LibCecInitialise; + LibCecInitialise = (_LibCecInitialise) (GetProcAddress(g_libCEC, "CECInitialise")); + if (!LibCecInitialise) + { + cout << "cannot find CECInitialise" << endl; + return NULL; + } + + return static_cast< CEC::ICECAdapter* > (LibCecInitialise(configuration)); +} + /*! * @brief Destroy an instance of libCEC. * @param device The instance to destroy. @@ -89,9 +118,13 @@ void UnloadLibCec(CEC::ICECAdapter *device) void *g_libCEC = NULL; /*! - * @deprecated Please use LibCecInit() instead + * @brief Create a new libCEC instance. + * @param strDeviceName The name of the primary device to pass to other CEC devices. + * @param types The list of device types to register on the bus. + * @param strLib The name of and/or path to libCEC + * @return An instance of libCEC or NULL when it failed to load. */ -CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1, uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS, const char *strLib = NULL) +CEC::ICECAdapter *LibCecInit(const char *strDeviceName, CEC::cec_device_type_list types, const char *strLib = NULL) { if (!g_libCEC) { @@ -111,25 +144,23 @@ CEC::ICECAdapter *LoadLibCec(const char *strName, CEC::cec_logical_address iLogi } } - typedef void* _CreateLibCec(const char *, uint8_t, uint16_t); - _CreateLibCec* CreateLibCec = (_CreateLibCec*) dlsym(g_libCEC, "CECCreate"); - if (!CreateLibCec) + typedef void* _LibCecInit(const char *, CEC::cec_device_type_list); + _LibCecInit* LibCecInit = (_LibCecInit*) dlsym(g_libCEC, "CECInit"); + if (!LibCecInit) { - cout << "cannot find CECCreate" << endl; + cout << "cannot find CECInit" << endl; return NULL; } - return (CEC::ICECAdapter*) CreateLibCec(strName, iLogicalAddress, iPhysicalAddress); + return (CEC::ICECAdapter*) LibCecInit(strDeviceName, types); } /*! * @brief Create a new libCEC instance. - * @param strDeviceName The name of the primary device to pass to other CEC devices. - * @param types The list of device types to register on the bus. - * @param strLib The name of and/or path to libCEC - * @return An instance of libCEC or NULL when it failed to load. + * @param configuration The configuration to pass to libCEC + * @return An instance of ICECAdapter or NULL on error. */ -CEC::ICECAdapter *LibCecInit(const char *strDeviceName, CEC::cec_device_type_list types, const char *strLib = NULL) +CEC::ICECAdapter *LibCecInitialise(const CEC::CecAdapterConfiguration &configuration) { if (!g_libCEC) { @@ -149,15 +180,15 @@ CEC::ICECAdapter *LibCecInit(const char *strDeviceName, CEC::cec_device_type_lis } } - typedef void* _LibCecInit(const char *, CEC::cec_device_type_list); - _LibCecInit* LibCecInit = (_LibCecInit*) dlsym(g_libCEC, "CECInit"); - if (!LibCecInit) + typedef void* _LibCecInitialise(const CEC::CecAdapterConfiguration &); + _LibCecInitialise* LibCecInitialise = (_LibCecInitialise*) dlsym(g_libCEC, "CECInitialise"); + if (!LibCecInitialise) { - cout << "cannot find CECInit" << endl; + cout << "cannot find CECInitialise" << endl; return NULL; } - return (CEC::ICECAdapter*) LibCecInit(strDeviceName, types); + return (CEC::ICECAdapter*) LibCecInitialise(configuration); } /*! diff --git a/include/cectypes.h b/include/cectypes.h index d837620..0158392 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -904,6 +904,39 @@ typedef struct ICECCallbacks CBCecCommandType CBCecCommand; } ICECCallbacks; +typedef enum cec_client_version +{ + CEC_CLIENT_VERSION_PRE_1_5 = 0, + CEC_CLIENT_VERSION_1_5_0 = 1 +} cec_client_version; + +typedef struct libcec_configuration +{ + char strDeviceName[13]; /*!< how to name the device on the CEC bus */ + cec_device_type_list deviceTypes; /*!< the CEC device types to emulate */ + uint16_t iPhysicalAddress; /*!< the physical address of the CEC adapter */ + cec_logical_address baseDevice; /*!< the logical address of the device to which the adapter is connected. only used when iPhysicalAddress = 0 */ + uint8_t iHDMIPort; /*!< the HDMI port to which the adapter is connected. only used when iPhysicalAddress = 0 */ + cec_client_version clientVersion; /*!< the version of the client that is connecting */ + + void * callbackParam; /*!< the object to pass along with a call of the callback methods. NULL to ignore */ + ICECCallbacks * callbacks; /*!< the callback methods to use. set this to NULL when not using callbacks */ + +#ifdef __cplusplus + void Clear(void) + { + memset(strDeviceName, 0, 13); + deviceTypes.clear(); + iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS; + baseDevice = (cec_logical_address)CEC_DEFAULT_BASE_DEVICE; + iHDMIPort = CEC_DEFAULT_HDMI_PORT; + clientVersion = CEC_CLIENT_VERSION_PRE_1_5; + callbackParam = NULL; + callbacks = NULL; + } +#endif +} libcec_configuration; + #ifdef UNUSED #elif defined(__GNUC__) #define UNUSED(x) UNUSED_ ## x __attribute__((unused)) diff --git a/src/cec-config/cec-config.cpp b/src/cec-config/cec-config.cpp index 19a7a01..b026864 100644 --- a/src/cec-config/cec-config.cpp +++ b/src/cec-config/cec-config.cpp @@ -359,6 +359,8 @@ int main (int argc, char *argv[]) } PrintToStdOut("=== USB-CEC Adapter Configuration Summary ===\n"); + bool bHasAudiosystem = g_parser->IsActiveDevice(CECDEVICE_AUDIOSYSTEM); + PrintToStdOut("Physical address: %4X", iAddress); g_parser->StandbyDevices(); diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 9535a21..6eeb38d 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -47,7 +47,26 @@ using namespace CEC; using namespace std; using namespace PLATFORM; -CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress /* = 0 */) : +CCECProcessor::CCECProcessor(CLibCEC *controller, const libcec_configuration *configuration) : + m_bInitialised(false), + m_iPhysicalAddress(configuration->iPhysicalAddress), + m_iHDMIPort(configuration->iHDMIPort), + m_iBaseDevice(configuration->baseDevice), + m_strDeviceName(configuration->strDeviceName), + m_types(configuration->deviceTypes), + m_communication(NULL), + m_controller(controller), + m_bMonitor(false), + m_iStandardLineTimeout(3), + m_iRetryLineTimeout(3), + m_iLastTransmission(0), + m_clientVersion(configuration->clientVersion) +{ + m_logicalAddresses.Clear(); + CreateBusDevices(); +} + +CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress, cec_client_version clientVersion) : m_bInitialised(false), m_iPhysicalAddress(iPhysicalAddress), m_iHDMIPort(CEC_DEFAULT_HDMI_PORT), @@ -59,9 +78,15 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con m_bMonitor(false), m_iStandardLineTimeout(3), m_iRetryLineTimeout(3), - m_iLastTransmission(0) + m_iLastTransmission(0), + m_clientVersion(clientVersion) { m_logicalAddresses.Clear(); + CreateBusDevices(); +} + +void CCECProcessor::CreateBusDevices(void) +{ for (int iPtr = 0; iPtr < 16; iPtr++) { switch(iPtr) @@ -149,7 +174,7 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint } if (bReturn) - CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d", m_communication->GetFirmwareVersion()); + CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_communication->GetFirmwareVersion(), ToString(m_clientVersion)); return bReturn; } @@ -1261,6 +1286,19 @@ const char *CCECProcessor::ToString(const cec_vendor_id vendor) } } +const char *CCECProcessor::ToString(const cec_client_version version) +{ + switch (version) + { + case CEC_CLIENT_VERSION_PRE_1_5: + return "pre-1.5"; + case CEC_CLIENT_VERSION_1_5_0: + return "1.5.0"; + default: + return "Unknown"; + } +} + void *CCECBusScan::Process(void) { CCECBusDevice *device(NULL); diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 5b6bd80..b05beb8 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -46,7 +46,8 @@ namespace CEC class CCECProcessor : public PLATFORM::CThread, public IAdapterCommunicationCallback { public: - CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress = 0); + CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress, cec_client_version clientVersion); + CCECProcessor(CLibCEC *controller, const libcec_configuration *configuration); virtual ~CCECProcessor(void); virtual bool Start(const char *strPort, uint16_t iBaudRate = 38400, uint32_t iTimeoutMs = 10000); @@ -113,6 +114,7 @@ namespace CEC const char *ToString(const cec_system_audio_status mode); const char *ToString(const cec_audio_status status); const char *ToString(const cec_vendor_id vendor); + const char *ToString(const cec_client_version version); virtual bool Transmit(const cec_command &data); virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, cec_abort_reason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); @@ -133,6 +135,7 @@ namespace CEC bool OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs); bool Initialise(void); void SetInitialised(bool bSetTo = true); + void CreateBusDevices(void); void ReplaceHandlers(void); void ScanCECBus(void); @@ -164,6 +167,7 @@ namespace CEC uint8_t m_iStandardLineTimeout; uint8_t m_iRetryLineTimeout; uint64_t m_iLastTransmission; + cec_client_version m_clientVersion; }; class CCECBusScan : public PLATFORM::CThread diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index ca83d5f..9da2ba5 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -49,7 +49,17 @@ CLibCEC::CLibCEC(const char *strDeviceName, cec_device_type_list types, uint16_t m_callbacks(NULL), m_cbParam(NULL) { - m_cec = new CCECProcessor(this, strDeviceName, types, iPhysicalAddress); + m_cec = new CCECProcessor(this, strDeviceName, types, iPhysicalAddress, CEC_CLIENT_VERSION_PRE_1_5); +} + +CLibCEC::CLibCEC(const libcec_configuration *configuration) : + m_iStartTime(GetTimeMs()), + m_iCurrentButton(CEC_USER_CONTROL_CODE_UNKNOWN), + m_buttontime(0), + m_callbacks(configuration->callbacks), + m_cbParam(configuration->callbackParam) +{ + m_cec = new CCECProcessor(this, configuration); } CLibCEC::~CLibCEC(void) @@ -464,6 +474,13 @@ void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types, uint1 return static_cast< void* > (lib); } +void * CECInitialise(const libcec_configuration *configuration) +{ + CLibCEC *lib = new CLibCEC(configuration); + CLibCEC::SetInstance(lib); + return static_cast< void* > (lib); +} + void CECDestroy(CEC::ICECAdapter *UNUSED(instance)) { CLibCEC::SetInstance(NULL); @@ -518,3 +535,8 @@ const char *CLibCEC::ToString(const cec_vendor_id vendor) { return m_cec->ToString(vendor); } + +const char *CLibCEC::ToString(const cec_client_version version) +{ + return m_cec->ToString(version); +} diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index c3d044e..6dabdc2 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -48,6 +48,7 @@ namespace CEC */ //@{ CLibCEC(const char *strDeviceName, cec_device_type_list types, uint16_t iPhysicalAddress = 0); + CLibCEC(const libcec_configuration *configuration); virtual ~CLibCEC(void); virtual bool Open(const char *strPort, uint32_t iTimeout = 10000); @@ -112,6 +113,7 @@ namespace CEC const char *ToString(const cec_system_audio_status mode); const char *ToString(const cec_audio_status status); const char *ToString(const cec_vendor_id vendor); + const char *ToString(const cec_client_version version); //@} static void AddLog(cec_log_level level, const char *strFormat, ...); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index 2b5357c..b57b107 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -42,9 +42,15 @@ using namespace std; //@{ ICECAdapter *cec_parser; -int cec_init_typed(const char *strDeviceName, cec_device_type_list devicesTypes) +int cec_initialise(const libcec_configuration *configuration) { - cec_parser = (ICECAdapter *) CECInit(strDeviceName, devicesTypes); + cec_parser = (ICECAdapter *) CECInitialise(configuration); + return (cec_parser != NULL) ? 1 : 0; +} + +int cec_init_typed(const char *strDeviceName, cec_device_type_list deviceTypes) +{ + cec_parser = (ICECAdapter *) CECInit(strDeviceName, deviceTypes); return (cec_parser != NULL) ? 1 : 0; } diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index b049286..dde9980 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -45,22 +45,18 @@ using namespace CEC; using namespace std; using namespace PLATFORM; -#define CEC_TEST_CLIENT_VERSION 1 - #include +ICECCallbacks g_callbacks; +libcec_configuration g_config; int g_cecLogLevel(CEC_LOG_ALL); ofstream g_logOutput; bool g_bShortLog(false); CStdString g_strPort; -uint8_t g_iHDMIPort(CEC_DEFAULT_HDMI_PORT); -cec_logical_address g_iBaseDevice((cec_logical_address)CEC_DEFAULT_BASE_DEVICE); -cec_device_type_list g_typeList; bool g_bSingleCommand(false); bool g_bExit(false); bool g_bHardExit(false); CMutex g_outputMutex; -ICECCallbacks g_callbacks; inline void PrintToStdOut(const char *strFormat, ...) { @@ -230,24 +226,6 @@ void ShowHelpCommandLine(const char* strExec) "available commands" << endl; } -ICECAdapter *CreateParser(cec_device_type_list typeList) -{ - ICECAdapter *parser = LibCecInit("CECTester", typeList); - if (!parser || parser->GetMinLibVersion() > CEC_TEST_CLIENT_VERSION) - { - #ifdef __WINDOWS__ - PrintToStdOut("Cannot load libcec.dll"); - #else - PrintToStdOut("Cannot load libcec.so"); - #endif - return NULL; - } - - PrintToStdOut("CEC Parser created - libcec version %d.%d", parser->GetLibVersionMajor(), parser->GetLibVersionMinor()); - - return parser; -} - void ShowHelpConsole(void) { CLockObject lock(g_outputMutex); @@ -956,25 +934,25 @@ bool ProcessCommandLineArguments(int argc, char *argv[]) { if (!g_bSingleCommand) cout << "== using device type 'playback device'" << endl; - g_typeList.add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); + g_config.deviceTypes.add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); } else if (!strcmp(argv[iArgPtr + 1], "r")) { if (!g_bSingleCommand) cout << "== using device type 'recording device'" << endl; - g_typeList.add(CEC_DEVICE_TYPE_RECORDING_DEVICE); + g_config.deviceTypes.add(CEC_DEVICE_TYPE_RECORDING_DEVICE); } else if (!strcmp(argv[iArgPtr + 1], "t")) { if (!g_bSingleCommand) cout << "== using device type 'tuner'" << endl; - g_typeList.add(CEC_DEVICE_TYPE_TUNER); + g_config.deviceTypes.add(CEC_DEVICE_TYPE_TUNER); } else if (!strcmp(argv[iArgPtr + 1], "a")) { if (!g_bSingleCommand) cout << "== using device type 'audio system'" << endl; - g_typeList.add(CEC_DEVICE_TYPE_AUDIO_SYSTEM); + g_config.deviceTypes.add(CEC_DEVICE_TYPE_AUDIO_SYSTEM); } else { @@ -987,7 +965,7 @@ bool ProcessCommandLineArguments(int argc, char *argv[]) else if (!strcmp(argv[iArgPtr], "--list-devices") || !strcmp(argv[iArgPtr], "-l")) { - ICECAdapter *parser = CreateParser(g_typeList); + ICECAdapter *parser = LibCecInitialise(&g_config); if (parser) { ListDevices(parser); @@ -1013,8 +991,8 @@ bool ProcessCommandLineArguments(int argc, char *argv[]) { if (argc >= iArgPtr + 2) { - g_iBaseDevice = (cec_logical_address)atoi(argv[iArgPtr + 1]); - cout << "using base device '" << (int)g_iBaseDevice << "'" << endl; + g_config.baseDevice = (cec_logical_address)atoi(argv[iArgPtr + 1]); + cout << "using base device '" << (int)g_config.baseDevice << "'" << endl; ++iArgPtr; } ++iArgPtr; @@ -1024,8 +1002,8 @@ bool ProcessCommandLineArguments(int argc, char *argv[]) { if (argc >= iArgPtr + 2) { - g_iHDMIPort = (int8_t)atoi(argv[iArgPtr + 1]); - cout << "using HDMI port '" << (int)g_iHDMIPort << "'" << endl; + g_config.iHDMIPort = (int8_t)atoi(argv[iArgPtr + 1]); + cout << "using HDMI port '" << (int)g_config.iHDMIPort << "'" << endl; ++iArgPtr; } ++iArgPtr; @@ -1042,20 +1020,27 @@ bool ProcessCommandLineArguments(int argc, char *argv[]) int main (int argc, char *argv[]) { - g_typeList.clear(); + g_config.Clear(); + snprintf(g_config.strDeviceName, 13, "CECTester"); + g_config.callbackParam = NULL; + g_config.clientVersion = CEC_CLIENT_VERSION_1_5_0; + g_callbacks.CBCecLogMessage = &CecLogMessage; + g_callbacks.CBCecKeyPress = &CecKeyPress; + g_callbacks.CBCecCommand = &CecCommand; + g_config.callbacks = &g_callbacks; if (!ProcessCommandLineArguments(argc, argv)) return 0; - if (g_typeList.IsEmpty()) + if (g_config.deviceTypes.IsEmpty()) { if (!g_bSingleCommand) cout << "No device type given. Using 'recording device'" << endl; - g_typeList.add(CEC_DEVICE_TYPE_RECORDING_DEVICE); + g_config.deviceTypes.add(CEC_DEVICE_TYPE_RECORDING_DEVICE); } - ICECAdapter *parser = LibCecInit("CECTester", g_typeList); - if (!parser || parser->GetMinLibVersion() > CEC_TEST_CLIENT_VERSION) + ICECAdapter *parser = LibCecInitialise(&g_config); + if (!parser) { #ifdef __WINDOWS__ cout << "Cannot load libcec.dll" << endl; @@ -1108,9 +1093,6 @@ int main (int argc, char *argv[]) } } - EnableCallbacks(parser); - - parser->SetHDMIPort(g_iBaseDevice, g_iHDMIPort); PrintToStdOut("opening a connection to the CEC adapter..."); if (!parser->Open(g_strPort.c_str()))