#include "../implementations/SLCommandHandler.h"
#include "../implementations/VLCommandHandler.h"
#include "../LibCEC.h"
+#include "../CECTypeUtils.h"
#include "../platform/util/timeutils.h"
+#include "../platform/util/util.h"
#include "CECAudioSystem.h"
#include "CECPlaybackDevice.h"
using namespace PLATFORM;
#define LIB_CEC m_processor->GetLib()
-#define ToString(p) LIB_CEC->ToString(p)
+#define ToString(p) CCECTypeUtils::ToString(p)
CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */) :
m_type (CEC_DEVICE_TYPE_RESERVED),
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)
{
if (bInitHandler)
{
- m_handler->InitHandler();
+ CCECBusDevice *primary = GetProcessor()->GetPrimaryDevice();
+ if (primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED)
+ {
+ m_handler->InitHandler();
- if (bActivateSource && IsHandledByLibCEC() && IsActiveSource())
- m_handler->ActivateSource();
+ if (bActivateSource && IsHandledByLibCEC() && IsActiveSource())
+ m_handler->ActivateSource();
+ }
}
MarkReady();