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

Side by Side Diff: media/audio/linux/alsa_output.cc

Issue 9234066: Detect errors in audio output and report them upstream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
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 // THREAD SAFETY 5 // THREAD SAFETY
6 // 6 //
7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used
8 // from the audio thread. We DCHECK on this assumption whenever we can. 8 // from the audio thread. We DCHECK on this assumption whenever we can.
9 // 9 //
10 // SEMANTICS OF Close() 10 // SEMANTICS OF Close()
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 playback_handle_ = alsa_util::OpenPlaybackDevice(wrapper_, 261 playback_handle_ = alsa_util::OpenPlaybackDevice(wrapper_,
262 device_name_.c_str(), 262 device_name_.c_str(),
263 channels_, sample_rate_, 263 channels_, sample_rate_,
264 pcm_format_, 264 pcm_format_,
265 latency_micros_); 265 latency_micros_);
266 } 266 }
267 267
268 // Finish initializing the stream if the device was opened successfully. 268 // Finish initializing the stream if the device was opened successfully.
269 if (playback_handle_ == NULL) { 269 if (playback_handle_ == NULL) {
270 stop_stream_ = true; 270 stop_stream_ = true;
271 TransitionTo(kInError);
272 return false;
271 } else { 273 } else {
272 bytes_per_output_frame_ = should_downmix_ ? 2 * bytes_per_sample_ : 274 bytes_per_output_frame_ = should_downmix_ ? 2 * bytes_per_sample_ :
273 bytes_per_frame_; 275 bytes_per_frame_;
274 uint32 output_packet_size = frames_per_packet_ * bytes_per_output_frame_; 276 uint32 output_packet_size = frames_per_packet_ * bytes_per_output_frame_;
275 buffer_.reset(new media::SeekableBuffer(0, output_packet_size)); 277 buffer_.reset(new media::SeekableBuffer(0, output_packet_size));
276 278
277 // Get alsa buffer size. 279 // Get alsa buffer size.
278 snd_pcm_uframes_t buffer_size; 280 snd_pcm_uframes_t buffer_size;
279 snd_pcm_uframes_t period_size; 281 snd_pcm_uframes_t period_size;
280 int error = wrapper_->PcmGetParams(playback_handle_, &buffer_size, 282 int error = wrapper_->PcmGetParams(playback_handle_, &buffer_size,
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 if (source_callback_) 841 if (source_callback_)
840 source_callback_->OnError(this, code); 842 source_callback_->OnError(this, code);
841 } 843 }
842 844
843 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to 845 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to
844 // release ownership of the currently registered callback. 846 // release ownership of the currently registered callback.
845 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { 847 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) {
846 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); 848 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
847 source_callback_ = callback; 849 source_callback_ = callback;
848 } 850 }
OLDNEW
« no previous file with comments | « content/renderer/renderer_webaudiodevice_impl.cc ('k') | media/audio/linux/alsa_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698