| OLD | NEW |
| 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 // Creates an output stream based on the ALSA PCM interface. | 5 // Creates an output stream based on the ALSA PCM interface. |
| 6 // | 6 // |
| 7 // On device write failure, the stream will move itself to an invalid state. | 7 // On device write failure, the stream will move itself to an invalid state. |
| 8 // No more data will be pulled from the data source, or written to the device. | 8 // No more data will be pulled from the data source, or written to the device. |
| 9 // All calls to public API functions will either no-op themselves, or return an | 9 // All calls to public API functions will either no-op themselves, or return an |
| 10 // error if possible. Specifically, If the stream is in an error state, Open() | 10 // error if possible. Specifically, If the stream is in an error state, Open() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include <stdint.h> | 25 #include <stdint.h> |
| 26 | 26 |
| 27 #include <memory> | 27 #include <memory> |
| 28 #include <string> | 28 #include <string> |
| 29 | 29 |
| 30 #include "base/compiler_specific.h" | 30 #include "base/compiler_specific.h" |
| 31 #include "base/gtest_prod_util.h" | 31 #include "base/gtest_prod_util.h" |
| 32 #include "base/macros.h" | 32 #include "base/macros.h" |
| 33 #include "base/memory/ref_counted.h" | 33 #include "base/memory/ref_counted.h" |
| 34 #include "base/memory/weak_ptr.h" | 34 #include "base/memory/weak_ptr.h" |
| 35 #include "base/sequence_checker.h" |
| 35 #include "base/single_thread_task_runner.h" | 36 #include "base/single_thread_task_runner.h" |
| 36 #include "base/threading/non_thread_safe.h" | |
| 37 #include "base/time/tick_clock.h" | 37 #include "base/time/tick_clock.h" |
| 38 #include "base/time/time.h" | 38 #include "base/time/time.h" |
| 39 #include "media/audio/audio_io.h" | 39 #include "media/audio/audio_io.h" |
| 40 #include "media/base/audio_parameters.h" | 40 #include "media/base/audio_parameters.h" |
| 41 | 41 |
| 42 namespace media { | 42 namespace media { |
| 43 | 43 |
| 44 class AlsaWrapper; | 44 class AlsaWrapper; |
| 45 class AudioManagerBase; | 45 class AudioManagerBase; |
| 46 class ChannelMixer; | 46 class ChannelMixer; |
| 47 class SeekableBuffer; | 47 class SeekableBuffer; |
| 48 | 48 |
| 49 class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream, | 49 class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream { |
| 50 public base::NonThreadSafe { | |
| 51 public: | 50 public: |
| 52 // String for the generic "default" ALSA device that has the highest | 51 // String for the generic "default" ALSA device that has the highest |
| 53 // compatibility and chance of working. | 52 // compatibility and chance of working. |
| 54 static const char kDefaultDevice[]; | 53 static const char kDefaultDevice[]; |
| 55 | 54 |
| 56 // Pass this to the AlsaPcmOutputStream if you want to attempt auto-selection | 55 // Pass this to the AlsaPcmOutputStream if you want to attempt auto-selection |
| 57 // of the audio device. | 56 // of the audio device. |
| 58 static const char kAutoSelectDevice[]; | 57 static const char kAutoSelectDevice[]; |
| 59 | 58 |
| 60 // Prefix for device names to enable ALSA library resampling. | 59 // Prefix for device names to enable ALSA library resampling. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 206 |
| 208 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 207 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
| 209 std::unique_ptr<AudioBus> audio_bus_; | 208 std::unique_ptr<AudioBus> audio_bus_; |
| 210 | 209 |
| 211 // Channel mixer and temporary bus for the final mixed channel data. | 210 // Channel mixer and temporary bus for the final mixed channel data. |
| 212 std::unique_ptr<ChannelMixer> channel_mixer_; | 211 std::unique_ptr<ChannelMixer> channel_mixer_; |
| 213 std::unique_ptr<AudioBus> mixed_audio_bus_; | 212 std::unique_ptr<AudioBus> mixed_audio_bus_; |
| 214 | 213 |
| 215 std::unique_ptr<base::TickClock> tick_clock_; | 214 std::unique_ptr<base::TickClock> tick_clock_; |
| 216 | 215 |
| 216 SEQUENCE_CHECKER(sequence_checker_); |
| 217 |
| 217 // Allows us to run tasks on the AlsaPcmOutputStream instance which are | 218 // Allows us to run tasks on the AlsaPcmOutputStream instance which are |
| 218 // bound by its lifetime. | 219 // bound by its lifetime. |
| 219 // NOTE: Weak pointers must be invalidated before all other member variables. | 220 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 220 base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_; | 221 base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_; |
| 221 | 222 |
| 222 DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream); | 223 DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream); |
| 223 }; | 224 }; |
| 224 | 225 |
| 225 MEDIA_EXPORT std::ostream& operator<<(std::ostream& os, | 226 MEDIA_EXPORT std::ostream& operator<<(std::ostream& os, |
| 226 AlsaPcmOutputStream::InternalState); | 227 AlsaPcmOutputStream::InternalState); |
| 227 | 228 |
| 228 }; // namespace media | 229 }; // namespace media |
| 229 | 230 |
| 230 #endif // MEDIA_AUDIO_ALSA_ALSA_OUTPUT_H_ | 231 #endif // MEDIA_AUDIO_ALSA_ALSA_OUTPUT_H_ |
| OLD | NEW |