Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1900)

Unified Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1413483003: Added option to specify a maximum file size when recording an AEC dump. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Initial version Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/audio_processing_impl.cc
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index f3ee0a399d54eaefad5020a550816051c421d0eb..743c46368fb991131def9283279b44330106a88d 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -194,6 +194,7 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
debug_file_(FileWrapper::Create()),
event_msg_(new audioproc::Event()),
+ nr_bytes_left_for_log(-1),
#endif
api_format_({{{kSampleRate16kHz, 1, false},
{kSampleRate16kHz, 1, false},
@@ -930,6 +931,21 @@ int AudioProcessingImpl::StartDebugRecording(
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
}
+int AudioProcessingImpl::StartDebugRecording(
+ const char filename[AudioProcessing::kMaxFilenameSize],
+ int max_log_size_bytes) {
+#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
+ nr_bytes_left_for_log = max_log_size_bytes;
+ int ret_val = StartDebugRecording(filename);
+ if (ret_val != kNoError) {
+ 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
+ }
+ return ret_val;
+#else
+ return kUnsupportedFunctionError;
+#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
+}
+
int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
CriticalSectionScoped crit_scoped(crit_);
@@ -957,6 +973,21 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
}
+int AudioProcessingImpl::StartDebugRecording(FILE* handle,
+ int max_log_size_bytes) {
+#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
+ RTC_DCHECK_GT(max_log_size_bytes, 0);
+ nr_bytes_left_for_log = max_log_size_bytes;
+ int ret_val = StartDebugRecording(handle);
+ if (ret_val != kNoError) {
+ nr_bytes_left_for_log = -1;
+ }
+ return ret_val;
+#else
+ return kUnsupportedFunctionError;
+#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
+}
+
int AudioProcessingImpl::StartDebugRecordingForPlatformFile(
rtc::PlatformFile handle) {
FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
@@ -1194,6 +1225,16 @@ int AudioProcessingImpl::WriteMessageToDebugFile() {
return kUnspecifiedError;
}
+ if (nr_bytes_left_for_log >= 0) {
+ 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
+ if (nr_bytes_left_for_log < 0) {
+ // Not enough bytes are left to write this message, so stop logging.
+ nr_bytes_left_for_log = -1;
+ 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
+ return kUnspecifiedError;
+ }
+ }
+
// Write message preceded by its size.
if (!debug_file_->Write(&size, sizeof(int32_t))) {
return kFileError;

Powered by Google App Engine
This is Rietveld 408576698