OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // ALSA device. | 135 // ALSA device. |
136 void BufferPacket(bool* source_exhausted); | 136 void BufferPacket(bool* source_exhausted); |
137 void WritePacket(); | 137 void WritePacket(); |
138 void WriteTask(); | 138 void WriteTask(); |
139 void ScheduleNextWrite(bool source_exhausted); | 139 void ScheduleNextWrite(bool source_exhausted); |
140 | 140 |
141 // Utility functions for talking with the ALSA API. | 141 // Utility functions for talking with the ALSA API. |
142 static uint32 FramesToMicros(uint32 frames, uint32 sample_rate); | 142 static uint32 FramesToMicros(uint32 frames, uint32 sample_rate); |
143 static uint32 FramesToMillis(uint32 frames, uint32 sample_rate); | 143 static uint32 FramesToMillis(uint32 frames, uint32 sample_rate); |
144 std::string FindDeviceForChannels(uint32 channels); | 144 std::string FindDeviceForChannels(uint32 channels); |
145 snd_pcm_t* OpenDevice(const std::string& device_name, | |
146 uint32 channels, | |
147 uint32 latency); | |
148 bool CloseDevice(snd_pcm_t* handle); | |
149 snd_pcm_sframes_t GetAvailableFrames(); | 145 snd_pcm_sframes_t GetAvailableFrames(); |
150 | 146 |
151 // Attempts to find the best matching linux audio device for the given number | 147 // Attempts to find the best matching linux audio device for the given number |
152 // of channels. This function will set |device_name_| and |should_downmix_|. | 148 // of channels. This function will set |device_name_| and |should_downmix_|. |
153 snd_pcm_t* AutoSelectDevice(uint32 latency); | 149 snd_pcm_t* AutoSelectDevice(uint32 latency); |
154 | 150 |
155 // Thread-asserting accessors for member variables. | 151 // Thread-asserting accessors for member variables. |
156 AudioManagerLinux* manager(); | 152 AudioManagerLinux* manager(); |
157 | 153 |
158 // Struct holding all mutable the data that must be shared by the | 154 // Struct holding all mutable the data that must be shared by the |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 MessageLoop* client_thread_loop_; | 239 MessageLoop* client_thread_loop_; |
244 | 240 |
245 // The message loop responsible for querying the data source, and writing to | 241 // The message loop responsible for querying the data source, and writing to |
246 // the output device. | 242 // the output device. |
247 MessageLoop* message_loop_; | 243 MessageLoop* message_loop_; |
248 | 244 |
249 DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream); | 245 DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream); |
250 }; | 246 }; |
251 | 247 |
252 #endif // MEDIA_AUDIO_LINUX_ALSA_OUTPUT_H_ | 248 #endif // MEDIA_AUDIO_LINUX_ALSA_OUTPUT_H_ |
OLD | NEW |