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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 friend std::ostream& operator<<(std::ostream& os, InternalState); 116 friend std::ostream& operator<<(std::ostream& os, InternalState);
117 117
118 // Functions to get another packet from the data source and write it into the 118 // Functions to get another packet from the data source and write it into the
119 // ALSA device. 119 // ALSA device.
120 void BufferPacket(bool* source_exhausted); 120 void BufferPacket(bool* source_exhausted);
121 void WritePacket(); 121 void WritePacket();
122 void WriteTask(); 122 void WriteTask();
123 void ScheduleNextWrite(bool source_exhausted); 123 void ScheduleNextWrite(bool source_exhausted);
124 124
125 // Utility functions for talking with the ALSA API. 125 // Utility functions for talking with the ALSA API.
126 static uint32 FramesToMicros(uint32 frames, uint32 sample_rate); 126 static uint32 FramesToMicros(uint32 frames, uint32 samples_per_second);
127 static uint32 FramesToMillis(uint32 frames, uint32 sample_rate); 127 static uint32 FramesToMillis(uint32 frames, uint32 samples_per_second);
128 std::string FindDeviceForChannels(uint32 channels); 128 std::string FindDeviceForChannels(uint32 channels);
129 snd_pcm_sframes_t GetAvailableFrames(); 129 snd_pcm_sframes_t GetAvailableFrames();
130 snd_pcm_sframes_t GetCurrentDelay(); 130 snd_pcm_sframes_t GetCurrentDelay();
131 131
132 // Attempts to find the best matching linux audio device for the given number 132 // Attempts to find the best matching linux audio device for the given number
133 // of channels. This function will set |device_name_| and |should_downmix_|. 133 // of channels. This function will set |device_name_| and |should_downmix_|.
134 snd_pcm_t* AutoSelectDevice(uint32 latency); 134 snd_pcm_t* AutoSelectDevice(uint32 latency);
135 135
136 // Functions to safeguard state transitions. All changes to the object state 136 // Functions to safeguard state transitions. All changes to the object state
137 // should go through these functions. 137 // should go through these functions.
(...skipping 20 matching lines...) Expand all
158 158
159 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to 159 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to
160 // release ownership of the currently registered callback. 160 // release ownership of the currently registered callback.
161 void set_source_callback(AudioSourceCallback* callback); 161 void set_source_callback(AudioSourceCallback* callback);
162 162
163 // Configuration constants from the constructor. Referenceable by all threads 163 // Configuration constants from the constructor. Referenceable by all threads
164 // since they are constants. 164 // since they are constants.
165 const std::string requested_device_name_; 165 const std::string requested_device_name_;
166 const snd_pcm_format_t pcm_format_; 166 const snd_pcm_format_t pcm_format_;
167 const uint32 channels_; 167 const uint32 channels_;
168 const uint32 sample_rate_; 168 const uint32 samples_per_second_;
169 const uint32 bytes_per_sample_; 169 const uint32 bytes_per_sample_;
170 const uint32 bytes_per_frame_; 170 const uint32 bytes_per_frame_;
171 171
172 // Device configuration data. Populated after OpenTask() completes. 172 // Device configuration data. Populated after OpenTask() completes.
173 std::string device_name_; 173 std::string device_name_;
174 bool should_downmix_; 174 bool should_downmix_;
175 uint32 packet_size_; 175 uint32 packet_size_;
176 uint32 micros_per_packet_; 176 uint32 micros_per_packet_;
177 uint32 latency_micros_; 177 uint32 latency_micros_;
178 uint32 bytes_per_output_frame_; 178 uint32 bytes_per_output_frame_;
(...skipping 25 matching lines...) Expand all
204 204
205 AudioSourceCallback* source_callback_; 205 AudioSourceCallback* source_callback_;
206 206
207 DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream); 207 DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream);
208 }; 208 };
209 209
210 MEDIA_EXPORT std::ostream& operator<<(std::ostream& os, 210 MEDIA_EXPORT std::ostream& operator<<(std::ostream& os,
211 AlsaPcmOutputStream::InternalState); 211 AlsaPcmOutputStream::InternalState);
212 212
213 #endif // MEDIA_AUDIO_LINUX_ALSA_OUTPUT_H_ 213 #endif // MEDIA_AUDIO_LINUX_ALSA_OUTPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698