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

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

Issue 11413078: Tab Audio Capture: Browser-side connect/disconnect functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor tweaks and added some useful comments. Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 AudioBuffersState buffers_state) OVERRIDE; 151 AudioBuffersState buffers_state) OVERRIDE;
152 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; 152 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
153 virtual void WaitTillDataReady() OVERRIDE; 153 virtual void WaitTillDataReady() OVERRIDE;
154 154
155 // AudioDeviceListener implementation. When called AudioOutputController will 155 // AudioDeviceListener implementation. When called AudioOutputController will
156 // shutdown the existing |stream_|, transition to the kRecreating state, 156 // shutdown the existing |stream_|, transition to the kRecreating state,
157 // create a new stream, and then transition back to an equivalent state prior 157 // create a new stream, and then transition back to an equivalent state prior
158 // to being called. 158 // to being called.
159 virtual void OnDeviceChange() OVERRIDE; 159 virtual void OnDeviceChange() OVERRIDE;
160 160
161 // Accessor to audio output parameters.
162 const AudioParameters& params() const { return params_; }
163
164 // Stops the normal audio output stream and creates an AudioSourceCallback to
165 // provide audio data to some other destination. The given object will always
166 // return data when OnMoreData() is invoked, even if the underlying
167 // implementation is paused/stopped. AudioOutputController retains ownership
168 // of the returned object.
169 AudioOutputStream::AudioSourceCallback* Divert();
170
171 // Restores normal audio output behavior for the current playback state.
172 // |asc| is the pointer returned by the previous call to Divert() and becomes
173 // invalid once this method is called.
174 void Revert(AudioOutputStream::AudioSourceCallback* asc);
175
161 protected: 176 protected:
162 // Internal state of the source. 177 // Internal state of the source.
163 enum State { 178 enum State {
164 kEmpty, 179 kEmpty,
165 kCreated, 180 kCreated,
166 kPlaying, 181 kPlaying,
167 kStarting, 182 kStarting,
168 kPausedWhenStarting, 183 kPausedWhenStarting,
169 kPaused, 184 kPaused,
170 kClosed, 185 kClosed,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // SyncReader is used only in low latency mode for synchronous reading. 236 // SyncReader is used only in low latency mode for synchronous reading.
222 SyncReader* sync_reader_; 237 SyncReader* sync_reader_;
223 238
224 // The message loop of audio manager thread that this object runs on. 239 // The message loop of audio manager thread that this object runs on.
225 scoped_refptr<base::MessageLoopProxy> message_loop_; 240 scoped_refptr<base::MessageLoopProxy> message_loop_;
226 241
227 // When starting stream we wait for data to become available. 242 // When starting stream we wait for data to become available.
228 // Number of times left. 243 // Number of times left.
229 int number_polling_attempts_left_; 244 int number_polling_attempts_left_;
230 245
231 AudioParameters params_; 246 const AudioParameters params_;
232 247
233 // Used to post delayed tasks to ourselves that we can cancel. 248 // Used to post delayed tasks to ourselves that we can cancel.
234 // We don't want the tasks to hold onto a reference as it will slow down 249 // We don't want the tasks to hold onto a reference as it will slow down
235 // shutdown and force it to wait for the most delayed task. 250 // shutdown and force it to wait for the most delayed task.
236 // Also, if we're shutting down, we do not want to poll for more data. 251 // Also, if we're shutting down, we do not want to poll for more data.
237 base::WeakPtrFactory<AudioOutputController> weak_this_; 252 base::WeakPtrFactory<AudioOutputController> weak_this_;
238 253
239 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 254 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
240 }; 255 };
241 256
242 } // namespace media 257 } // namespace media
243 258
244 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 259 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698