From: Lars Op den Kamp Date: Wed, 21 Dec 2011 23:55:45 +0000 (+0100) Subject: cec: fix handler init X-Git-Tag: upstream/2.2.0~1^2~43^2~21 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=89a726faa6ffe9c02ce9d6452a9fe34e98d26037;p=deb_libcec.git cec: fix handler init --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 770b24b..5b1c06e 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -170,9 +170,8 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true)) { - /* init the default handler */ - if (m_busDevices[CECDEVICE_TV]->GetHandler()->GetVendorId() == CEC_VENDOR_UNKNOWN) - m_busDevices[CECDEVICE_TV]->GetHandler()->InitHandler(); + /* init the handler */ + m_busDevices[CECDEVICE_TV]->GetHandler()->InitHandler(); m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); return true; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 8d16a02..ef8a8f2 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -44,7 +44,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) : m_processor(m_busDevice->GetProcessor()), m_iTransmitTimeout(CEC_DEFAULT_TRANSMIT_TIMEOUT), m_iTransmitWait(CEC_DEFAULT_TRANSMIT_WAIT), - m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES) + m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES), + m_bHandlerInited(false) { } @@ -946,8 +947,12 @@ bool CCECCommandHandler::InitHandler(void) primary->SetPowerStatus(CEC_POWER_STATUS_ON); primary->SetMenuState(CEC_MENU_STATE_ACTIVATED); - m_processor->SetActiveSource(); - primary->TransmitMenuState(m_busDevice->GetLogicalAddress()); + if (m_processor->GetPrimaryDevice()->GetPhysicalAddress(false) != 0xffff) + { + m_processor->SetActiveSource(); + primary->TransmitMenuState(m_busDevice->GetLogicalAddress()); + m_bHandlerInited = true; + } } return true; } diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index 762052b..0469b31 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -130,6 +130,7 @@ namespace CEC int32_t m_iTransmitTimeout; int32_t m_iTransmitWait; int8_t m_iTransmitRetries; + bool m_bHandlerInited; CMutex m_receiveMutex; CCondition m_condition; }; diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index e63f1bb..f86a644 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -246,6 +246,10 @@ bool CSLCommandHandler::HandleReceiveFailed(void) bool CSLCommandHandler::InitHandler(void) { + if (m_bHandlerInited) + return true; + m_bHandlerInited = true; + m_processor->SetStandardLineTimeout(3); m_processor->SetRetryLineTimeout(3);