CCECBusDevice *primary = bIsRunning ? GetPrimaryDevice() : NULL;
cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE;
- m_configuration.serverVersion = LIBCEC_VERSION_CURRENT;
- m_configuration.clientVersion = configuration->clientVersion;
+ m_configuration.clientVersion = configuration->clientVersion;
LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - using client version '%s'", __FUNCTION__, ToString((cec_client_version)configuration->clientVersion));
// client version 1.5.0
delete m_communication;
m_communication = NULL;
}
+
+ m_bMonitor = false;
+ m_iPreviousAckMask = 0;
+ m_iStandardLineTimeout = 3;
+ m_iRetryLineTimeout = 3;
+ m_iLastTransmission = 0;
+ m_busDevices->ResetDeviceStatus();
}
bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs, bool bStartListening /* = true */)
client->Initialise();
// set the firmware version and build date
- configuration.iFirmwareVersion = m_communication->GetFirmwareVersion();
+ configuration.serverVersion = LIBCEC_VERSION_CURRENT;
+ configuration.iFirmwareVersion = m_communication->GetFirmwareVersion();
configuration.iFirmwareBuildDate = m_communication->GetFirmwareBuildDate();
CStdString strLog;
void CCECProcessor::UnregisterClient(CCECClient *client)
{
CLockObject lock(m_mutex);
- libcec_configuration &configuration = *client->GetConfiguration();
CECDEVICEVEC devices;
- m_busDevices->GetByLogicalAddresses(devices, configuration.logicalAddresses);
+ m_busDevices->GetByLogicalAddresses(devices, client->GetConfiguration()->logicalAddresses);
for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++)
{
map<cec_logical_address, CCECClient *>::iterator entry = m_clients.find((*it)->GetLogicalAddress());
bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
{
+ if (!m_cec)
+ return false;
+
if (m_cec->IsRunning())
{
AddLog(CEC_LOG_ERROR, "connection already open");
void CLibCEC::Close(void)
{
- m_clients.clear();
-
- if (m_client)
- {
- delete m_client;
- m_client = NULL;
- }
if (m_cec)
+ m_cec->Close();
+
+ for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
{
- delete m_cec;
- m_cec = NULL;
+ (*it)->SetRegistered(false);
+ (*it)->SetInitialised(false);
}
}
if (m_cec->IsRunning())
m_cec->RegisterClient(newClient);
- return m_client;
+ return newClient;
}
void CLibCEC::UnregisterClients(void)
return NULL;
CLibCEC *lib = new CLibCEC;
+ CCECClient *client(NULL);
if (lib)
- lib->RegisterClient(configuration);
+ client = lib->RegisterClient(configuration);
+
+ if (client)
+ client->GetCurrentConfiguration(configuration);
+
+ // ensure that the correct server version is set
+ configuration->serverVersion = LIBCEC_VERSION_CURRENT;
return static_cast< void* > (lib);
}
void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types, uint16_t iPhysicalAddress /* = 0 */)
{
libcec_configuration configuration;
- configuration.serverVersion = LIBCEC_VERSION_CURRENT;
// client version < 1.5.0
snprintf(configuration.strDeviceName, 13, "%s", strDeviceName);
m_iStreamPath = iNewAddress;
}
+ if (!LIB_CEC->IsValidPhysicalAddress(iNewAddress))
+ return;
+
CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
if (device)
{
CThread(void) :
m_bStop(false),
m_bRunning(false),
- m_bStopped(false) {}
+ m_bStopped(false),
+ m_thread(NULL) {}
virtual ~CThread(void)
{
StopThread(0);
void *retVal;
- ThreadsWait(m_thread, &retVal);
+ if (m_thread)
+ ThreadsWait(m_thread, &retVal);
#if defined(__WINDOWS__)
(void *)retVal; //"unreferenced local variable" warning
#endif