OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 echo_control_mobile_(NULL), | 187 echo_control_mobile_(NULL), |
188 gain_control_(NULL), | 188 gain_control_(NULL), |
189 high_pass_filter_(NULL), | 189 high_pass_filter_(NULL), |
190 level_estimator_(NULL), | 190 level_estimator_(NULL), |
191 noise_suppression_(NULL), | 191 noise_suppression_(NULL), |
192 voice_detection_(NULL), | 192 voice_detection_(NULL), |
193 crit_(CriticalSectionWrapper::CreateCriticalSection()), | 193 crit_(CriticalSectionWrapper::CreateCriticalSection()), |
194 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 194 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
195 debug_file_(FileWrapper::Create()), | 195 debug_file_(FileWrapper::Create()), |
196 event_msg_(new audioproc::Event()), | 196 event_msg_(new audioproc::Event()), |
197 nr_bytes_left_for_log(-1), | |
197 #endif | 198 #endif |
198 api_format_({{{kSampleRate16kHz, 1, false}, | 199 api_format_({{{kSampleRate16kHz, 1, false}, |
199 {kSampleRate16kHz, 1, false}, | 200 {kSampleRate16kHz, 1, false}, |
200 {kSampleRate16kHz, 1, false}, | 201 {kSampleRate16kHz, 1, false}, |
201 {kSampleRate16kHz, 1, false}}}), | 202 {kSampleRate16kHz, 1, false}}}), |
202 fwd_proc_format_(kSampleRate16kHz), | 203 fwd_proc_format_(kSampleRate16kHz), |
203 rev_proc_format_(kSampleRate16kHz, 1), | 204 rev_proc_format_(kSampleRate16kHz, 1), |
204 split_rate_(kSampleRate16kHz), | 205 split_rate_(kSampleRate16kHz), |
205 stream_delay_ms_(0), | 206 stream_delay_ms_(0), |
206 delay_offset_ms_(0), | 207 delay_offset_ms_(0), |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 } | 924 } |
924 | 925 |
925 RETURN_ON_ERR(WriteConfigMessage(true)); | 926 RETURN_ON_ERR(WriteConfigMessage(true)); |
926 RETURN_ON_ERR(WriteInitMessage()); | 927 RETURN_ON_ERR(WriteInitMessage()); |
927 return kNoError; | 928 return kNoError; |
928 #else | 929 #else |
929 return kUnsupportedFunctionError; | 930 return kUnsupportedFunctionError; |
930 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 931 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
931 } | 932 } |
932 | 933 |
934 int AudioProcessingImpl::StartDebugRecording( | |
935 const char filename[AudioProcessing::kMaxFilenameSize], | |
936 int max_log_size_bytes) { | |
937 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
938 nr_bytes_left_for_log = max_log_size_bytes; | |
939 int ret_val = StartDebugRecording(filename); | |
940 if (ret_val != kNoError) { | |
941 nr_bytes_left_for_log = -1; | |
hlundin-webrtc
2015/10/30 08:02:21
Is it important to reset to -1 when an error happe
ivoc
2015/11/05 13:14:46
I did this because there was also the other versio
| |
942 } | |
943 return ret_val; | |
944 #else | |
945 return kUnsupportedFunctionError; | |
946 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | |
947 } | |
948 | |
933 int AudioProcessingImpl::StartDebugRecording(FILE* handle) { | 949 int AudioProcessingImpl::StartDebugRecording(FILE* handle) { |
934 CriticalSectionScoped crit_scoped(crit_); | 950 CriticalSectionScoped crit_scoped(crit_); |
935 | 951 |
936 if (handle == NULL) { | 952 if (handle == NULL) { |
937 return kNullPointerError; | 953 return kNullPointerError; |
938 } | 954 } |
939 | 955 |
940 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 956 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
941 // Stop any ongoing recording. | 957 // Stop any ongoing recording. |
942 if (debug_file_->Open()) { | 958 if (debug_file_->Open()) { |
943 if (debug_file_->CloseFile() == -1) { | 959 if (debug_file_->CloseFile() == -1) { |
944 return kFileError; | 960 return kFileError; |
945 } | 961 } |
946 } | 962 } |
947 | 963 |
948 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) { | 964 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) { |
949 return kFileError; | 965 return kFileError; |
950 } | 966 } |
951 | 967 |
952 RETURN_ON_ERR(WriteConfigMessage(true)); | 968 RETURN_ON_ERR(WriteConfigMessage(true)); |
953 RETURN_ON_ERR(WriteInitMessage()); | 969 RETURN_ON_ERR(WriteInitMessage()); |
954 return kNoError; | 970 return kNoError; |
955 #else | 971 #else |
956 return kUnsupportedFunctionError; | 972 return kUnsupportedFunctionError; |
957 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 973 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
958 } | 974 } |
959 | 975 |
976 int AudioProcessingImpl::StartDebugRecording(FILE* handle, | |
977 int max_log_size_bytes) { | |
978 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
979 RTC_DCHECK_GT(max_log_size_bytes, 0); | |
980 nr_bytes_left_for_log = max_log_size_bytes; | |
981 int ret_val = StartDebugRecording(handle); | |
982 if (ret_val != kNoError) { | |
983 nr_bytes_left_for_log = -1; | |
984 } | |
985 return ret_val; | |
986 #else | |
987 return kUnsupportedFunctionError; | |
988 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | |
989 } | |
990 | |
960 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( | 991 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( |
961 rtc::PlatformFile handle) { | 992 rtc::PlatformFile handle) { |
962 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); | 993 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); |
963 return StartDebugRecording(stream); | 994 return StartDebugRecording(stream); |
964 } | 995 } |
965 | 996 |
966 int AudioProcessingImpl::StopDebugRecording() { | 997 int AudioProcessingImpl::StopDebugRecording() { |
967 CriticalSectionScoped crit_scoped(crit_); | 998 CriticalSectionScoped crit_scoped(crit_); |
968 | 999 |
969 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 1000 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1187 } | 1218 } |
1188 #if defined(WEBRTC_ARCH_BIG_ENDIAN) | 1219 #if defined(WEBRTC_ARCH_BIG_ENDIAN) |
1189 // TODO(ajm): Use little-endian "on the wire". For the moment, we can be | 1220 // TODO(ajm): Use little-endian "on the wire". For the moment, we can be |
1190 // pretty safe in assuming little-endian. | 1221 // pretty safe in assuming little-endian. |
1191 #endif | 1222 #endif |
1192 | 1223 |
1193 if (!event_msg_->SerializeToString(&event_str_)) { | 1224 if (!event_msg_->SerializeToString(&event_str_)) { |
1194 return kUnspecifiedError; | 1225 return kUnspecifiedError; |
1195 } | 1226 } |
1196 | 1227 |
1228 if (nr_bytes_left_for_log >= 0) { | |
1229 nr_bytes_left_for_log -= (sizeof(int32_t) + event_str_.size()); | |
kwiberg-webrtc
2015/10/25 02:29:12
You use event_str_.length() below. Are they the sa
ivoc
2015/11/05 13:14:46
for std::string, .size() and .length() are exactly
| |
1230 if (nr_bytes_left_for_log < 0) { | |
1231 // Not enough bytes are left to write this message, so stop logging. | |
1232 nr_bytes_left_for_log = -1; | |
1233 debug_file_->CloseFile(); | |
the sun
2015/10/26 10:37:20
Can you add:
RTC_DCHECK(debug_file_->Open());
at t
hlundin-webrtc
2015/10/30 08:02:21
I agree. I'm also a bit uneasy about setting nr_by
ivoc
2015/11/05 13:14:45
I added the RTC_DCHECK. I removed the code setting
| |
1234 return kUnspecifiedError; | |
1235 } | |
1236 } | |
1237 | |
1197 // Write message preceded by its size. | 1238 // Write message preceded by its size. |
1198 if (!debug_file_->Write(&size, sizeof(int32_t))) { | 1239 if (!debug_file_->Write(&size, sizeof(int32_t))) { |
1199 return kFileError; | 1240 return kFileError; |
1200 } | 1241 } |
1201 if (!debug_file_->Write(event_str_.data(), event_str_.length())) { | 1242 if (!debug_file_->Write(event_str_.data(), event_str_.length())) { |
1202 return kFileError; | 1243 return kFileError; |
1203 } | 1244 } |
1204 | 1245 |
1205 event_msg_->Clear(); | 1246 event_msg_->Clear(); |
1206 | 1247 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1264 | 1305 |
1265 event_msg_->set_type(audioproc::Event::CONFIG); | 1306 event_msg_->set_type(audioproc::Event::CONFIG); |
1266 event_msg_->mutable_config()->CopyFrom(config); | 1307 event_msg_->mutable_config()->CopyFrom(config); |
1267 | 1308 |
1268 RETURN_ON_ERR(WriteMessageToDebugFile()); | 1309 RETURN_ON_ERR(WriteMessageToDebugFile()); |
1269 return kNoError; | 1310 return kNoError; |
1270 } | 1311 } |
1271 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1312 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1272 | 1313 |
1273 } // namespace webrtc | 1314 } // namespace webrtc |
OLD | NEW |