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

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

Issue 12383016: Merge AssociateStreamWithProducer message into CreateStream message for both audio output and input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual bool SetVolume(double volume) OVERRIDE; 87 virtual bool SetVolume(double volume) OVERRIDE;
88 88
89 // Methods called on IO thread ---------------------------------------------- 89 // Methods called on IO thread ----------------------------------------------
90 // AudioOutputIPCDelegate methods. 90 // AudioOutputIPCDelegate methods.
91 virtual void OnStateChanged(AudioOutputIPCDelegate::State state) OVERRIDE; 91 virtual void OnStateChanged(AudioOutputIPCDelegate::State state) OVERRIDE;
92 virtual void OnStreamCreated(base::SharedMemoryHandle handle, 92 virtual void OnStreamCreated(base::SharedMemoryHandle handle,
93 base::SyncSocket::Handle socket_handle, 93 base::SyncSocket::Handle socket_handle,
94 int length) OVERRIDE; 94 int length) OVERRIDE;
95 virtual void OnIPCClosed() OVERRIDE; 95 virtual void OnIPCClosed() OVERRIDE;
96 96
97 // Creates an uninitialized AudioOutputDevice. Clients must call Initialize() 97 // Creates an uninitialized AudioOutputDevice. Takes ownership of |ipc|.
98 // before using. 98 // Clients must call Initialize() before using.
99 AudioOutputDevice(AudioOutputIPC* ipc, 99 AudioOutputDevice(AudioOutputIPC* ipc,
100 const scoped_refptr<base::MessageLoopProxy>& io_loop); 100 const scoped_refptr<base::MessageLoopProxy>& io_loop);
101 101
102 protected: 102 protected:
103 // Magic required by ref_counted.h to avoid any code deleting the object 103 // Magic required by ref_counted.h to avoid any code deleting the object
104 // accidentally while there are references to it. 104 // accidentally while there are references to it.
105 friend class base::RefCountedThreadSafe<AudioOutputDevice>; 105 friend class base::RefCountedThreadSafe<AudioOutputDevice>;
106 virtual ~AudioOutputDevice(); 106 virtual ~AudioOutputDevice();
107 107
108 // Accessors for subclasses (via IO thread only).
109 int stream_id() const { return stream_id_; }
110 AudioOutputIPC* audio_output_ipc() const { return ipc_; }
111
112 private: 108 private:
113 // Note: The ordering of members in this enum is critical to correct behavior! 109 // Note: The ordering of members in this enum is critical to correct behavior!
114 enum State { 110 enum State {
115 IPC_CLOSED, // No more IPCs can take place. 111 IPC_CLOSED, // No more IPCs can take place.
116 IDLE, // Not started. 112 IDLE, // Not started.
117 CREATING_STREAM, // Waiting for OnStreamCreated() to be called back. 113 CREATING_STREAM, // Waiting for OnStreamCreated() to be called back.
118 PAUSED, // Paused. OnStreamCreated() has been called. Can Play()/Stop(). 114 PAUSED, // Paused. OnStreamCreated() has been called. Can Play()/Stop().
119 PLAYING, // Playing back. Can Pause()/Stop(). 115 PLAYING, // Playing back. Can Pause()/Stop().
120 }; 116 };
121 117
122 // Methods called on IO thread ---------------------------------------------- 118 // Methods called on IO thread ----------------------------------------------
123 // The following methods are tasks posted on the IO thread that needs to 119 // The following methods are tasks posted on the IO thread that needs to
124 // be executed on that thread. They interact with AudioMessageFilter and 120 // be executed on that thread. They interact with AudioMessageFilter and
125 // sends IPC messages on that thread. 121 // sends IPC messages on that thread.
126 void CreateStreamOnIOThread(const AudioParameters& params); 122 void CreateStreamOnIOThread(const AudioParameters& params);
127 void PlayOnIOThread(); 123 void PlayOnIOThread();
128 void PauseOnIOThread(bool flush); 124 void PauseOnIOThread(bool flush);
129 void ShutDownOnIOThread(); 125 void ShutDownOnIOThread();
130 void SetVolumeOnIOThread(double volume); 126 void SetVolumeOnIOThread(double volume);
131 127
132 // MessageLoop::DestructionObserver implementation for the IO loop. 128 // MessageLoop::DestructionObserver implementation for the IO loop.
133 // If the IO loop dies before we do, we shut down the audio thread from here. 129 // If the IO loop dies before we do, we shut down the audio thread from here.
134 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; 130 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
135 131
136 AudioParameters audio_parameters_; 132 AudioParameters audio_parameters_;
137 133
138 RenderCallback* callback_; 134 RenderCallback* callback_;
139 135
140 // A pointer to the IPC layer that takes care of sending requests over to 136 // A pointer to the IPC layer that takes care of sending requests over to
141 // the AudioRendererHost. 137 // the AudioRendererHost. Only valid when state_ != IPC_CLOSED and must only
142 AudioOutputIPC* ipc_; 138 // be accessed on the IO thread.
143 139 const scoped_ptr<AudioOutputIPC> ipc_;
144 // Our stream ID on the message filter. Only accessed on the IO thread.
145 // Must only be modified on the IO thread.
146 int stream_id_;
147 140
148 // Current state (must only be accessed from the IO thread). See comments for 141 // Current state (must only be accessed from the IO thread). See comments for
149 // State enum above. 142 // State enum above.
150 State state_; 143 State state_;
151 144
152 // State of Play() / Pause() calls before OnStreamCreated() is called. 145 // State of Play() / Pause() calls before OnStreamCreated() is called.
153 bool play_on_start_; 146 bool play_on_start_;
154 147
155 // Our audio thread callback class. See source file for details. 148 // Our audio thread callback class. See source file for details.
156 class AudioThreadCallback; 149 class AudioThreadCallback;
(...skipping 11 matching lines...) Expand all
168 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept 161 // TODO(scherkus): Replace this by changing AudioRendererSink to either accept
169 // the callback via Start(). See http://crbug.com/151051 for details. 162 // the callback via Start(). See http://crbug.com/151051 for details.
170 bool stopping_hack_; 163 bool stopping_hack_;
171 164
172 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice); 165 DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice);
173 }; 166 };
174 167
175 } // namespace media 168 } // namespace media
176 169
177 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_ 170 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698