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

Side by Side Diff: media/audio/sounds/audio_stream_handler.cc

Issue 1453233002: Improve input handling for WaveAudioHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Correct typo Created 5 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sounds/audio_stream_handler.h" 5 #include "media/audio/sounds/audio_stream_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/cancelable_callback.h" 9 #include "base/cancelable_callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 }; 157 };
158 158
159 AudioStreamHandler::AudioStreamHandler(const base::StringPiece& wav_data) 159 AudioStreamHandler::AudioStreamHandler(const base::StringPiece& wav_data)
160 : wav_audio_(wav_data), 160 : wav_audio_(wav_data),
161 initialized_(false) { 161 initialized_(false) {
162 AudioManager* manager = AudioManager::Get(); 162 AudioManager* manager = AudioManager::Get();
163 if (!manager) { 163 if (!manager) {
164 LOG(ERROR) << "Can't get access to audio manager."; 164 LOG(ERROR) << "Can't get access to audio manager.";
165 return; 165 return;
166 } 166 }
167
168 if (!wav_audio_.is_valid()) {
169 LOG(ERROR) << "wav_audio handler is not valid";
170 return;
171 }
172
167 const AudioParameters params( 173 const AudioParameters params(
168 AudioParameters::AUDIO_PCM_LOW_LATENCY, 174 AudioParameters::AUDIO_PCM_LOW_LATENCY,
169 GuessChannelLayout(wav_audio_.num_channels()), wav_audio_.sample_rate(), 175 GuessChannelLayout(wav_audio_.num_channels()), wav_audio_.sample_rate(),
170 wav_audio_.bits_per_sample(), kDefaultFrameCount); 176 wav_audio_.bits_per_sample(), kDefaultFrameCount);
171 if (!params.IsValid()) { 177 if (!params.IsValid()) {
172 LOG(ERROR) << "Audio params are invalid."; 178 LOG(ERROR) << "Audio params are invalid.";
173 return; 179 return;
174 } 180 }
175 stream_.reset(new AudioStreamContainer(wav_audio_)); 181 stream_.reset(new AudioStreamContainer(wav_audio_));
176 initialized_ = true; 182 initialized_ = true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 g_observer_for_testing = observer; 221 g_observer_for_testing = observer;
216 } 222 }
217 223
218 // static 224 // static
219 void AudioStreamHandler::SetAudioSourceForTesting( 225 void AudioStreamHandler::SetAudioSourceForTesting(
220 AudioOutputStream::AudioSourceCallback* source) { 226 AudioOutputStream::AudioSourceCallback* source) {
221 g_audio_source_for_testing = source; 227 g_audio_source_for_testing = source;
222 } 228 }
223 229
224 } // namespace media 230 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698