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

Side by Side Diff: media/audio/audio_controller.h

Issue 2861010: Some fixups for AudioController and unit tests (Closed)
Patch Set: fixes Created 10 years, 6 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
« no previous file with comments | « no previous file | media/audio/audio_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef MEDIA_AUDIO_AUDIO_CONTROLLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_CONTROLLER_H_
6 #define MEDIA_AUDIO_AUDIO_CONTROLLER_H_ 6 #define MEDIA_AUDIO_AUDIO_CONTROLLER_H_
7 7
8 #include "base/lock.h" 8 #include "base/lock.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Factory method for creating an AudioController, returns NULL if failed. 100 // Factory method for creating an AudioController, returns NULL if failed.
101 // If successful, an audio controller thread is created. The audio device 101 // If successful, an audio controller thread is created. The audio device
102 // will be created on the audio controller thread and when that is done 102 // will be created on the audio controller thread and when that is done
103 // event handler will receive a OnCreated() call. 103 // event handler will receive a OnCreated() call.
104 static scoped_refptr<AudioController> Create( 104 static scoped_refptr<AudioController> Create(
105 EventHandler* event_handler, 105 EventHandler* event_handler,
106 AudioManager::Format format, // Format of the stream. 106 AudioManager::Format format, // Format of the stream.
107 int channels, // Number of channels. 107 int channels, // Number of channels.
108 int sample_rate, // Sampling frequency/rate. 108 int sample_rate, // Sampling frequency/rate.
109 int bits_per_sample, // Number of bits per sample. 109 int bits_per_sample, // Number of bits per sample.
110 int hardware_buffer_size, // Size of the hardware buffer. 110 uint32 hardware_buffer_size, // Size of the hardware buffer.
111 111
112 // Soft limit for buffer capacity in this controller. This parameter 112 // Soft limit for buffer capacity in this controller. This parameter
113 // is used only in regular latency mode. 113 // is used only in regular latency mode.
114 uint32 buffer_capacity); 114 uint32 buffer_capacity);
115 115
116 // Factory method for creating a low latency audio stream. 116 // Factory method for creating a low latency audio stream.
117 static scoped_refptr<AudioController> CreateLowLatency( 117 static scoped_refptr<AudioController> CreateLowLatency(
118 EventHandler* event_handler, 118 EventHandler* event_handler,
119 AudioManager::Format format, // Format of the stream. 119 AudioManager::Format format, // Format of the stream.
120 int channels, // Number of channels. 120 int channels, // Number of channels.
121 int sample_rate, // Sampling frequency/rate. 121 int sample_rate, // Sampling frequency/rate.
122 int bits_per_sample, // Number of bits per sample. 122 int bits_per_sample, // Number of bits per sample.
123 int hardware_buffer_size, // Size of the hardware buffer. 123 uint32 hardware_buffer_size, // Size of the hardware buffer.
124 124
125 // External synchronous reader for audio controller. 125 // External synchronous reader for audio controller.
126 SyncReader* sync_reader); 126 SyncReader* sync_reader);
127 127
128 // Methods to control playback of the stream. 128 // Methods to control playback of the stream.
129 129
130 // Starts the playback of this audio output stream. 130 // Starts the playback of this audio output stream.
131 void Play(); 131 void Play();
132 132
133 // Pause this audio output stream. 133 // Pause this audio output stream.
134 void Pause(); 134 void Pause();
135 135
136 // Discard all audio data buffered in this output stream. This method only 136 // Discard all audio data buffered in this output stream. This method only
137 // has effect when the stream is paused. 137 // has effect when the stream is paused.
138 void Flush(); 138 void Flush();
139 139
140 // Closes the audio output stream and shutdown the audio controller thread. 140 // Closes the audio output stream and shutdown the audio controller thread.
141 // This method returns only after all operations are completed. This 141 // This method returns only after all operations are completed. This
142 // controller cannot be used after this method is called. 142 // controller cannot be used after this method is called.
143 //
144 // It is safe to call this method more than once. Calls after the first one
145 // will have no effect.
143 void Close(); 146 void Close();
144 147
145 // Sets the volume of the audio output stream. 148 // Sets the volume of the audio output stream.
146 void SetVolume(double volume); 149 void SetVolume(double volume);
147 150
148 // Enqueue audio |data| into the controller. This method is used only in 151 // Enqueue audio |data| into the controller. This method is used only in
149 // the regular latency mode and it is illegal to call this method when 152 // the regular latency mode and it is illegal to call this method when
150 // SyncReader is present. 153 // SyncReader is present.
151 void EnqueueData(const uint8* data, uint32 size); 154 void EnqueueData(const uint8* data, uint32 size);
152 155
156 bool LowLatencyMode() const { return sync_reader_ != NULL; }
157
153 /////////////////////////////////////////////////////////////////////////// 158 ///////////////////////////////////////////////////////////////////////////
154 // AudioSourceCallback methods. 159 // AudioSourceCallback methods.
155 virtual uint32 OnMoreData(AudioOutputStream* stream, void* dest, 160 virtual uint32 OnMoreData(AudioOutputStream* stream, void* dest,
156 uint32 max_size, uint32 pending_bytes); 161 uint32 max_size, uint32 pending_bytes);
157 virtual void OnClose(AudioOutputStream* stream); 162 virtual void OnClose(AudioOutputStream* stream);
158 virtual void OnError(AudioOutputStream* stream, int code); 163 virtual void OnError(AudioOutputStream* stream, int code);
159 164
160 private: 165 private:
161 AudioController(EventHandler* handler, 166 AudioController(EventHandler* handler,
162 uint32 capacity, SyncReader* sync_reader); 167 uint32 capacity, SyncReader* sync_reader);
163 168
164 // The following methods are executed on the audio controller thread. 169 // The following methods are executed on the audio controller thread.
165 void DoCreate(AudioManager::Format format, int channels, 170 void DoCreate(AudioManager::Format format, int channels,
166 int sample_rate, int bits_per_sample, 171 int sample_rate, int bits_per_sample,
167 int hardware_buffer_size); 172 uint32 hardware_buffer_size);
168 void DoPlay(); 173 void DoPlay();
169 void DoPause(); 174 void DoPause();
170 void DoFlush(); 175 void DoFlush();
171 void DoClose(); 176 void DoClose();
172 void DoSetVolume(double volume); 177 void DoSetVolume(double volume);
173 void DoReportError(int code); 178 void DoReportError(int code);
174 179
175 // Helper method to submit a OnMoreData() call to the event handler. 180 // Helper method to submit a OnMoreData() call to the event handler.
176 void SubmitOnMoreData_Locked(); 181 void SubmitOnMoreData_Locked();
177 182
(...skipping 18 matching lines...) Expand all
196 201
197 // The audio controller thread that this object runs on. 202 // The audio controller thread that this object runs on.
198 base::Thread thread_; 203 base::Thread thread_;
199 204
200 DISALLOW_COPY_AND_ASSIGN(AudioController); 205 DISALLOW_COPY_AND_ASSIGN(AudioController);
201 }; 206 };
202 207
203 } // namespace media 208 } // namespace media
204 209
205 #endif // MEDIA_AUDIO_AUDIO_CONTROLLER_H_ 210 #endif // MEDIA_AUDIO_AUDIO_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698