OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/audio_modem/audio_recorder_impl.h" | 5 #include "components/audio_modem/audio_recorder_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 params.set_effects(media::AudioParameters::NO_EFFECTS); | 107 params.set_effects(media::AudioParameters::NO_EFFECTS); |
108 } | 108 } |
109 | 109 |
110 total_buffer_frames_ = kProcessIntervalMs * params.sample_rate() / 1000; | 110 total_buffer_frames_ = kProcessIntervalMs * params.sample_rate() / 1000; |
111 buffer_ = media::AudioBus::Create(params.channels(), total_buffer_frames_); | 111 buffer_ = media::AudioBus::Create(params.channels(), total_buffer_frames_); |
112 buffer_frame_index_ = 0; | 112 buffer_frame_index_ = 0; |
113 | 113 |
114 stream_ = input_stream_for_testing_ | 114 stream_ = input_stream_for_testing_ |
115 ? input_stream_for_testing_.get() | 115 ? input_stream_for_testing_.get() |
116 : media::AudioManager::Get()->MakeAudioInputStream( | 116 : media::AudioManager::Get()->MakeAudioInputStream( |
117 params, media::AudioDeviceDescription::kDefaultDeviceId); | 117 params, media::AudioDeviceDescription::kDefaultDeviceId, |
| 118 media::AudioManager::LogCallback()); |
118 | 119 |
119 if (!stream_ || !stream_->Open()) { | 120 if (!stream_ || !stream_->Open()) { |
120 LOG(ERROR) << "Failed to open an input stream."; | 121 LOG(ERROR) << "Failed to open an input stream."; |
121 if (stream_) { | 122 if (stream_) { |
122 stream_->Close(); | 123 stream_->Close(); |
123 stream_ = nullptr; | 124 stream_ = nullptr; |
124 } | 125 } |
125 return; | 126 return; |
126 } | 127 } |
127 stream_->SetVolume(stream_->GetMaxVolume()); | 128 stream_->SetVolume(stream_->GetMaxVolume()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 194 |
194 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { | 195 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { |
195 LOG(ERROR) << "Error during sound recording."; | 196 LOG(ERROR) << "Error during sound recording."; |
196 media::AudioManager::Get()->GetTaskRunner()->PostTask( | 197 media::AudioManager::Get()->GetTaskRunner()->PostTask( |
197 FROM_HERE, | 198 FROM_HERE, |
198 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, | 199 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, |
199 base::Unretained(this))); | 200 base::Unretained(this))); |
200 } | 201 } |
201 | 202 |
202 } // namespace audio_modem | 203 } // namespace audio_modem |
OLD | NEW |