diff options
-rw-r--r-- | build/common.gypi | 3 | ||||
-rw-r--r-- | common_types.h | 1 | ||||
-rw-r--r-- | system_wrappers/interface/logging.h | 166 | ||||
-rw-r--r-- | system_wrappers/interface/trace.h | 13 | ||||
-rw-r--r-- | system_wrappers/source/condition_variable_unittest.cc | 14 | ||||
-rw-r--r-- | system_wrappers/source/critical_section_unittest.cc | 10 | ||||
-rw-r--r-- | system_wrappers/source/logging.cc | 52 | ||||
-rw-r--r-- | system_wrappers/source/logging_unittest.cc | 96 | ||||
-rw-r--r-- | system_wrappers/source/system_wrappers.gyp | 28 | ||||
-rw-r--r-- | system_wrappers/source/trace_impl.cc | 32 | ||||
-rw-r--r-- | voice_engine/channel.cc | 51 | ||||
-rw-r--r-- | voice_engine/voe_audio_processing_impl.cc | 21 |
12 files changed, 388 insertions, 99 deletions
diff --git a/build/common.gypi b/build/common.gypi index b4f6a263..0921906d 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -91,6 +91,8 @@ # Disable the use of protocol buffers in production code. 'enable_protobuf%': 0, + 'enable_tracing%': 0, + }, { # Settings for the standalone (not-in-Chromium) build. 'include_pulse_audio%': 1, 'include_internal_audio_device%': 1, @@ -98,6 +100,7 @@ 'include_internal_video_render%': 1, 'include_video_engine_file_api%': 1, 'enable_protobuf%': 1, + 'enable_tracing%': 1, 'include_tests%': 1, # TODO(andrew): For now, disable the Chrome plugins, which causes a diff --git a/common_types.h b/common_types.h index 83c55a3c..f5d55d78 100644 --- a/common_types.h +++ b/common_types.h @@ -57,6 +57,7 @@ protected: enum TraceModule { + kTraceUndefined = 0, // not a module, triggered from the engine code kTraceVoice = 0x0001, // not a module, triggered from the engine code diff --git a/system_wrappers/interface/logging.h b/system_wrappers/interface/logging.h new file mode 100644 index 00000000..ef6fb8dd --- /dev/null +++ b/system_wrappers/interface/logging.h @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +// This is a highly stripped-down version of libjingle's talk/base/logging.h. +// It is a thin wrapper around WEBRTC_TRACE, maintaining the libjingle log +// semantics to ease a transition to that format. + +// LOG(...) an ostream target that can be used to send formatted +// output to a variety of logging targets, such as debugger console, stderr, +// file, or any StreamInterface. +// The severity level passed as the first argument to the LOGging +// functions is used as a filter, to limit the verbosity of the logging. +// Static members of LogMessage documented below are used to control the +// verbosity and target of the output. +// There are several variations on the LOG macro which facilitate logging +// of common error conditions, detailed below. + +// LOG(sev) logs the given stream at severity "sev", which must be a +// compile-time constant of the LoggingSeverity type, without the namespace +// prefix. +// LOG_V(sev) Like LOG(), but sev is a run-time variable of the LoggingSeverity +// type (basically, it just doesn't prepend the namespace). +// LOG_F(sev) Like LOG(), but includes the name of the current function. + +// Additional helper macros added by WebRTC: +// LOG_API is a shortcut for API call logging. Pass in the input parameters of +// the method. For example: +// Foo(int bar, int baz) { +// LOG_API2(bar, baz); +// } +// +// LOG_FERR is a shortcut for logging a failed function call. For example: +// if (!Foo(bar)) { +// LOG_FERR1(WARNING, Foo, bar); +// } + +#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_ +#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_ + +#include <sstream> + +namespace webrtc { + +////////////////////////////////////////////////////////////////////// + +// Note that the non-standard LoggingSeverity aliases exist because they are +// still in broad use. The meanings of the levels are: +// LS_SENSITIVE: Information which should only be logged with the consent +// of the user, due to privacy concerns. +// LS_VERBOSE: This level is for data which we do not want to appear in the +// normal debug log, but should appear in diagnostic logs. +// LS_INFO: Chatty level used in debugging for all sorts of things, the default +// in debug builds. +// LS_WARNING: Something that may warrant investigation. +// LS_ERROR: Something that should not have occurred. +enum LoggingSeverity { LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR, + INFO = LS_INFO, + WARNING = LS_WARNING, + LERROR = LS_ERROR }; + +class LogMessage { + public: + LogMessage(const char* file, int line, LoggingSeverity sev); + ~LogMessage(); + + std::ostream& stream() { return print_stream_; } + + private: + // These assist in formatting some parts of the debug output. + static const char* DescribeFile(const char* file); + + // The ostream that buffers the formatted message before output + std::ostringstream print_stream_; + + // The severity level of this message + LoggingSeverity severity_; +}; + +////////////////////////////////////////////////////////////////////// +// Macros which automatically disable logging when LOGGING == 0 +////////////////////////////////////////////////////////////////////// + +// If LOGGING is not explicitly defined, default to enabled in debug mode +// TODO(andrew): We explictly enable here; handle in gyp instead. +#define LOGGING 1 +#if !defined(LOGGING) +#if defined(_DEBUG) && !defined(NDEBUG) +#define LOGGING 1 +#else +#define LOGGING 0 +#endif +#endif // !defined(LOGGING) + +#ifndef LOG +#if LOGGING + +// The following non-obvious technique for implementation of a +// conditional log stream was stolen from google3/base/logging.h. + +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". + +class LogMessageVoidify { + public: + LogMessageVoidify() { } + // This has to be an operator with a precedence lower than << but + // higher than ?: + void operator&(std::ostream&) { } +}; + +#define LOG(sev) \ + webrtc::LogMessage(__FILE__, __LINE__, webrtc::sev).stream() + +// The _V version is for when a variable is passed in. It doesn't do the +// namespace concatination. +#define LOG_V(sev) \ + webrtc::LogMessage(__FILE__, __LINE__, sev).stream() + +// The _F version prefixes the message with the current function name. +#if (defined(__GNUC__) && defined(_DEBUG)) || defined(WANT_PRETTY_LOG_F) +#define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": " +#else +#define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": " +#endif + +#else // !LOGGING + +// Hopefully, the compiler will optimize away some of this code. +// Note: syntax of "1 ? (void)0 : LogMessage" was causing errors in g++, +// converted to "while (false)" +#define LOG(sev) \ + while (false)webrtc::LogMessage(NULL, 0, webrtc::sev).stream() +#define LOG_V(sev) \ + while (false) webrtc::LogMessage(NULL, 0, sev).stream() +#define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": " + +#endif // !LOGGING + +#define LOG_API0() LOG_F(LS_INFO) +#define LOG_API1(v1) LOG_API0() << #v1 << "=" << v1 +#define LOG_API2(v1, v2) LOG_API1(v1) \ + << ", " << #v2 << "=" << v2 +#define LOG_API3(v1, v2, v3) LOG_API2(v1, v2) \ + << ", " << #v3 << "=" << v3 + +#define LOG_FERR0(sev, func) LOG(sev) << #func << " failed" +#define LOG_FERR1(sev, func, v1) LOG_FERR0(sev, func) \ + << ": " << #v1 << "=" << v1 +#define LOG_FERR2(sev, func, v1, v2) LOG_FERR1(sev, func, v1) \ + << ", " << #v2 << "=" << v2 +#define LOG_FERR3(sev, func, v1, v2, v3) LOG_FERR2(sev, func, v1, v2) \ + << ", " << #v3 << "=" << v3 + +#endif // LOG + +} // namespace webrtc + +#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_LOGGING_H_ diff --git a/system_wrappers/interface/trace.h b/system_wrappers/interface/trace.h index f88d23f8..4b39d055 100644 --- a/system_wrappers/interface/trace.h +++ b/system_wrappers/interface/trace.h @@ -8,9 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -// System independant wrapper for logging runtime information to file. +// System independent wrapper for logging runtime information to file. // Note: All log messages will be written to the same trace file. -// Note: If to many messages are written to file there will be a build up of +// Note: If too many messages are written to file there will be a build up of // messages. Apply filtering to avoid that. #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ @@ -35,7 +35,7 @@ public: // Specifies what type of messages should be written to the trace file. The // filter parameter is a bitmask where each message type is enumerated by - // the TraceLevel enumerator. TODO (hellner) why is the + // the TraceLevel enumerator. TODO(hellner): why is the // TraceLevel enumerator not defined in this file? static WebRtc_Word32 SetLevelFilter(const WebRtc_UWord32 filter); @@ -59,17 +59,18 @@ public: // Adds a trace message for writing to file. The message is put in a queue // for writing to file whenever possible for performance reasons. I.e. there // is a crash it is possible that the last, vital logs are not logged yet. - // level is the the type of message to log. If that type of messages is + // level is the type of message to log. If that type of messages is // filtered it will not be written to file. module is an identifier for what - // part of the code the message is comming. + // part of the code the message is coming. // id is an identifier that should be unique for that set of classes that // are associated (e.g. all instances owned by an engine). - // msg and the elipsis are the same as e.g. sprintf. + // msg and the ellipsis are the same as e.g. sprintf. // TODO (hellner) Why is TraceModule not defined in this file? static void Add(const TraceLevel level, const TraceModule module, const WebRtc_Word32 id, const char* msg, ...); }; + } // namespace webrtc #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_TRACE_H_ diff --git a/system_wrappers/source/condition_variable_unittest.cc b/system_wrappers/source/condition_variable_unittest.cc index 25a4683a..be3bfc6e 100644 --- a/system_wrappers/source/condition_variable_unittest.cc +++ b/system_wrappers/source/condition_variable_unittest.cc @@ -24,8 +24,6 @@ const int kLogTrace = false; // Set to true to enable debug logging to stdout. const int kLongWaitMs = 100 * 1000; // A long time in testing terms const int kShortWaitMs = 2 * 1000; // Long enough for process switches to happen -#define LOG(...) WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, __VA_ARGS__); - // A Baton is one possible control structure one can build using // conditional variables. // A Baton is always held by one and only one active thread - unlike @@ -53,15 +51,12 @@ class Baton { // Only one process can pass at the same time; this property is // ensured by the |giver_sect_| lock. bool Pass(WebRtc_UWord32 max_msecs) { - LOG("Locking giver_sect"); CriticalSectionScoped cs_giver(giver_sect_); - LOG("Locked giver_sect, locking crit_sect"); CriticalSectionScoped cs(crit_sect_); SignalBatonAvailable(); const bool result = TakeBatonIfStillFree(max_msecs); if (result) { ++pass_count_; - LOG("Pass count is %d", pass_count_); } return result; } @@ -87,9 +82,7 @@ class Baton { // These functions must be called with crit_sect_ held. bool WaitUntilBatonOffered(int timeout_ms) { while (!being_passed_) { - LOG("Wait waiting"); if (!cond_var_->SleepCS(*crit_sect_, timeout_ms)) { - LOG("Wait timeout"); return false; } } @@ -101,7 +94,6 @@ class Baton { void SignalBatonAvailable() { assert(!being_passed_); being_passed_ = true; - LOG("Signal waking"); cond_var_->Wake(); } @@ -114,7 +106,6 @@ class Baton { bool TakeBatonIfStillFree(int timeout_ms) { bool not_timeout = true; while (being_passed_ && not_timeout) { - LOG("Takeback waiting"); not_timeout = cond_var_->SleepCS(*crit_sect_, timeout_ms); // If we're woken up while variable is still held, we may have // gotten a wakeup destined for a grabber thread. @@ -123,7 +114,6 @@ class Baton { if (!being_passed_) { return true; } else { - LOG("Takeback grab"); assert(!not_timeout); being_passed_ = false; return false; @@ -145,10 +135,8 @@ class Baton { // Function that waits on a Baton, and passes it right back. // We expect these calls never to time out. bool WaitingRunFunction(void* obj) { - Baton* the_baton = static_cast<Baton*>(obj); - LOG("Thread waiting"); + Baton* the_baton = static_cast<Baton*> (obj); EXPECT_TRUE(the_baton->Grab(kLongWaitMs)); - LOG("Thread waking parent"); EXPECT_TRUE(the_baton->Pass(kLongWaitMs)); return true; } diff --git a/system_wrappers/source/critical_section_unittest.cc b/system_wrappers/source/critical_section_unittest.cc index c48b9f75..23b61a2f 100644 --- a/system_wrappers/source/critical_section_unittest.cc +++ b/system_wrappers/source/critical_section_unittest.cc @@ -30,8 +30,6 @@ namespace { const bool kLogTrace = false; // Set to true to enable debug logging to stdout. -#define LOG(...) WEBRTC_TRACE(kTraceStateInfo, kTraceUtility, -1, __VA_ARGS__); - // Cause a process switch. Needed to avoid depending on // busy-wait in tests. static void SwitchProcess() { @@ -50,7 +48,6 @@ class ProtectedCount { void Increment() { CriticalSectionScoped cs(crit_sect_); ++count_; - LOG("Inc to %d", count_); } int Count() const { @@ -79,7 +76,6 @@ class CritSectTest : public ::testing::Test { ++loop_counter; SwitchProcess(); } - LOG("Test looped %d times\n", loop_counter); return (count->Count() >= target); } @@ -88,11 +84,8 @@ class CritSectTest : public ::testing::Test { }; bool LockUnlockThenStopRunFunction(void* obj) { - LOG("Wait starting"); ProtectedCount* the_count = static_cast<ProtectedCount*> (obj); - LOG("Wait incrementing"); the_count->Increment(); - LOG("Wait returning"); return false; } @@ -119,12 +112,9 @@ TEST_F(CritSectTest, ThreadWakesOnce) { } bool LockUnlockRunFunction(void* obj) { - LOG("Wait starting"); ProtectedCount* the_count = static_cast<ProtectedCount*> (obj); - LOG("Wait incrementing"); the_count->Increment(); SwitchProcess(); - LOG("Wait returning"); return true; } diff --git a/system_wrappers/source/logging.cc b/system_wrappers/source/logging.cc new file mode 100644 index 00000000..16804d95 --- /dev/null +++ b/system_wrappers/source/logging.cc @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "webrtc/system_wrappers/interface/logging.h" + +#include <string.h> +#include <iostream> + +#include "webrtc/common_types.h" +#include "webrtc/system_wrappers/interface/trace.h" + +namespace webrtc { + +static TraceLevel WebRtcSeverity(LoggingSeverity sev) { + switch (sev) { + // TODO(andrew): SENSITIVE doesn't have a corresponding webrtc level. + case LS_SENSITIVE: return kTraceInfo; + case LS_VERBOSE: return kTraceDebug; + case LS_INFO: return kTraceInfo; + case LS_WARNING: return kTraceWarning; + case LS_ERROR: return kTraceError; + default: return kTraceNone; + } +} + +LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev) + : severity_(sev) { + print_stream_ << "(" << DescribeFile(file) << ":" << line << "): "; +} + +LogMessage::~LogMessage() { + const std::string& str = print_stream_.str(); + WEBRTC_TRACE(WebRtcSeverity(severity_), kTraceUndefined, 0, str.c_str()); +} + +const char* LogMessage::DescribeFile(const char* file) { + const char* end1 = ::strrchr(file, '/'); + const char* end2 = ::strrchr(file, '\\'); + if (!end1 && !end2) + return file; + else + return (end1 > end2) ? end1 + 1 : end2 + 1; +} + +} // namespace webrtc diff --git a/system_wrappers/source/logging_unittest.cc b/system_wrappers/source/logging_unittest.cc new file mode 100644 index 00000000..45acbfd3 --- /dev/null +++ b/system_wrappers/source/logging_unittest.cc @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "webrtc/system_wrappers/interface/logging.h" + +#include "gtest/gtest.h" +#include "webrtc/system_wrappers/interface/condition_variable_wrapper.h" +#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" +#include "webrtc/system_wrappers/interface/scoped_ptr.h" +#include "webrtc/system_wrappers/interface/sleep.h" +#include "webrtc/system_wrappers/interface/trace.h" + +namespace webrtc { +namespace { + +const size_t kBoilerplateLength = 71; + +class LoggingTest : public ::testing::Test, public TraceCallback { + public: + virtual void Print(const TraceLevel level, + const char* msg, + const int length) { + CriticalSectionScoped cs(crit_.get()); + // We test the length here to ensure (with high likelihood) that only our + // traces will be tested. + if (level_ != kTraceNone && + expected_log_.str().size() == length - kBoilerplateLength - 1) { + EXPECT_EQ(level_, level); + EXPECT_EQ(expected_log_.str(), &msg[kBoilerplateLength]); + level_ = kTraceNone; + cv_->Wake(); + } + } + + protected: + LoggingTest() + : crit_(CriticalSectionWrapper::CreateCriticalSection()), + cv_(ConditionVariableWrapper::CreateConditionVariable()), + level_(kTraceNone), + expected_log_() { + } + + void SetUp() { + Trace::CreateTrace(); + Trace::SetTraceCallback(this); + // Reduce the chance that spurious traces will ruin the test. + Trace::SetLevelFilter(kTraceWarning | kTraceError); + } + + void TearDown() { + CriticalSectionScoped cs(crit_.get()); + Trace::SetTraceCallback(NULL); + Trace::ReturnTrace(); + ASSERT_EQ(kTraceNone, level_) << "Print() was not called"; + } + + scoped_ptr<CriticalSectionWrapper> crit_; + scoped_ptr<ConditionVariableWrapper> cv_; + TraceLevel level_; + int length_; + std::ostringstream expected_log_; +}; + +TEST_F(LoggingTest, LogStream) { + { + CriticalSectionScoped cs(crit_.get()); + level_ = kTraceWarning; + std::string msg = "Important message"; + expected_log_ << "(logging_unittest.cc:" << __LINE__ + 1 << "): " << msg; + LOG(WARNING) << msg; + cv_->SleepCS(*crit_.get()); + } +} + +TEST_F(LoggingTest, LogFunctionError) { + { + CriticalSectionScoped cs(crit_.get()); + int bar = 42; + int baz = 99; + level_ = kTraceError; + expected_log_ << "(logging_unittest.cc:" << __LINE__ + 2 + << "): Foo failed: bar=" << bar << ", baz=" << baz; + LOG_FERR2(LS_ERROR, Foo, bar, baz); + cv_->SleepCS(*crit_.get()); + } +} + +} // namespace +} // namespace webrtc diff --git a/system_wrappers/source/system_wrappers.gyp b/system_wrappers/source/system_wrappers.gyp index 02e30196..d629da97 100644 --- a/system_wrappers/source/system_wrappers.gyp +++ b/system_wrappers/source/system_wrappers.gyp @@ -37,6 +37,7 @@ '../interface/file_wrapper.h', '../interface/fix_interlocked_exchange_pointer_win.h', '../interface/list_wrapper.h', + '../interface/logging.h', '../interface/map_wrapper.h', '../interface/ref_count.h', '../interface/rw_lock_wrapper.h', @@ -83,6 +84,7 @@ 'file_impl.cc', 'file_impl.h', 'list_no_stl.cc', + 'logging.cc', 'map.cc', 'rw_lock.cc', 'rw_lock_generic.cc', @@ -111,9 +113,23 @@ 'conditions': [ ['enable_data_logging==1', { 'sources!': [ 'data_log_no_op.cc', ], - },{ + }, { 'sources!': [ 'data_log.cc', ], },], + ['enable_tracing==1', { + 'sources!': [ + 'trace_impl_no_op.cc', + ], + }, { + 'sources!': [ + 'trace_impl.cc', + 'trace_impl.h', + 'trace_posix.cc', + 'trace_posix.h', + 'trace_win.cc', + 'trace_win.h', + ], + }], ['OS=="android"', { 'dependencies': [ 'cpu_features_android', ], }], @@ -141,19 +157,12 @@ 'cpu_linux.h', 'cpu_mac.h', 'cpu_win.h', - 'trace_impl.cc', - 'trace_impl.h', - 'trace_posix.cc', - 'trace_posix.h', - 'trace_win.cc', - 'trace_win.h', ], }, { 'sources!': [ 'cpu_no_op.cc', - 'trace_impl_no_op.cc', ], - }] + }], ], # conditions 'target_conditions': [ # We need to do this in a target_conditions block to override the @@ -210,6 +219,7 @@ 'cpu_measurement_harness.cc', 'critical_section_unittest.cc', 'list_unittest.cc', + 'logging_unittest.cc', 'map_unittest.cc', 'data_log_unittest.cc', 'data_log_unittest_disabled.cc', diff --git a/system_wrappers/source/trace_impl.cc b/system_wrappers/source/trace_impl.cc index 09d3eb78..c3c6849c 100644 --- a/system_wrappers/source/trace_impl.cc +++ b/system_wrappers/source/trace_impl.cc @@ -199,6 +199,7 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage, // TODO (hellner): is this actually a problem? If so, it should be better to // clean up WebRtc_Word32 const long int idl = id; + const int kMessageLength = 25; if(idl != -1) { const unsigned long int idEngine = id>>16; @@ -206,6 +207,10 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage, switch (module) { + case kTraceUndefined: + // Add the appropriate amount of whitespace. + memset(traceMessage, ' ', kMessageLength); + break; case kTraceVoice: sprintf(traceMessage, " VOICE:%5ld %5ld;", idEngine, idChannel); @@ -279,6 +284,10 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage, } else { switch (module) { + case kTraceUndefined: + // Add the appropriate amount of whitespace. + memset(traceMessage, ' ', kMessageLength); + break; case kTraceVoice: sprintf (traceMessage, " VOICE:%11ld;", idl); break; @@ -332,8 +341,7 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage, break; } } - // All messages are 25 characters. - return 25; + return kMessageLength; } WebRtc_Word32 TraceImpl::SetTraceFileImpl(const char* fileNameUTF8, @@ -605,44 +613,44 @@ void TraceImpl::AddImpl(const TraceLevel level, const TraceModule module, if (TraceCheck(level)) { char traceMessage[WEBRTC_TRACE_MAX_MESSAGE_SIZE]; - char* meassagePtr = traceMessage; + char* messagePtr = traceMessage; WebRtc_Word32 len = 0; WebRtc_Word32 ackLen = 0; - len = AddLevel(meassagePtr, level); + len = AddLevel(messagePtr, level); if(len == -1) { return; } - meassagePtr += len; + messagePtr += len; ackLen += len; - len = AddTime(meassagePtr, level); + len = AddTime(messagePtr, level); if(len == -1) { return; } - meassagePtr += len; + messagePtr += len; ackLen += len; - len = AddModuleAndId(meassagePtr, module, id); + len = AddModuleAndId(messagePtr, module, id); if(len == -1) { return; } - meassagePtr += len; + messagePtr += len; ackLen += len; - len = AddThreadId(meassagePtr); + len = AddThreadId(messagePtr); if(len < 0) { return; } - meassagePtr += len; + messagePtr += len; ackLen += len; - len = AddMessage(meassagePtr, msg, (WebRtc_UWord16)ackLen); + len = AddMessage(messagePtr, msg, (WebRtc_UWord16)ackLen); if(len == -1) { return; diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc index 3cca5db9..976146f5 100644 --- a/voice_engine/channel.cc +++ b/voice_engine/channel.cc @@ -14,6 +14,7 @@ #include "audio_frame_operations.h" #include "audio_processing.h" #include "critical_section_wrapper.h" +#include "logging.h" #include "output_mixer.h" #include "process_thread.h" #include "rtp_dump.h" @@ -29,11 +30,8 @@ #include <Qos.h> #endif -namespace webrtc -{ - -namespace voe -{ +namespace webrtc { +namespace voe { WebRtc_Word32 Channel::SendData(FrameType frameType, @@ -6615,36 +6613,21 @@ Channel::RegisterReceiveCodecsToRTPModule() } } -int -Channel::ApmProcessRx(AudioFrame& audioFrame) -{ - WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), - "Channel::ApmProcessRx()"); - - // Register the (possibly new) frame parameters. - if (_rxAudioProcessingModulePtr->set_sample_rate_hz( - audioFrame.sample_rate_hz_) != 0) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), - "AudioProcessingModule::set_sample_rate_hz(%u) => error", - audioFrame.sample_rate_hz_); - } - if (_rxAudioProcessingModulePtr->set_num_channels(audioFrame.num_channels_, - audioFrame.num_channels_) != 0) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), - "AudioProcessingModule::set_num_channels(%u, %u) => error", - audioFrame.num_channels_, audioFrame.num_channels_); - } - - if (_rxAudioProcessingModulePtr->ProcessStream(&audioFrame) != 0) - { - WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), - "AudioProcessingModule::ProcessStream() => error"); - } - return 0; +int Channel::ApmProcessRx(AudioFrame& frame) { + AudioProcessing* audioproc = _rxAudioProcessingModulePtr; + // Register the (possibly new) frame parameters. + if (audioproc->set_sample_rate_hz(frame.sample_rate_hz_) != 0) { + LOG_FERR1(WARNING, set_sample_rate_hz, frame.sample_rate_hz_); + } + if (audioproc->set_num_channels(frame.num_channels_, + frame.num_channels_) != 0) { + LOG_FERR1(WARNING, set_num_channels, frame.num_channels_); + } + if (audioproc->ProcessStream(&frame) != 0) { + LOG_FERR0(WARNING, ProcessStream); + } + return 0; } } // namespace voe - } // namespace webrtc diff --git a/voice_engine/voe_audio_processing_impl.cc b/voice_engine/voe_audio_processing_impl.cc index 62440f4e..9397bfaf 100644 --- a/voice_engine/voe_audio_processing_impl.cc +++ b/voice_engine/voe_audio_processing_impl.cc @@ -13,18 +13,13 @@ #include "audio_processing.h" #include "channel.h" #include "critical_section_wrapper.h" +#include "logging.h" #include "trace.h" #include "transmit_mixer.h" #include "voe_errors.h" #include "voice_engine_impl.h" // TODO(andrew): move to a common place. -#define WEBRTC_TRACE_VOICE_API() \ - do { \ - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, \ - VoEId(_shared->instance_id(), -1), __FUNCTION__); \ - } while (0) - #define WEBRTC_VOICE_INIT_CHECK() \ do { \ if (!_shared->statistics().Initialized()) { \ @@ -41,7 +36,6 @@ } \ } while (0) - namespace webrtc { #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) @@ -353,9 +347,7 @@ int VoEAudioProcessingImpl::GetAgcConfig(AgcConfig& config) { int VoEAudioProcessingImpl::SetRxNsStatus(int channel, bool enable, NsModes mode) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetRxNsStatus(channel=%d, enable=%d, mode=%d)", - channel, (int)enable, (int)mode); + LOG_API3(channel, enable, mode); #ifdef WEBRTC_VOICE_ENGINE_NR if (!_shared->statistics().Initialized()) { _shared->SetLastError(VE_NOT_INITED, kTraceError); @@ -514,7 +506,7 @@ bool VoEAudioProcessing::DriftCompensationSupported() { } int VoEAudioProcessingImpl::EnableDriftCompensation(bool enable) { - WEBRTC_TRACE_VOICE_API(); + LOG_API1(enable); WEBRTC_VOICE_INIT_CHECK(); if (!DriftCompensationSupported()) { @@ -533,7 +525,7 @@ int VoEAudioProcessingImpl::EnableDriftCompensation(bool enable) { } bool VoEAudioProcessingImpl::DriftCompensationEnabled() { - WEBRTC_TRACE_VOICE_API(); + LOG_API0(); WEBRTC_VOICE_INIT_CHECK_BOOL(); EchoCancellation* aec = _shared->audio_processing()->echo_cancellation(); @@ -1139,13 +1131,12 @@ int VoEAudioProcessingImpl::SetTypingDetectionParameters(int timeWindow, } void VoEAudioProcessingImpl::EnableStereoChannelSwapping(bool enable) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "EnableStereoChannelSwapping(enable=%d)", enable); + LOG_API1(enable); _shared->transmit_mixer()->EnableStereoChannelSwapping(enable); } bool VoEAudioProcessingImpl::IsStereoChannelSwappingEnabled() { - WEBRTC_TRACE_VOICE_API(); + LOG_API0(); return _shared->transmit_mixer()->IsStereoChannelSwappingEnabled(); } |