| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 // view, it will seem that the device has just clogged and stopped requesting | 32 // view, it will seem that the device has just clogged and stopped requesting |
| 33 // data. | 33 // data. |
| 34 | 34 |
| 35 #include "media/audio/linux/alsa_output.h" | 35 #include "media/audio/linux/alsa_output.h" |
| 36 | 36 |
| 37 #include <algorithm> | 37 #include <algorithm> |
| 38 | 38 |
| 39 #include "base/bind.h" | 39 #include "base/bind.h" |
| 40 #include "base/debug/trace_event.h" | 40 #include "base/debug/trace_event.h" |
| 41 #include "base/logging.h" | 41 #include "base/logging.h" |
| 42 #include "base/message_loop/message_loop.h" | |
| 43 #include "base/stl_util.h" | 42 #include "base/stl_util.h" |
| 44 #include "base/time/time.h" | 43 #include "base/time/time.h" |
| 45 #include "media/audio/linux/alsa_util.h" | 44 #include "media/audio/linux/alsa_util.h" |
| 46 #include "media/audio/linux/alsa_wrapper.h" | 45 #include "media/audio/linux/alsa_wrapper.h" |
| 47 #include "media/audio/linux/audio_manager_linux.h" | 46 #include "media/audio/linux/audio_manager_linux.h" |
| 48 #include "media/base/channel_mixer.h" | 47 #include "media/base/channel_mixer.h" |
| 49 #include "media/base/data_buffer.h" | 48 #include "media/base/data_buffer.h" |
| 50 #include "media/base/seekable_buffer.h" | 49 #include "media/base/seekable_buffer.h" |
| 51 | 50 |
| 52 namespace media { | 51 namespace media { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 wrapper_(wrapper), | 151 wrapper_(wrapper), |
| 153 manager_(manager), | 152 manager_(manager), |
| 154 message_loop_(base::MessageLoop::current()), | 153 message_loop_(base::MessageLoop::current()), |
| 155 playback_handle_(NULL), | 154 playback_handle_(NULL), |
| 156 frames_per_packet_(packet_size_ / bytes_per_frame_), | 155 frames_per_packet_(packet_size_ / bytes_per_frame_), |
| 157 weak_factory_(this), | 156 weak_factory_(this), |
| 158 state_(kCreated), | 157 state_(kCreated), |
| 159 volume_(1.0f), | 158 volume_(1.0f), |
| 160 source_callback_(NULL), | 159 source_callback_(NULL), |
| 161 audio_bus_(AudioBus::Create(params)) { | 160 audio_bus_(AudioBus::Create(params)) { |
| 162 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); | 161 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread()); |
| 163 DCHECK_EQ(audio_bus_->frames() * bytes_per_frame_, packet_size_); | 162 DCHECK_EQ(audio_bus_->frames() * bytes_per_frame_, packet_size_); |
| 164 | 163 |
| 165 // Sanity check input values. | 164 // Sanity check input values. |
| 166 if (!params.IsValid()) { | 165 if (!params.IsValid()) { |
| 167 LOG(WARNING) << "Unsupported audio parameters."; | 166 LOG(WARNING) << "Unsupported audio parameters."; |
| 168 TransitionTo(kInError); | 167 TransitionTo(kInError); |
| 169 } | 168 } |
| 170 | 169 |
| 171 if (pcm_format_ == SND_PCM_FORMAT_UNKNOWN) { | 170 if (pcm_format_ == SND_PCM_FORMAT_UNKNOWN) { |
| 172 LOG(WARNING) << "Unsupported bits per sample: " << params.bits_per_sample(); | 171 LOG(WARNING) << "Unsupported bits per sample: " << params.bits_per_sample(); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 755 } |
| 757 | 756 |
| 758 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 757 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
| 759 // release ownership of the currently registered callback. | 758 // release ownership of the currently registered callback. |
| 760 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { | 759 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { |
| 761 DCHECK(IsOnAudioThread()); | 760 DCHECK(IsOnAudioThread()); |
| 762 source_callback_ = callback; | 761 source_callback_ = callback; |
| 763 } | 762 } |
| 764 | 763 |
| 765 } // namespace media | 764 } // namespace media |
| OLD | NEW |