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

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

Issue 15979015: Reland 15721002: Hook up the device selection to the WebAudio live audio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed the comments. Created 7 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 | 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/atomic_ref_count.h" 8 #include "base/atomic_ref_count.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 virtual bool DataReady() = 0; 105 virtual bool DataReady() = 0;
106 }; 106 };
107 107
108 // Factory method for creating an AudioOutputController. 108 // Factory method for creating an AudioOutputController.
109 // This also creates and opens an AudioOutputStream on the audio manager 109 // This also creates and opens an AudioOutputStream on the audio manager
110 // thread, and if this is successful, the |event_handler| will receive an 110 // thread, and if this is successful, the |event_handler| will receive an
111 // OnCreated() call from the same audio manager thread. |audio_manager| must 111 // OnCreated() call from the same audio manager thread. |audio_manager| must
112 // outlive AudioOutputController. 112 // outlive AudioOutputController.
113 static scoped_refptr<AudioOutputController> Create( 113 static scoped_refptr<AudioOutputController> Create(
114 AudioManager* audio_manager, EventHandler* event_handler, 114 AudioManager* audio_manager, EventHandler* event_handler,
115 const AudioParameters& params, SyncReader* sync_reader); 115 const AudioParameters& params, const std::string& input_device_id,
116 SyncReader* sync_reader);
116 117
117 // Methods to control playback of the stream. 118 // Methods to control playback of the stream.
118 119
119 // Starts the playback of this audio output stream. 120 // Starts the playback of this audio output stream.
120 void Play(); 121 void Play();
121 122
122 // Pause this audio output stream. 123 // Pause this audio output stream.
123 void Pause(); 124 void Pause();
124 125
125 // Closes the audio output stream. The state is changed and the resources 126 // Closes the audio output stream. The state is changed and the resources
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 171
171 friend class base::RefCountedThreadSafe<AudioOutputController>; 172 friend class base::RefCountedThreadSafe<AudioOutputController>;
172 virtual ~AudioOutputController(); 173 virtual ~AudioOutputController();
173 174
174 private: 175 private:
175 // We are polling sync reader if data became available. 176 // We are polling sync reader if data became available.
176 static const int kPollNumAttempts; 177 static const int kPollNumAttempts;
177 static const int kPollPauseInMilliseconds; 178 static const int kPollPauseInMilliseconds;
178 179
179 AudioOutputController(AudioManager* audio_manager, EventHandler* handler, 180 AudioOutputController(AudioManager* audio_manager, EventHandler* handler,
180 const AudioParameters& params, SyncReader* sync_reader); 181 const AudioParameters& params,
182 const std::string& input_device_id,
183 SyncReader* sync_reader);
181 184
182 // The following methods are executed on the audio manager thread. 185 // The following methods are executed on the audio manager thread.
183 void DoCreate(bool is_for_device_change); 186 void DoCreate(bool is_for_device_change);
184 void DoPlay(); 187 void DoPlay();
185 void PollAndStartIfDataReady(); 188 void PollAndStartIfDataReady();
186 void DoPause(); 189 void DoPause();
187 void DoClose(); 190 void DoClose();
188 void DoSetVolume(double volume); 191 void DoSetVolume(double volume);
189 void DoReportError(); 192 void DoReportError();
190 void DoStartDiverting(AudioOutputStream* to_stream); 193 void DoStartDiverting(AudioOutputStream* to_stream);
(...skipping 12 matching lines...) Expand all
203 206
204 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread 207 // Sanity-check that entry/exit to OnMoreIOData() by the hardware audio thread
205 // happens only between AudioOutputStream::Start() and Stop(). 208 // happens only between AudioOutputStream::Start() and Stop().
206 void AllowEntryToOnMoreIOData(); 209 void AllowEntryToOnMoreIOData();
207 void DisallowEntryToOnMoreIOData(); 210 void DisallowEntryToOnMoreIOData();
208 211
209 AudioManager* const audio_manager_; 212 AudioManager* const audio_manager_;
210 const AudioParameters params_; 213 const AudioParameters params_;
211 EventHandler* const handler_; 214 EventHandler* const handler_;
212 215
216 // Used by the unified IO to open the correct input device.
217 std::string input_device_id_;
218
213 // Note: It's important to invalidate the weak pointers whenever stream_ is 219 // Note: It's important to invalidate the weak pointers whenever stream_ is
214 // changed. See comment for weak_this_. 220 // changed. See comment for weak_this_.
215 AudioOutputStream* stream_; 221 AudioOutputStream* stream_;
216 222
217 // When non-NULL, audio is being diverted to this stream. 223 // When non-NULL, audio is being diverted to this stream.
218 AudioOutputStream* diverting_to_stream_; 224 AudioOutputStream* diverting_to_stream_;
219 225
220 // The current volume of the audio stream. 226 // The current volume of the audio stream.
221 double volume_; 227 double volume_;
222 228
(...skipping 27 matching lines...) Expand all
250 // EventHandler::OnAudbile() to be called whenever a transition to a period of 256 // EventHandler::OnAudbile() to be called whenever a transition to a period of
251 // silence or non-silence is detected. 257 // silence or non-silence is detected.
252 scoped_ptr<AudioSilenceDetector> silence_detector_; 258 scoped_ptr<AudioSilenceDetector> silence_detector_;
253 259
254 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 260 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
255 }; 261 };
256 262
257 } // namespace media 263 } // namespace media
258 264
259 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 265 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698