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 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 virtual ~AudioOutputController(); | 102 virtual ~AudioOutputController(); |
103 | 103 |
104 // Factory method for creating an AudioOutputController. | 104 // Factory method for creating an AudioOutputController. |
105 // If successful, an audio controller thread is created. The audio device | 105 // If successful, an audio controller thread is created. The audio device |
106 // will be created on the audio controller thread and when that is done | 106 // will be created on the audio controller thread and when that is done |
107 // event handler will receive a OnCreated() call. | 107 // event handler will receive a OnCreated() call. |
108 static scoped_refptr<AudioOutputController> Create( | 108 static scoped_refptr<AudioOutputController> Create( |
109 EventHandler* event_handler, | 109 EventHandler* event_handler, |
110 AudioParameters params, | 110 AudioParameters params, |
111 uint32 hardware_buffer_size, // Size of the hardware buffer. | |
112 | |
113 // Soft limit for buffer capacity in this controller. This parameter | 111 // Soft limit for buffer capacity in this controller. This parameter |
114 // is used only in regular latency mode. | 112 // is used only in regular latency mode. |
115 uint32 buffer_capacity); | 113 uint32 buffer_capacity); |
116 | 114 |
117 // Factory method for creating a low latency audio stream. | 115 // Factory method for creating a low latency audio stream. |
118 static scoped_refptr<AudioOutputController> CreateLowLatency( | 116 static scoped_refptr<AudioOutputController> CreateLowLatency( |
119 EventHandler* event_handler, | 117 EventHandler* event_handler, |
120 AudioParameters params, | 118 AudioParameters params, |
121 uint32 hardware_buffer_size, // Size of the hardware buffer. | |
122 | |
123 // External synchronous reader for audio controller. | 119 // External synchronous reader for audio controller. |
124 SyncReader* sync_reader); | 120 SyncReader* sync_reader); |
125 | 121 |
126 // Methods to control playback of the stream. | 122 // Methods to control playback of the stream. |
127 | 123 |
128 // Starts the playback of this audio output stream. | 124 // Starts the playback of this audio output stream. |
129 void Play(); | 125 void Play(); |
130 | 126 |
131 // Pause this audio output stream. | 127 // Pause this audio output stream. |
132 void Pause(); | 128 void Pause(); |
(...skipping 18 matching lines...) Expand all Loading... |
151 // the regular latency mode and it is illegal to call this method when | 147 // the regular latency mode and it is illegal to call this method when |
152 // SyncReader is present. | 148 // SyncReader is present. |
153 void EnqueueData(const uint8* data, uint32 size); | 149 void EnqueueData(const uint8* data, uint32 size); |
154 | 150 |
155 bool LowLatencyMode() const { return sync_reader_ != NULL; } | 151 bool LowLatencyMode() const { return sync_reader_ != NULL; } |
156 | 152 |
157 /////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////// |
158 // AudioSourceCallback methods. | 154 // AudioSourceCallback methods. |
159 virtual uint32 OnMoreData(AudioOutputStream* stream, uint8* dest, | 155 virtual uint32 OnMoreData(AudioOutputStream* stream, uint8* dest, |
160 uint32 max_size, AudioBuffersState buffers_state); | 156 uint32 max_size, AudioBuffersState buffers_state); |
161 virtual void OnClose(AudioOutputStream* stream); | |
162 virtual void OnError(AudioOutputStream* stream, int code); | 157 virtual void OnError(AudioOutputStream* stream, int code); |
163 | 158 |
164 private: | 159 private: |
165 AudioOutputController(EventHandler* handler, | 160 AudioOutputController(EventHandler* handler, |
166 uint32 capacity, SyncReader* sync_reader); | 161 uint32 capacity, SyncReader* sync_reader); |
167 | 162 |
168 // The following methods are executed on the audio controller thread. | 163 // The following methods are executed on the audio controller thread. |
169 void DoCreate(AudioParameters params, uint32 hardware_buffer_size); | 164 void DoCreate(AudioParameters params); |
170 void DoPlay(); | 165 void DoPlay(); |
171 void DoPause(); | 166 void DoPause(); |
172 void DoFlush(); | 167 void DoFlush(); |
173 void DoClose(Task* closed_task); | 168 void DoClose(Task* closed_task); |
174 void DoSetVolume(double volume); | 169 void DoSetVolume(double volume); |
175 void DoReportError(int code); | 170 void DoReportError(int code); |
176 | 171 |
177 // Helper method to submit a OnMoreData() call to the event handler. | 172 // Helper method to submit a OnMoreData() call to the event handler. |
178 void SubmitOnMoreData_Locked(); | 173 void SubmitOnMoreData_Locked(); |
179 | 174 |
(...skipping 23 matching lines...) Expand all Loading... |
203 | 198 |
204 // The message loop of audio thread that this object runs on. | 199 // The message loop of audio thread that this object runs on. |
205 MessageLoop* message_loop_; | 200 MessageLoop* message_loop_; |
206 | 201 |
207 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); | 202 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); |
208 }; | 203 }; |
209 | 204 |
210 } // namespace media | 205 } // namespace media |
211 | 206 |
212 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ | 207 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ |
OLD | NEW |