| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // The AlsaPcmOutputStream object's internal state is accessed by two threads: | 7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: |
| 8 // | 8 // |
| 9 // client thread - creates the object and calls the public APIs. | 9 // client thread - creates the object and calls the public APIs. |
| 10 // message loop thread - executes all the internal tasks including querying | 10 // message loop thread - executes all the internal tasks including querying |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 bytes_per_frame_(channels_ * bits_per_sample / 8), | 160 bytes_per_frame_(channels_ * bits_per_sample / 8), |
| 161 stop_stream_(false), | 161 stop_stream_(false), |
| 162 wrapper_(wrapper), | 162 wrapper_(wrapper), |
| 163 playback_handle_(NULL), | 163 playback_handle_(NULL), |
| 164 source_callback_(NULL), | 164 source_callback_(NULL), |
| 165 frames_per_packet_(0), | 165 frames_per_packet_(0), |
| 166 client_thread_loop_(MessageLoop::current()), | 166 client_thread_loop_(MessageLoop::current()), |
| 167 message_loop_(message_loop) { | 167 message_loop_(message_loop) { |
| 168 | 168 |
| 169 // Sanity check input values. | 169 // Sanity check input values. |
| 170 // TODO(ajwong): Just try what happens if we allow non 2-channel audio. | 170 // |
| 171 if (channels_ != 2) { | 171 // TODO(scherkus): ALSA works fine if you pass in multichannel audio, however |
| 172 LOG(WARNING) << "Only 2-channel audio is supported right now."; | 172 // it seems to be mapped to the wrong channels. We may have to do some |
| 173 // channel swizzling from decoder output to ALSA's preferred multichannel |
| 174 // format. |
| 175 if (channels_ != 1 && channels_ != 2) { |
| 176 LOG(WARNING) << "Only 1 and 2 channel audio is supported right now."; |
| 173 shared_data_.TransitionTo(kInError); | 177 shared_data_.TransitionTo(kInError); |
| 174 } | 178 } |
| 175 | 179 |
| 176 if (AudioManager::AUDIO_PCM_LINEAR != format) { | 180 if (AudioManager::AUDIO_PCM_LINEAR != format) { |
| 177 LOG(WARNING) << "Only linear PCM supported."; | 181 LOG(WARNING) << "Only linear PCM supported."; |
| 178 shared_data_.TransitionTo(kInError); | 182 shared_data_.TransitionTo(kInError); |
| 179 } | 183 } |
| 180 | 184 |
| 181 if (pcm_format_ == SND_PCM_FORMAT_UNKNOWN) { | 185 if (pcm_format_ == SND_PCM_FORMAT_UNKNOWN) { |
| 182 LOG(WARNING) << "Unsupported bits per sample: " << bits_per_sample; | 186 LOG(WARNING) << "Unsupported bits per sample: " << bits_per_sample; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 601 |
| 598 float AlsaPcmOutputStream::SharedData::volume() { | 602 float AlsaPcmOutputStream::SharedData::volume() { |
| 599 AutoLock l(lock_); | 603 AutoLock l(lock_); |
| 600 return volume_; | 604 return volume_; |
| 601 } | 605 } |
| 602 | 606 |
| 603 void AlsaPcmOutputStream::SharedData::set_volume(float v) { | 607 void AlsaPcmOutputStream::SharedData::set_volume(float v) { |
| 604 AutoLock l(lock_); | 608 AutoLock l(lock_); |
| 605 volume_ = v; | 609 volume_ = v; |
| 606 } | 610 } |
| OLD | NEW |