Line data Source code
1 : /*
2 : * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 : #include <assert.h>
12 : #include <stdio.h>
13 :
14 : #include "webrtc/voice_engine/statistics.h"
15 :
16 : #include "webrtc/system_wrappers/include/trace.h"
17 :
18 : namespace webrtc {
19 :
20 : namespace voe {
21 :
22 0 : Statistics::Statistics(uint32_t instanceId) :
23 : _instanceId(instanceId),
24 : _lastError(0),
25 0 : _isInitialized(false)
26 : {
27 0 : }
28 :
29 0 : Statistics::~Statistics()
30 : {
31 0 : }
32 :
33 0 : int32_t Statistics::SetInitialized()
34 : {
35 0 : _isInitialized = true;
36 0 : return 0;
37 : }
38 :
39 0 : int32_t Statistics::SetUnInitialized()
40 : {
41 0 : _isInitialized = false;
42 0 : return 0;
43 : }
44 :
45 0 : bool Statistics::Initialized() const
46 : {
47 0 : return _isInitialized;
48 : }
49 :
50 0 : int32_t Statistics::SetLastError(int32_t error) const
51 : {
52 0 : rtc::CritScope cs(&lock_);
53 0 : _lastError = error;
54 0 : return 0;
55 : }
56 :
57 0 : int32_t Statistics::SetLastError(int32_t error,
58 : TraceLevel level) const
59 : {
60 : WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1),
61 : "error code is set to %d",
62 : error);
63 0 : rtc::CritScope cs(&lock_);
64 0 : _lastError = error;
65 0 : return 0;
66 : }
67 :
68 0 : int32_t Statistics::SetLastError(
69 : int32_t error,
70 : TraceLevel level, const char* msg) const
71 : {
72 : char traceMessage[KTraceMaxMessageSize];
73 0 : assert(strlen(msg) < KTraceMaxMessageSize);
74 0 : sprintf(traceMessage, "%s (error=%d)", msg, error);
75 :
76 : WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1), "%s",
77 : traceMessage);
78 :
79 0 : rtc::CritScope cs(&lock_);
80 0 : _lastError = error;
81 0 : return 0;
82 : }
83 :
84 0 : int32_t Statistics::LastError() const
85 : {
86 : int32_t ret;
87 : {
88 0 : rtc::CritScope cs(&lock_);
89 0 : ret = _lastError;
90 : }
91 : WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1),
92 : "LastError() => %d", ret);
93 0 : return ret;
94 : }
95 :
96 : } // namespace voe
97 :
98 : } // namespace webrtc
|