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

Side by Side Diff: media/audio/audio_output_device.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 // Audio rendering unit utilizing audio output stream provided by browser 5 // Audio rendering unit utilizing audio output stream provided by browser
6 // process through IPC. 6 // process through IPC.
7 // 7 //
8 // Relationship of classes. 8 // Relationship of classes.
9 // 9 //
10 // AudioOutputController AudioOutputDevice 10 // AudioOutputController AudioOutputDevice
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 class MEDIA_EXPORT AudioOutputDevice 75 class MEDIA_EXPORT AudioOutputDevice
76 : NON_EXPORTED_BASE(public AudioRendererSink), 76 : NON_EXPORTED_BASE(public AudioRendererSink),
77 NON_EXPORTED_BASE(public AudioOutputIPCDelegate), 77 NON_EXPORTED_BASE(public AudioOutputIPCDelegate),
78 NON_EXPORTED_BASE(public ScopedLoopObserver) { 78 NON_EXPORTED_BASE(public ScopedLoopObserver) {
79 public: 79 public:
80 // NOTE: Clients must call Initialize() before using. 80 // NOTE: Clients must call Initialize() before using.
81 AudioOutputDevice(scoped_ptr<AudioOutputIPC> ipc, 81 AudioOutputDevice(scoped_ptr<AudioOutputIPC> ipc,
82 const scoped_refptr<base::MessageLoopProxy>& io_loop); 82 const scoped_refptr<base::MessageLoopProxy>& io_loop);
83 83
84 // Initialize function for clients wishing to have unified input and
85 // output, |params| may specify |input_channels| > 0, representing a
86 // number of input channels which will be at the same sample-rate
87 // and buffer-size as the output as specified in |params|. |session_id| is
88 // used for the browser to select the correct input device.
89 // In this case, the callback's RenderIO() method will be called instead
90 // of Render(), providing the synchronized input data at the same time as
91 // when new output data is to be rendered.
92 void InitializeUnifiedStream(const AudioParameters& params,
93 RenderCallback* callback,
94 int session_id);
95
84 // AudioRendererSink implementation. 96 // AudioRendererSink implementation.
85 virtual void Initialize(const AudioParameters& params, 97 virtual void Initialize(const AudioParameters& params,
86 RenderCallback* callback) OVERRIDE; 98 RenderCallback* callback) OVERRIDE;
87 virtual void Start() OVERRIDE; 99 virtual void Start() OVERRIDE;
88 virtual void Stop() OVERRIDE; 100 virtual void Stop() OVERRIDE;
89 virtual void Play() OVERRIDE; 101 virtual void Play() OVERRIDE;
90 virtual void Pause() OVERRIDE; 102 virtual void Pause() OVERRIDE;
91 virtual bool SetVolume(double volume) OVERRIDE; 103 virtual bool SetVolume(double volume) OVERRIDE;
92 104
93 // Methods called on IO thread ---------------------------------------------- 105 // Methods called on IO thread ----------------------------------------------
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // be accessed on the IO thread. 149 // be accessed on the IO thread.
138 scoped_ptr<AudioOutputIPC> ipc_; 150 scoped_ptr<AudioOutputIPC> ipc_;
139 151
140 // Current state (must only be accessed from the IO thread). See comments for 152 // Current state (must only be accessed from the IO thread). See comments for
141 // State enum above. 153 // State enum above.
142 State state_; 154 State state_;
143 155
144 // State of Play() / Pause() calls before OnStreamCreated() is called. 156 // State of Play() / Pause() calls before OnStreamCreated() is called.
145 bool play_on_start_; 157 bool play_on_start_;
146 158
159 // The media session ID used to identify which input device to be started.
160 // Only used by Unified IO.
161 int session_id_;
162
147 // Our audio thread callback class. See source file for details. 163 // Our audio thread callback class. See source file for details.
148 class AudioThreadCallback; 164 class AudioThreadCallback;
149 165
150 // In order to avoid a race between OnStreamCreated and Stop(), we use this 166 // In order to avoid a race between OnStreamCreated and Stop(), we use this
151 // guard to control stopping and starting the audio thread. 167 // guard to control stopping and starting the audio thread.
152 base::Lock audio_thread_lock_; 168 base::Lock audio_thread_lock_;
153 AudioDeviceThread audio_thread_; 169 AudioDeviceThread audio_thread_;
154 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; 170 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_;
155 171
156 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() 172 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop()
157 // so we don't start the audio thread pointing to a potentially freed 173 // so we don't start the audio thread pointing to a potentially freed
158 // |callback_|. 174 // |callback_|.
159 // 175 //
160 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept 176 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept
161 // the callback via Start(). See http://crbug.com/151051 for details. 177 // the callback via Start(). See http://crbug.com/151051 for details.
162 bool stopping_hack_; 178 bool stopping_hack_;
163 179
164 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); 180 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice);
165 }; 181 };
166 182
167 } // namespace media 183 } // namespace media
168 184
169 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ 185 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698