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

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

Issue 3185022: Share one thread between all AudioOutputControllers instead of creating one per stream. (Closed)
Patch Set: - Created 10 years, 4 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 | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_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_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"
11 #include "base/thread.h"
12 #include "base/time.h" 11 #include "base/time.h"
13 #include "media/audio/audio_io.h" 12 #include "media/audio/audio_io.h"
13 #include "media/audio/audio_manager.h"
14 #include "media/audio/simple_sources.h" 14 #include "media/audio/simple_sources.h"
15 15
16 class MessageLoop;
17
16 // An AudioOutputController controls an AudioOutputStream and provides data 18 // An AudioOutputController controls an AudioOutputStream and provides data
17 // to this output stream. It has an important function that it executes 19 // to this output stream. It has an important function that it executes
18 // audio operations like play, pause, stop, etc. on a separate thread, 20 // audio operations like play, pause, stop, etc. on a separate thread,
19 // namely the audio controller thread. 21 // namely the audio controller thread.
20 // 22 //
21 // All the public methods of AudioOutputController are non-blocking except 23 // All the public methods of AudioOutputController are non-blocking except
22 // close, the actual operations are performed on the audio controller thread. 24 // close, the actual operations are performed on the audio controller thread.
23 // 25 //
24 // Here is a state diagram for the AudioOutputController: 26 // Here is a state diagram for the AudioOutputController:
25 // 27 //
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Starts the playback of this audio output stream. 133 // Starts the playback of this audio output stream.
132 void Play(); 134 void Play();
133 135
134 // Pause this audio output stream. 136 // Pause this audio output stream.
135 void Pause(); 137 void Pause();
136 138
137 // Discard all audio data buffered in this output stream. This method only 139 // Discard all audio data buffered in this output stream. This method only
138 // has effect when the stream is paused. 140 // has effect when the stream is paused.
139 void Flush(); 141 void Flush();
140 142
141 // Closes the audio output stream and shutdown the audio controller thread. 143 // Closes the audio output stream. It changes state to kClosed and returns
142 // This method returns only after all operations are completed. This 144 // right away. The physical resources are freed on the audio thread if
143 // controller cannot be used after this method is called. 145 // neccessary.
144 // 146 //
145 // It is safe to call this method more than once. Calls after the first one 147 // It is safe to call this method more than once. Calls after the first one
146 // will have no effect. 148 // will have no effect.
147 void Close(); 149 void Close();
148 150
149 // Sets the volume of the audio output stream. 151 // Sets the volume of the audio output stream.
150 void SetVolume(double volume); 152 void SetVolume(double volume);
151 153
152 // Enqueue audio |data| into the controller. This method is used only in 154 // Enqueue audio |data| into the controller. This method is used only in
153 // the regular latency mode and it is illegal to call this method when 155 // the regular latency mode and it is illegal to call this method when
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 base::Time last_callback_time_; 198 base::Time last_callback_time_;
197 Lock lock_; 199 Lock lock_;
198 200
199 // PushSource role is to buffer and it's only used in regular latency mode. 201 // PushSource role is to buffer and it's only used in regular latency mode.
200 PushSource push_source_; 202 PushSource push_source_;
201 uint32 buffer_capacity_; 203 uint32 buffer_capacity_;
202 204
203 // SyncReader is used only in low latency mode for synchronous reading. 205 // SyncReader is used only in low latency mode for synchronous reading.
204 SyncReader* sync_reader_; 206 SyncReader* sync_reader_;
205 207
206 // The audio controller thread that this object runs on. 208 // The message loop of audio thread that this object runs on.
207 base::Thread thread_; 209 MessageLoop* message_loop_;
208 210
209 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 211 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
210 }; 212 };
211 213
212 } // namespace media 214 } // namespace media
213 215
214 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 216 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698