Reland "Added option to specify a maximum file size when recording an AEC dump.", commit ae2c5ad12afc8cc29fe9c59dea432b697b871a87.
The revert of the original CL was commit 36d4c545007129446e551c45c17b25377dce89a4. Original review: https://codereview.webrtc.org/1413483003/ The original CL changes a function on audio_processing.h that is used by Chrome, this CL adds back the old function. TBR=glaznev@webrtc.org, henrik.lundin@webrtc.org, solenberg@google.com, henrikg@webrtc.org, perkj@webrtc.org BUG=webrtc:4741 Committed: https://crrev.com/f4f5cb09277d5ef6aeac8341e5f54a055867803a Cr-Commit-Position: refs/heads/master@{#11093} Review URL: https://codereview.webrtc.org/1540103002 Cr-Commit-Position: refs/heads/master@{#11267}
This commit is contained in:
@ -647,6 +647,7 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
|
||||
++i)
|
||||
msg->add_output_channel(dest[i], channel_size);
|
||||
RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
|
||||
&debug_dump_.num_bytes_left_for_log_,
|
||||
&crit_debug_, &debug_dump_.capture));
|
||||
}
|
||||
#endif
|
||||
@ -734,6 +735,7 @@ int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
|
||||
sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
|
||||
msg->set_output_data(frame->data_, data_size);
|
||||
RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
|
||||
&debug_dump_.num_bytes_left_for_log_,
|
||||
&crit_debug_, &debug_dump_.capture));
|
||||
}
|
||||
#endif
|
||||
@ -901,6 +903,7 @@ int AudioProcessingImpl::AnalyzeReverseStreamLocked(
|
||||
i < formats_.api_format.reverse_input_stream().num_channels(); ++i)
|
||||
msg->add_channel(src[i], channel_size);
|
||||
RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
|
||||
&debug_dump_.num_bytes_left_for_log_,
|
||||
&crit_debug_, &debug_dump_.render));
|
||||
}
|
||||
#endif
|
||||
@ -969,6 +972,7 @@ int AudioProcessingImpl::AnalyzeReverseStream(AudioFrame* frame) {
|
||||
sizeof(int16_t) * frame->samples_per_channel_ * frame->num_channels_;
|
||||
msg->set_data(frame->data_, data_size);
|
||||
RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
|
||||
&debug_dump_.num_bytes_left_for_log_,
|
||||
&crit_debug_, &debug_dump_.render));
|
||||
}
|
||||
#endif
|
||||
@ -1054,7 +1058,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) {
|
||||
// Run in a single-threaded manner.
|
||||
rtc::CritScope cs_render(&crit_render_);
|
||||
rtc::CritScope cs_capture(&crit_capture_);
|
||||
@ -1065,6 +1070,7 @@ int AudioProcessingImpl::StartDebugRecording(
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
debug_dump_.num_bytes_left_for_log_ = max_log_size_bytes;
|
||||
// Stop any ongoing recording.
|
||||
if (debug_dump_.debug_file->Open()) {
|
||||
if (debug_dump_.debug_file->CloseFile() == -1) {
|
||||
@ -1085,7 +1091,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) {
|
||||
// Run in a single-threaded manner.
|
||||
rtc::CritScope cs_render(&crit_render_);
|
||||
rtc::CritScope cs_capture(&crit_capture_);
|
||||
@ -1095,6 +1102,8 @@ int AudioProcessingImpl::StartDebugRecording(FILE* handle) {
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
debug_dump_.num_bytes_left_for_log_ = max_log_size_bytes;
|
||||
|
||||
// Stop any ongoing recording.
|
||||
if (debug_dump_.debug_file->Open()) {
|
||||
if (debug_dump_.debug_file->CloseFile() == -1) {
|
||||
@ -1120,7 +1129,7 @@ int AudioProcessingImpl::StartDebugRecordingForPlatformFile(
|
||||
rtc::CritScope cs_render(&crit_render_);
|
||||
rtc::CritScope cs_capture(&crit_capture_);
|
||||
FILE* stream = rtc::FdopenPlatformFileForWriting(handle);
|
||||
return StartDebugRecording(stream);
|
||||
return StartDebugRecording(stream, -1);
|
||||
}
|
||||
|
||||
int AudioProcessingImpl::StopDebugRecording() {
|
||||
@ -1416,6 +1425,7 @@ void AudioProcessingImpl::UpdateHistogramsOnCallEnd() {
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
int AudioProcessingImpl::WriteMessageToDebugFile(
|
||||
FileWrapper* debug_file,
|
||||
int64_t* filesize_limit_bytes,
|
||||
rtc::CriticalSection* crit_debug,
|
||||
ApmDebugDumpThreadState* debug_state) {
|
||||
int32_t size = debug_state->event_msg->ByteSize();
|
||||
@ -1433,7 +1443,19 @@ int AudioProcessingImpl::WriteMessageToDebugFile(
|
||||
|
||||
{
|
||||
// Ensure atomic writes of the message.
|
||||
rtc::CritScope cs_capture(crit_debug);
|
||||
rtc::CritScope cs_debug(crit_debug);
|
||||
|
||||
RTC_DCHECK(debug_file->Open());
|
||||
// Update the byte counter.
|
||||
if (*filesize_limit_bytes >= 0) {
|
||||
*filesize_limit_bytes -=
|
||||
(sizeof(int32_t) + debug_state->event_str.length());
|
||||
if (*filesize_limit_bytes < 0) {
|
||||
// Not enough bytes are left to write this message, so stop logging.
|
||||
debug_file->CloseFile();
|
||||
return kNoError;
|
||||
}
|
||||
}
|
||||
// Write message preceded by its size.
|
||||
if (!debug_file->Write(&size, sizeof(int32_t))) {
|
||||
return kFileError;
|
||||
@ -1468,6 +1490,7 @@ int AudioProcessingImpl::WriteInitMessage() {
|
||||
// debug_dump_.capture.event_msg.
|
||||
|
||||
RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
|
||||
&debug_dump_.num_bytes_left_for_log_,
|
||||
&crit_debug_, &debug_dump_.capture));
|
||||
return kNoError;
|
||||
}
|
||||
@ -1520,6 +1543,7 @@ int AudioProcessingImpl::WriteConfigMessage(bool forced) {
|
||||
debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
|
||||
|
||||
RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
|
||||
&debug_dump_.num_bytes_left_for_log_,
|
||||
&crit_debug_, &debug_dump_.capture));
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user