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

Side by Side Diff: content/renderer/media/audio_device.h

Issue 8909006: Fix start/stop of html5 audio stream and race condition when pausing. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Low-latency audio rendering unit utilizing audio output stream provided 5 // Low-latency audio rendering unit utilizing audio output stream provided
6 // by browser process through IPC. 6 // by browser process through IPC.
7 // 7 //
8 // Relationship of classes. 8 // Relationship of classes.
9 // 9 //
10 // AudioOutputController AudioDevice 10 // AudioOutputController AudioDevice
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "content/renderer/media/audio_message_filter.h" 74 #include "content/renderer/media/audio_message_filter.h"
75 #include "media/audio/audio_parameters.h" 75 #include "media/audio/audio_parameters.h"
76 76
77 class CONTENT_EXPORT AudioDevice 77 class CONTENT_EXPORT AudioDevice
78 : public AudioMessageFilter::Delegate, 78 : public AudioMessageFilter::Delegate,
79 public base::DelegateSimpleThread::Delegate, 79 public base::DelegateSimpleThread::Delegate,
80 public base::RefCountedThreadSafe<AudioDevice> { 80 public base::RefCountedThreadSafe<AudioDevice> {
81 public: 81 public:
82 class CONTENT_EXPORT RenderCallback { 82 class CONTENT_EXPORT RenderCallback {
83 public: 83 public:
84 virtual void Render(const std::vector<float*>& audio_data, 84 // Always fills entire buffer but returns actual number of frames it got
85 size_t number_of_frames, 85 // from source. That actual number of frames is passed to host at the end
86 size_t audio_delay_milliseconds) = 0; 86 // of the shared memory (i.e. buffer), and host is free to use or ignore it.
Chris Rogers 2011/12/15 00:32:52 nit: the implementation details of "shared memory"
enal1 2011/12/15 16:54:40 Done.
87 virtual size_t Render(const std::vector<float*>& audio_data,
88 size_t number_of_frames,
89 size_t audio_delay_milliseconds) = 0;
87 protected: 90 protected:
88 virtual ~RenderCallback() {} 91 virtual ~RenderCallback() {}
89 }; 92 };
90 93
91 // Methods called on main render thread ------------------------------------- 94 // Methods called on main render thread -------------------------------------
92 95
93 // Minimal constructor where Initialize() must be called later. 96 // Minimal constructor where Initialize() must be called later.
94 AudioDevice(); 97 AudioDevice();
95 98
96 AudioDevice(size_t buffer_size, 99 AudioDevice(size_t buffer_size,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // sends IPC messages on that thread. 156 // sends IPC messages on that thread.
154 void InitializeOnIOThread(const AudioParameters& params); 157 void InitializeOnIOThread(const AudioParameters& params);
155 void PlayOnIOThread(); 158 void PlayOnIOThread();
156 void PauseOnIOThread(bool flush); 159 void PauseOnIOThread(bool flush);
157 void ShutDownOnIOThread(base::WaitableEvent* completion); 160 void ShutDownOnIOThread(base::WaitableEvent* completion);
158 void SetVolumeOnIOThread(double volume); 161 void SetVolumeOnIOThread(double volume);
159 162
160 void Send(IPC::Message* message); 163 void Send(IPC::Message* message);
161 164
162 // Method called on the audio thread (+ one call on the IO thread) ---------- 165 // Method called on the audio thread (+ one call on the IO thread) ----------
163 // Calls the client's callback for rendering audio. There will also be one 166 // Calls the client's callback for rendering audio.
164 // initial call on the IO thread before the audio thread has been created. 167 // Returns actual number of filled frames, see comment on
165 void FireRenderCallback(int16* data); 168 // RenderCallback::Render().
Chris Rogers 2011/12/15 00:32:52 See my comment above.
enal1 2011/12/15 16:54:40 Done.
169 size_t FireRenderCallback(int16* data);
166 170
167 // DelegateSimpleThread::Delegate implementation. 171 // DelegateSimpleThread::Delegate implementation.
168 virtual void Run() OVERRIDE; 172 virtual void Run() OVERRIDE;
169 173
170 // Closes socket and joins with the audio thread. 174 // Closes socket and joins with the audio thread.
171 void ShutDownAudioThread(); 175 void ShutDownAudioThread();
172 176
173 // Format 177 // Format
174 size_t buffer_size_; // in sample-frames 178 size_t buffer_size_; // in sample-frames
175 int channels_; 179 int channels_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 222
219 // Protects lifetime of: 223 // Protects lifetime of:
220 // socket_handle_ 224 // socket_handle_
221 // audio_thread_ 225 // audio_thread_
222 base::Lock lock_; 226 base::Lock lock_;
223 227
224 DISALLOW_COPY_AND_ASSIGN(AudioDevice); 228 DISALLOW_COPY_AND_ASSIGN(AudioDevice);
225 }; 229 };
226 230
227 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ 231 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/audio_device.cc » ('j') | content/renderer/media/webrtc_audio_device_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698