From: Lars Op den Kamp Date: Wed, 3 Oct 2012 15:54:56 +0000 (+0200) Subject: don't log every frame, unless debugging was enabled in ./configure or visual studio X-Git-Tag: upstream/2.2.0~1^2~17^2^2~36 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8cd2b85af8e7210497ccd612396b5e73557172f3;p=deb_libcec.git don't log every frame, unless debugging was enabled in ./configure or visual studio --- diff --git a/configure.ac b/configure.ac index 7313948..4bd7648 100644 --- a/configure.ac +++ b/configure.ac @@ -313,6 +313,7 @@ CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers" if test "x$use_debug" = "xyes"; then CXXFLAGS="$CXXFLAGS -g" + AC_DEFINE(CEC_DEBUGGING,"1", "generate libCEC debug output") fi if test "x$optimisation" = "xyes"; then diff --git a/project/libcec.vcxproj b/project/libcec.vcxproj index dd529e1..fca9635 100644 --- a/project/libcec.vcxproj +++ b/project/libcec.vcxproj @@ -181,7 +181,7 @@ Level4 Disabled - HAVE_P8_USB;_USE_32BIT_TIME_T;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) + CEC_DEBUGGING;HAVE_P8_USB;_USE_32BIT_TIME_T;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) $(SolutionDir)..\include;$(SolutionDir)..\src;%(AdditionalIncludeDirectories) @@ -197,7 +197,7 @@ Level4 Disabled - HAVE_P8_USB;_WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) + CEC_DEBUGGING;HAVE_P8_USB;_WIN64;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINSOCKAPI_;__STDC_CONSTANT_MACROS;DLL_EXPORT;%(PreprocessorDefinitions) $(SolutionDir)..\include;$(SolutionDir)..\src;%(AdditionalIncludeDirectories) @@ -267,4 +267,4 @@ - \ No newline at end of file + diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp index a2c33e7..3d36497 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp @@ -384,7 +384,9 @@ bool CUSBCECAdapterCommunication::WriteToDevice(CCECAdapterMessage *message) return false; } +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "command '%s' sent", message->IsTranmission() ? "CEC transmission" : CCECAdapterMessage::ToString(message->Message())); +#endif message->state = ADAPTER_MESSAGE_STATE_SENT; return true; } diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp index 77f93c7..35faeb7 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp @@ -203,12 +203,14 @@ bool CCECAdapterMessageQueueEntry::MessageReceivedCommandAccepted(const CCECAdap /* decrease by 1 */ m_iPacketsLeft--; +#ifdef CEC_DEBUGGING /* log this message */ CStdString strLog; strLog.Format("%s - command accepted", ToString()); if (m_iPacketsLeft > 0) strLog.AppendFormat(" - waiting for %d more", m_iPacketsLeft); m_queue->m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, strLog); +#endif /* no more packets left and not a transmission, so we're done */ if (!m_message->IsTranmission() && m_iPacketsLeft == 0) @@ -234,7 +236,9 @@ bool CCECAdapterMessageQueueEntry::MessageReceivedTransmitSucceeded(const CCECAd if (m_iPacketsLeft == 0) { /* transmission succeeded, so we're done */ +#ifdef CEC_DEBUGGING m_queue->m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "%s - transmit succeeded", m_message->ToString().c_str()); +#endif m_message->state = ADAPTER_MESSAGE_STATE_SENT_ACKED; m_message->response = message.packet; } @@ -256,7 +260,9 @@ bool CCECAdapterMessageQueueEntry::MessageReceivedResponse(const CCECAdapterMess { { CLockObject lock(m_mutex); +#ifdef CEC_DEBUGGING m_queue->m_com->m_callback->GetLib()->AddLog(CEC_LOG_DEBUG, "%s - received response - %s", ToString(), message.ToString().c_str()); +#endif m_message->response = message.packet; if (m_message->IsTranmission()) m_message->state = message.Message() == MSGCODE_TRANSMIT_SUCCEEDED ? ADAPTER_MESSAGE_STATE_SENT_ACKED : ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; @@ -365,7 +371,12 @@ void CCECAdapterMessageQueue::MessageReceived(const CCECAdapterMessage &msg) { /* the message wasn't handled */ bool bIsError(m_com->HandlePoll(msg)); +#ifdef CEC_DEBUGGING m_com->m_callback->GetLib()->AddLog(bIsError ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString().c_str()); +#else + if (bIsError) + m_com->m_callback->GetLib()->AddLog(CEC_LOG_WARNING, msg.ToString().c_str()); +#endif /* push this message to the current frame */ if (!bIsError && msg.PushToCecCommand(m_currentCECFrame))