OLD | NEW |
| (Empty) |
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 "voice_engine/statistics.h" | |
15 | |
16 #include "system_wrappers/include/trace.h" | |
17 | |
18 namespace webrtc { | |
19 | |
20 namespace voe { | |
21 | |
22 Statistics::Statistics(uint32_t instanceId) : | |
23 _instanceId(instanceId), | |
24 _lastError(0), | |
25 _isInitialized(false) | |
26 { | |
27 } | |
28 | |
29 Statistics::~Statistics() | |
30 { | |
31 } | |
32 | |
33 int32_t Statistics::SetInitialized() | |
34 { | |
35 _isInitialized = true; | |
36 return 0; | |
37 } | |
38 | |
39 int32_t Statistics::SetUnInitialized() | |
40 { | |
41 _isInitialized = false; | |
42 return 0; | |
43 } | |
44 | |
45 bool Statistics::Initialized() const | |
46 { | |
47 return _isInitialized; | |
48 } | |
49 | |
50 int32_t Statistics::SetLastError(int32_t error) const | |
51 { | |
52 rtc::CritScope cs(&lock_); | |
53 _lastError = error; | |
54 return 0; | |
55 } | |
56 | |
57 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 rtc::CritScope cs(&lock_); | |
64 _lastError = error; | |
65 return 0; | |
66 } | |
67 | |
68 int32_t Statistics::SetLastError( | |
69 int32_t error, | |
70 TraceLevel level, const char* msg) const | |
71 { | |
72 char traceMessage[KTraceMaxMessageSize]; | |
73 assert(strlen(msg) < KTraceMaxMessageSize); | |
74 sprintf(traceMessage, "%s (error=%d)", msg, error); | |
75 | |
76 WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1), "%s", | |
77 traceMessage); | |
78 | |
79 rtc::CritScope cs(&lock_); | |
80 _lastError = error; | |
81 return 0; | |
82 } | |
83 | |
84 } // namespace voe | |
85 | |
86 } // namespace webrtc | |
OLD | NEW |