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()); | |
119 | 118 |
120 if (!stream_ || !stream_->Open()) { | 119 if (!stream_ || !stream_->Open()) { |
121 LOG(ERROR) << "Failed to open an input stream."; | 120 LOG(ERROR) << "Failed to open an input stream."; |
122 if (stream_) { | 121 if (stream_) { |
123 stream_->Close(); | 122 stream_->Close(); |
124 stream_ = nullptr; | 123 stream_ = nullptr; |
125 } | 124 } |
126 return; | 125 return; |
127 } | 126 } |
128 stream_->SetVolume(stream_->GetMaxVolume()); | 127 stream_->SetVolume(stream_->GetMaxVolume()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 193 |
195 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { | 194 void AudioRecorderImpl::OnError(media::AudioInputStream* /* stream */) { |
196 LOG(ERROR) << "Error during sound recording."; | 195 LOG(ERROR) << "Error during sound recording."; |
197 media::AudioManager::Get()->GetTaskRunner()->PostTask( | 196 media::AudioManager::Get()->GetTaskRunner()->PostTask( |
198 FROM_HERE, | 197 FROM_HERE, |
199 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, | 198 base::Bind(&AudioRecorderImpl::StopAndCloseOnAudioThread, |
200 base::Unretained(this))); | 199 base::Unretained(this))); |
201 } | 200 } |
202 | 201 |
203 } // namespace audio_modem | 202 } // namespace audio_modem |
OLD | NEW |