OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/fake_audio_input_stream.h" | 5 #include "media/audio/fake_audio_input_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "media/audio/audio_manager_base.h" | 14 #include "media/audio/audio_manager_base.h" |
14 #include "media/audio/simple_sources.h" | 15 #include "media/audio/simple_sources.h" |
15 #include "media/base/audio_bus.h" | 16 #include "media/base/audio_bus.h" |
16 #include "media/base/media_switches.h" | 17 #include "media/base/media_switches.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 AudioInputStream* FakeAudioInputStream::MakeFakeStream( | 21 AudioInputStream* FakeAudioInputStream::MakeFakeStream( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 if (!audio_source_) | 98 if (!audio_source_) |
98 audio_source_ = ChooseSource(); | 99 audio_source_ = ChooseSource(); |
99 | 100 |
100 const int kNoDelay = 0; | 101 const int kNoDelay = 0; |
101 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay, 0); | 102 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay, 0); |
102 callback_->OnData(this, audio_bus_.get(), 0, 1.0); | 103 callback_->OnData(this, audio_bus_.get(), 0, 1.0); |
103 } | 104 } |
104 | 105 |
105 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; | 106 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; |
106 scoped_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { | 107 std::unique_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { |
107 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 108 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
108 | 109 |
109 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 110 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
110 switches::kUseFileForFakeAudioCapture)) { | 111 switches::kUseFileForFakeAudioCapture)) { |
111 base::FilePath path_to_wav_file = | 112 base::FilePath path_to_wav_file = |
112 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 113 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
113 switches::kUseFileForFakeAudioCapture); | 114 switches::kUseFileForFakeAudioCapture); |
114 CHECK(!path_to_wav_file.empty()) | 115 CHECK(!path_to_wav_file.empty()) |
115 << "You must pass the file to use as argument to --" | 116 << "You must pass the file to use as argument to --" |
116 << switches::kUseFileForFakeAudioCapture << "."; | 117 << switches::kUseFileForFakeAudioCapture << "."; |
117 | 118 |
118 return make_scoped_ptr(new FileSource(params_, path_to_wav_file)); | 119 return base::WrapUnique(new FileSource(params_, path_to_wav_file)); |
119 } | 120 } |
120 return make_scoped_ptr(new BeepingSource(params_)); | 121 return base::WrapUnique(new BeepingSource(params_)); |
121 } | 122 } |
122 | 123 |
123 void FakeAudioInputStream::BeepOnce() { | 124 void FakeAudioInputStream::BeepOnce() { |
124 BeepingSource::BeepOnce(); | 125 BeepingSource::BeepOnce(); |
125 } | 126 } |
126 | 127 |
127 } // namespace media | 128 } // namespace media |
OLD | NEW |