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

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

Issue 1769933002: Looking up device id by session id for AudioRendererMixerInput (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 #include "base/bind.h" 67 #include "base/bind.h"
68 #include "base/macros.h" 68 #include "base/macros.h"
69 #include "base/memory/scoped_ptr.h" 69 #include "base/memory/scoped_ptr.h"
70 #include "base/memory/shared_memory.h" 70 #include "base/memory/shared_memory.h"
71 #include "base/synchronization/waitable_event.h" 71 #include "base/synchronization/waitable_event.h"
72 #include "media/audio/audio_device_thread.h" 72 #include "media/audio/audio_device_thread.h"
73 #include "media/audio/audio_output_ipc.h" 73 #include "media/audio/audio_output_ipc.h"
74 #include "media/audio/audio_parameters.h" 74 #include "media/audio/audio_parameters.h"
75 #include "media/audio/scoped_task_runner_observer.h" 75 #include "media/audio/scoped_task_runner_observer.h"
76 #include "media/base/audio_renderer_sink.h" 76 #include "media/base/audio_renderer_mixer_sink.h"
77 #include "media/base/media_export.h" 77 #include "media/base/media_export.h"
78 #include "media/base/output_device.h" 78 #include "media/base/output_device.h"
79 79
80 namespace media { 80 namespace media {
81 81
82 class MEDIA_EXPORT AudioOutputDevice 82 class MEDIA_EXPORT AudioOutputDevice
83 : NON_EXPORTED_BASE(public AudioRendererSink), 83 : NON_EXPORTED_BASE(public AudioRendererMixerSink),
84 NON_EXPORTED_BASE(public AudioOutputIPCDelegate), 84 NON_EXPORTED_BASE(public AudioOutputIPCDelegate),
85 NON_EXPORTED_BASE(public OutputDevice), 85 NON_EXPORTED_BASE(public OutputDevice),
86 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { 86 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) {
87 public: 87 public:
88 // NOTE: Clients must call Initialize() before using. 88 // NOTE: Clients must call Initialize() before using.
89 AudioOutputDevice( 89 AudioOutputDevice(
90 scoped_ptr<AudioOutputIPC> ipc, 90 scoped_ptr<AudioOutputIPC> ipc,
91 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 91 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
92 int session_id, 92 int session_id,
93 const std::string& device_id, 93 const std::string& device_id,
(...skipping 13 matching lines...) Expand all
107 OutputDevice* GetOutputDevice() override; 107 OutputDevice* GetOutputDevice() override;
108 108
109 // OutputDevice implementation 109 // OutputDevice implementation
110 AudioParameters GetOutputParameters() override; 110 AudioParameters GetOutputParameters() override;
111 OutputDeviceStatus GetDeviceStatus() override; 111 OutputDeviceStatus GetDeviceStatus() override;
112 112
113 // Methods called on IO thread ---------------------------------------------- 113 // Methods called on IO thread ----------------------------------------------
114 // AudioOutputIPCDelegate methods. 114 // AudioOutputIPCDelegate methods.
115 void OnStateChanged(AudioOutputIPCDelegateState state) override; 115 void OnStateChanged(AudioOutputIPCDelegateState state) override;
116 void OnDeviceAuthorized(OutputDeviceStatus device_status, 116 void OnDeviceAuthorized(OutputDeviceStatus device_status,
117 const media::AudioParameters& output_params) override; 117 const media::AudioParameters& output_params,
118 const std::string& matched_device_id) override;
118 void OnStreamCreated(base::SharedMemoryHandle handle, 119 void OnStreamCreated(base::SharedMemoryHandle handle,
119 base::SyncSocket::Handle socket_handle, 120 base::SyncSocket::Handle socket_handle,
120 int length) override; 121 int length) override;
121 void OnIPCClosed() override; 122 void OnIPCClosed() override;
122 123
124 std::string GetDeviceId() override;
Henrik Grunell 2016/03/08 21:09:57 Add comment with description.
o1ka 2016/04/05 15:13:38 Acknowledged.
125
123 protected: 126 protected:
124 // Magic required by ref_counted.h to avoid any code deleting the object 127 // Magic required by ref_counted.h to avoid any code deleting the object
125 // accidentally while there are references to it. 128 // accidentally while there are references to it.
126 friend class base::RefCountedThreadSafe<AudioOutputDevice>; 129 friend class base::RefCountedThreadSafe<AudioOutputDevice>;
127 ~AudioOutputDevice() override; 130 ~AudioOutputDevice() override;
128 131
129 private: 132 private:
130 // Note: The ordering of members in this enum is critical to correct behavior! 133 // Note: The ordering of members in this enum is critical to correct behavior!
131 enum State { 134 enum State {
132 IPC_CLOSED, // No more IPCs can take place. 135 IPC_CLOSED, // No more IPCs can take place.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 bool play_on_start_; 181 bool play_on_start_;
179 182
180 // The media session ID used to identify which input device to be started. 183 // The media session ID used to identify which input device to be started.
181 // Only used by Unified IO. 184 // Only used by Unified IO.
182 int session_id_; 185 int session_id_;
183 186
184 // ID of hardware output device to be used (provided session_id_ is zero) 187 // ID of hardware output device to be used (provided session_id_ is zero)
185 const std::string device_id_; 188 const std::string device_id_;
186 const url::Origin security_origin_; 189 const url::Origin security_origin_;
187 190
191 // If |device_id_| is empty and |session_id_| is not, |matched_device_id_| is
192 // received in OnDeviceAuthorized().
193 std::string matched_device_id_;
194
188 // Our audio thread callback class. See source file for details. 195 // Our audio thread callback class. See source file for details.
189 class AudioThreadCallback; 196 class AudioThreadCallback;
190 197
191 // In order to avoid a race between OnStreamCreated and Stop(), we use this 198 // In order to avoid a race between OnStreamCreated and Stop(), we use this
192 // guard to control stopping and starting the audio thread. 199 // guard to control stopping and starting the audio thread.
193 base::Lock audio_thread_lock_; 200 base::Lock audio_thread_lock_;
194 AudioDeviceThread audio_thread_; 201 AudioDeviceThread audio_thread_;
195 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_; 202 scoped_ptr<AudioOutputDevice::AudioThreadCallback> audio_callback_;
196 203
197 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() 204 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop()
198 // so we don't start the audio thread pointing to a potentially freed 205 // so we don't start the audio thread pointing to a potentially freed
199 // |callback_|. 206 // |callback_|.
200 // 207 //
201 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept 208 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept
202 // the callback via Start(). See http://crbug.com/151051 for details. 209 // the callback via Start(). See http://crbug.com/151051 for details.
203 bool stopping_hack_; 210 bool stopping_hack_;
204 211
205 base::WaitableEvent did_receive_auth_; 212 base::WaitableEvent did_receive_auth_;
206 media::AudioParameters output_params_; 213 media::AudioParameters output_params_;
207 OutputDeviceStatus device_status_; 214 OutputDeviceStatus device_status_;
208 215
209 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); 216 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice);
210 }; 217 };
211 218
212 } // namespace media 219 } // namespace media
213 220
214 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ 221 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698