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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Control through AudioManager. Compiles on Linux, works with PulseAudio. 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..ab66d43b8e5c6b37e422904e44b28aae96d64aa0 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>(
+ manager,
+ manager_->GetTaskRunner())) {
CHECK(params_.IsValid());
audio_bus_ = AudioBus::Create(params_);
}
@@ -156,8 +163,15 @@ 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();
}
+ debug_recording_helper_->MaybeWrite(audio_bus_.get());
Max Morin 2017/01/20 07:49:09 Move this below call to PA, to reduce risk of time
Henrik Grunell 2017/01/20 10:38:56 Good point. Done.
+
if (pa_stream_write(pa_stream_, buffer, bytes_to_fill, NULL, 0LL,
PA_SEEK_RELATIVE) < 0) {
if (source_callback_) {
@@ -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