#include "LibCEC.h"
#include "CECClient.h"
#include "platform/util/timeutils.h"
+#include "platform/util/util.h"
using namespace CEC;
using namespace std;
CCECProcessor::~CCECProcessor(void)
{
Close();
- delete m_busDevices;
+ DELETE_AND_NULL(m_busDevices);
}
bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = CEC_SERIAL_DEFAULT_BAUDRATE */, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
StopThread();
// close the connection
- if (m_communication)
- {
- delete m_communication;
- m_communication = NULL;
- }
+ DELETE_AND_NULL(m_communication);
}
void CCECProcessor::ResetMembers(void)
{
// close the connection
- if (m_communication)
- {
- delete m_communication;
- m_communication = NULL;
- }
+ DELETE_AND_NULL(m_communication);
// reset the other members to the initial state
m_iStandardLineTimeout = 3;
if (comm->IsOpen())
{
bReturn = comm->StartBootloader();
- delete comm;
+ DELETE_AND_NULL(comm);
}
return bReturn;
}
#include "devices/CECTV.h"
#include "platform/util/timeutils.h"
#include "platform/util/StdString.h"
+#include "platform/util/util.h"
#include "CECClient.h"
using namespace CEC;
using namespace PLATFORM;
+//TODO replace deprecated constructor in 2.0
CLibCEC::CLibCEC(const char *UNUSED(strDeviceName), cec_device_type_list UNUSED(types), uint16_t UNUSED(iPhysicalAddress) /* = 0 */) :
m_iStartTime(GetTimeMs()),
m_client(NULL)
m_cec = new CCECProcessor(this);
}
+//TODO replace deprecated constructor in 2.0
CLibCEC::CLibCEC(libcec_configuration *UNUSED(configuration)) :
m_iStartTime(GetTimeMs()),
m_client(NULL)
UnregisterClients();
// delete the adapter connection
- delete m_cec;
- m_cec = NULL;
+ DELETE_AND_NULL(m_cec);
}
bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
m_clients.clear();
- delete m_client;
- m_client = NULL;
+ DELETE_AND_NULL(m_client);
}
void * CECInitialise(libcec_configuration *configuration)
void CECDestroy(CEC::ICECAdapter *instance)
{
- delete instance;
+ DELETE_AND_NULL(instance);
}
bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
retVal.Shift(2); // shift out start and msgcode
retVal.size -= 1; // remove end
}
+
delete message;
return retVal;
}
#include "USBCECAdapterMessageQueue.h"
#include "../platform/sockets/serialport.h"
#include "../platform/util/timeutils.h"
+#include "../platform/util/util.h"
#include "../LibCEC.h"
#include "../CECProcessor.h"
CUSBCECAdapterCommunication::~CUSBCECAdapterCommunication(void)
{
Close();
- delete m_commands;
- delete m_adapterMessageQueue;
- delete m_port;
+ DELETE_AND_NULL(m_commands);
+ DELETE_AND_NULL(m_adapterMessageQueue);
+ DELETE_AND_NULL(m_port);
}
bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */, bool bSkipChecks /* = false */, bool bStartListening /* = true */)
m_adapterMessageQueue->Clear();
/* stop and delete the ping thread */
- if (m_pingThread)
- m_pingThread->StopThread(0);
- delete m_pingThread;
- m_pingThread = NULL;
+ DELETE_AND_NULL(m_pingThread);
/* close and delete the com port connection */
if (m_port)
#include "../implementations/VLCommandHandler.h"
#include "../LibCEC.h"
#include "../platform/util/timeutils.h"
+#include "../platform/util/util.h"
#include "CECAudioSystem.h"
#include "CECPlaybackDevice.h"
CCECBusDevice::~CCECBusDevice(void)
{
- delete m_handler;
+ DELETE_AND_NULL(m_handler);
}
bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
if (CCECCommandHandler::HasSpecificHandler(m_vendor))
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress());
- delete m_handler;
+ DELETE_AND_NULL(m_handler);
switch (m_vendor)
{
#include "../CECClient.h"
#include "../CECProcessor.h"
#include "../LibCEC.h"
+#include "../platform/util/util.h"
using namespace CEC;
using namespace std;
CCECCommandHandler::~CCECCommandHandler(void)
{
- delete m_waitForResponse;
+ DELETE_AND_NULL(m_waitForResponse);
}
bool CCECCommandHandler::HandleCommand(const cec_command &command)
--- /dev/null
+#pragma once
+/*
+ * This file is part of the libCEC(R) library.
+ *
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
+ * libCEC(R) is an original work, containing original code.
+ *
+ * libCEC(R) is a trademark of Pulse-Eight Limited.
+ *
+ * This program is dual-licensed; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *
+ * Alternatively, you can license this library under a commercial license,
+ * please contact Pulse-Eight Licensing for more information.
+ *
+ * For more information contact:
+ * Pulse-Eight Licensing <license@pulse-eight.com>
+ * http://www.pulse-eight.com/
+ * http://www.pulse-eight.net/
+ */
+
+#define DELETE_AND_NULL(t) while (t) { delete (t); (t) = NULL; }