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

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: Processed first batch of reviews. Created 5 years, 1 month 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..d1c474a15168765a59c4bb4bb2e23750c6660914 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},
@@ -901,7 +902,8 @@ int AudioProcessingImpl::delay_offset_ms() const {
}
int AudioProcessingImpl::StartDebugRecording(
- const char filename[AudioProcessing::kMaxFilenameSize]) {
+ const char filename[AudioProcessing::kMaxFilenameSize],
+ int64_t max_log_size_bytes) {
CriticalSectionScoped crit_scoped(crit_);
static_assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize, "");
@@ -910,13 +912,8 @@ int AudioProcessingImpl::StartDebugRecording(
}
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
+ nr_bytes_left_for_log = max_log_size_bytes;
// Stop any ongoing recording.
- if (debug_file_->Open()) {
- if (debug_file_->CloseFile() == -1) {
- return kFileError;
- }
- }
-
if (debug_file_->OpenFile(filename, false) == -1) {
debug_file_->CloseFile();
return kFileError;
@@ -930,7 +927,8 @@ int AudioProcessingImpl::StartDebugRecording(
#endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
}
-int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
+int AudioProcessingImpl::StartDebugRecording(FILE* handle,
+ int64_t max_log_size_bytes) {
CriticalSectionScoped crit_scoped(crit_);
if (handle == NULL) {
@@ -938,6 +936,8 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
}
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
+ nr_bytes_left_for_log = max_log_size_bytes;
+
// Stop any ongoing recording.
if (debug_file_->Open()) {
if (debug_file_->CloseFile() == -1) {
@@ -960,7 +960,7 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
int AudioProcessingImpl::StartDebugRecordingForPlatformFile(
rtc::PlatformFile handle) {
FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
- return StartDebugRecording(stream);
+ return StartDebugRecording(stream, -1);
}
int AudioProcessingImpl::StopDebugRecording() {
@@ -1181,6 +1181,7 @@ void AudioProcessingImpl::UpdateHistogramsOnCallEnd() {
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
int AudioProcessingImpl::WriteMessageToDebugFile() {
+ RTC_DCHECK(debug_file_->Open());
int32_t size = event_msg_->ByteSize();
if (size <= 0) {
return kUnspecifiedError;
@@ -1194,6 +1195,15 @@ int AudioProcessingImpl::WriteMessageToDebugFile() {
return kUnspecifiedError;
}
+ if (nr_bytes_left_for_log >= 0) {
+ nr_bytes_left_for_log -= (sizeof(int32_t) + event_str_.length());
+ if (nr_bytes_left_for_log < 0) {
+ // Not enough bytes are left to write this message, so stop logging.
+ debug_file_->CloseFile();
+ 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