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

Unified Diff: media/audio/pulse/pulse_output.cc

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review (dalecurtis@ and maxmorin@). Created 3 years, 11 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: media/audio/pulse/pulse_output.cc
diff --git a/media/audio/pulse/pulse_output.cc b/media/audio/pulse/pulse_output.cc
index 5efa040c0d1b96a712a77cc309badbeef9db4f2a..f2b25c0b4c3ebe159895f40c366fb1d306c25ff3 100644
--- a/media/audio/pulse/pulse_output.cc
+++ b/media/audio/pulse/pulse_output.cc
@@ -7,9 +7,13 @@
#include <pulse/pulseaudio.h>
#include <stdint.h>
+#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
+#include "media/audio/audio_debug_recording_helper.h"
#include "media/audio/audio_device_description.h"
+#include "media/audio/audio_file_writer.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/pulse/pulse_util.h"
#include "media/base/audio_sample_types.h"
@@ -58,7 +62,10 @@ PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params,
pa_mainloop_(NULL),
pa_stream_(NULL),
volume_(1.0f),
- source_callback_(NULL) {
+ source_callback_(NULL),
+ debug_recording_helper_(base::MakeUnique<AudioDebugRecordingHelper>(
o1ka 2017/01/20 11:36:26 Set it to nullptr for non-webrtc-enabled builds?
Henrik Grunell 2017/01/26 10:25:09 Good point. That should be the right things to do.
+ manager,
+ manager_->GetTaskRunner())) {
CHECK(params_.IsValid());
audio_bus_ = AudioBus::Create(params_);
}
@@ -156,6 +163,11 @@ void PulseAudioOutputStream::FulfillWriteRequest(size_t requested_bytes) {
audio_bus_->frames(), reinterpret_cast<float*>(buffer));
} else {
memset(buffer, 0, bytes_to_fill);
+
+ // If we'll write the data to a debug file, also zero out the |audio_bus_|
+ // as it will be copied.
+ if (debug_recording_helper_->WillWrite())
+ audio_bus_->Zero();
}
if (pa_stream_write(pa_stream_, buffer, bytes_to_fill, NULL, 0LL,
@@ -168,6 +180,8 @@ void PulseAudioOutputStream::FulfillWriteRequest(size_t requested_bytes) {
// NOTE: As mentioned above, |bytes_remaining| may be negative after this.
bytes_remaining -= bytes_to_fill;
+ debug_recording_helper_->MaybeWrite(audio_bus_.get());
+
// Despite telling Pulse to only request certain buffer sizes, it will not
// always obey. In these cases we need to avoid back to back reads from
// the renderer as it won't have time to complete the request.
@@ -245,4 +259,13 @@ void PulseAudioOutputStream::GetVolume(double* volume) {
*volume = volume_;
}
+void PulseAudioOutputStream::EnableDebugRecording(
+ const base::FilePath& file_name) {
+ debug_recording_helper_->EnableDebugRecording(params_, file_name);
+}
+
+void PulseAudioOutputStream::DisableDebugRecording() {
+ debug_recording_helper_->DisableDebugRecording();
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698