From: Lars Op den Kamp Date: Mon, 30 Jan 2012 13:16:47 +0000 (+0100) Subject: cec: wait 500 ms before trying to retransmit a command. always wait for the result... X-Git-Tag: upstream/2.2.0~1^2~36^2~30 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4478bc797f871f631399ab8008d3b2787ded07c2;p=deb_libcec.git cec: wait 500 ms before trying to retransmit a command. always wait for the result of a transmission in CCECCommandHandler::Transmit() --- diff --git a/include/cectypes.h b/include/cectypes.h index f3864c6..36057eb 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -73,9 +73,10 @@ namespace CEC { #define CEC_POWER_STATE_REFRESH_TIME 30000 #define CEC_FW_VERSION_UNKNOWN 0xFFFF -#define CEC_DEFAULT_TRANSMIT_TIMEOUT 1000 -#define CEC_DEFAULT_TRANSMIT_WAIT 2000 -#define CEC_DEFAULT_TRANSMIT_RETRIES 1 +#define CEC_DEFAULT_TRANSMIT_RETRY_WAIT 500 +#define CEC_DEFAULT_TRANSMIT_TIMEOUT 1000 +#define CEC_DEFAULT_TRANSMIT_WAIT 2000 +#define CEC_DEFAULT_TRANSMIT_RETRIES 1 #define CEC_MIN_LIB_VERSION 1 #define CEC_LIB_VERSION_MAJOR 1 diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 0ad84d8..b54426c 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -324,7 +324,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to) if (previousDevice && newDevice) { newDevice->SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC); - previousDevice->SetDeviceStatus(CEC_DEVICE_STATUS_UNKNOWN); + previousDevice->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); newDevice->SetCecVersion(previousDevice->GetCecVersion(false)); previousDevice->SetCecVersion(CEC_VERSION_UNKNOWN); @@ -474,6 +474,12 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE { bReturn = m_busDevices[addr]->TransmitActiveSource(); + if (bReturn) + { + m_busDevices[addr]->SetMenuState(CEC_MENU_STATE_ACTIVATED); + m_busDevices[addr]->TransmitMenuState(CECDEVICE_TV); + } + if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && m_busDevices[addr]->GetHandler()->SendDeckStatusUpdateOnActiveSource()) @@ -889,6 +895,8 @@ bool CCECProcessor::Transmit(CCECAdapterMessage *output) if (output->tries > 0) m_communication->SetLineTimeout(m_iRetryLineTimeout); bReturn = m_communication->Write(output); + if (!bReturn) + Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT); }while (!bReturn && output->transmit_timeout > 0 && output->NeedsRetry() && ++output->tries < output->maxTries); } diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 66bdfbd..5fe3eba 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -959,12 +959,11 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* while (!bReturn && ++iTries <= iMaxTries) { m_expectedResponse = expectedResponse; - if (m_processor->Transmit(command)) + if ((bReturn = m_processor->Transmit(command))) { CLibCEC::AddLog(CEC_LOG_DEBUG, "command transmitted"); - bReturn = bExpectResponse ? - m_condition.Wait(m_receiveMutex, m_iTransmitWait) : - true; + if (bExpectResponse) + bReturn = m_condition.Wait(m_receiveMutex, m_iTransmitWait); } } --m_iUseCounter;