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

Side by Side Diff: media/audio/audio_debug_recording_helper.cc

Issue 2885173002: Make AudioDebugFileWriter create its own file worker thread. (Closed)
Patch Set: Remove useless include Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_debug_recording_helper.h" 5 #include "media/audio/audio_debug_recording_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "media/audio/audio_debug_file_writer.h" 11 #include "media/audio/audio_debug_file_writer.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 AudioDebugRecordingHelper::AudioDebugRecordingHelper( 15 AudioDebugRecordingHelper::AudioDebugRecordingHelper(
16 const AudioParameters& params, 16 const AudioParameters& params,
17 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 17 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
18 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
19 base::OnceClosure on_destruction_closure) 18 base::OnceClosure on_destruction_closure)
20 : params_(params), 19 : params_(params),
21 recording_enabled_(0), 20 recording_enabled_(0),
22 task_runner_(std::move(task_runner)), 21 task_runner_(std::move(task_runner)),
23 file_task_runner_(std::move(file_task_runner)),
24 on_destruction_closure_(std::move(on_destruction_closure)), 22 on_destruction_closure_(std::move(on_destruction_closure)),
25 weak_factory_(this) {} 23 weak_factory_(this) {}
26 24
27 AudioDebugRecordingHelper::~AudioDebugRecordingHelper() { 25 AudioDebugRecordingHelper::~AudioDebugRecordingHelper() {
28 if (on_destruction_closure_) 26 if (on_destruction_closure_)
29 std::move(on_destruction_closure_).Run(); 27 std::move(on_destruction_closure_).Run();
30 } 28 }
31 29
32 void AudioDebugRecordingHelper::EnableDebugRecording( 30 void AudioDebugRecordingHelper::EnableDebugRecording(
33 const base::FilePath& file_name) { 31 const base::FilePath& file_name) {
34 DCHECK(task_runner_->BelongsToCurrentThread()); 32 DCHECK(task_runner_->BelongsToCurrentThread());
35 DCHECK(!debug_writer_); 33 DCHECK(!debug_writer_);
36 DCHECK(!file_name.empty()); 34 DCHECK(!file_name.empty());
37 35
38 debug_writer_ = CreateAudioDebugFileWriter(params_, file_task_runner_); 36 debug_writer_ = CreateAudioDebugFileWriter(params_);
39 debug_writer_->Start( 37 debug_writer_->Start(
40 file_name.AddExtension(debug_writer_->GetFileNameExtension())); 38 file_name.AddExtension(debug_writer_->GetFileNameExtension()));
41 39
42 base::subtle::NoBarrier_Store(&recording_enabled_, 1); 40 base::subtle::NoBarrier_Store(&recording_enabled_, 1);
43 } 41 }
44 42
45 void AudioDebugRecordingHelper::DisableDebugRecording() { 43 void AudioDebugRecordingHelper::DisableDebugRecording() {
46 DCHECK(task_runner_->BelongsToCurrentThread()); 44 DCHECK(task_runner_->BelongsToCurrentThread());
47 45
48 base::subtle::NoBarrier_Store(&recording_enabled_, 0); 46 base::subtle::NoBarrier_Store(&recording_enabled_, 0);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 84
87 void AudioDebugRecordingHelper::DoWrite(std::unique_ptr<media::AudioBus> data) { 85 void AudioDebugRecordingHelper::DoWrite(std::unique_ptr<media::AudioBus> data) {
88 DCHECK(task_runner_->BelongsToCurrentThread()); 86 DCHECK(task_runner_->BelongsToCurrentThread());
89 87
90 if (debug_writer_) 88 if (debug_writer_)
91 debug_writer_->Write(std::move(data)); 89 debug_writer_->Write(std::move(data));
92 } 90 }
93 91
94 std::unique_ptr<AudioDebugFileWriter> 92 std::unique_ptr<AudioDebugFileWriter>
95 AudioDebugRecordingHelper::CreateAudioDebugFileWriter( 93 AudioDebugRecordingHelper::CreateAudioDebugFileWriter(
96 const AudioParameters& params, 94 const AudioParameters& params) {
97 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) { 95 return base::MakeUnique<AudioDebugFileWriter>(params);
98 return base::MakeUnique<AudioDebugFileWriter>(params, file_task_runner);
99 } 96 }
100 97
101 } // namespace media 98 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_debug_recording_helper.h ('k') | media/audio/audio_debug_recording_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698