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

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 // Fills entire buffer of length |number_of_frames| but returns actual
85 size_t number_of_frames, 85 // number of frames it got from its source (|number_of_frames| in case of
86 size_t audio_delay_milliseconds) = 0; 86 // continuous stream). That actual number of frames is passed to host
87 // together with PCM audio data and host is free to use or ignore it.
88 virtual size_t Render(const std::vector<float*>& audio_data,
89 size_t number_of_frames,
90 size_t audio_delay_milliseconds) = 0;
87 protected: 91 protected:
88 virtual ~RenderCallback() {} 92 virtual ~RenderCallback() {}
89 }; 93 };
90 94
91 // Methods called on main render thread ------------------------------------- 95 // Methods called on main render thread -------------------------------------
92 96
93 // Minimal constructor where Initialize() must be called later. 97 // Minimal constructor where Initialize() must be called later.
94 AudioDevice(); 98 AudioDevice();
95 99
96 AudioDevice(size_t buffer_size, 100 AudioDevice(size_t buffer_size,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // be executed on that thread. They interact with AudioMessageFilter and 156 // be executed on that thread. They interact with AudioMessageFilter and
153 // sends IPC messages on that thread. 157 // sends IPC messages on that thread.
154 void InitializeOnIOThread(const AudioParameters& params); 158 void InitializeOnIOThread(const AudioParameters& params);
155 void PlayOnIOThread(); 159 void PlayOnIOThread();
156 void PauseOnIOThread(bool flush); 160 void PauseOnIOThread(bool flush);
157 void ShutDownOnIOThread(base::WaitableEvent* completion); 161 void ShutDownOnIOThread(base::WaitableEvent* completion);
158 void SetVolumeOnIOThread(double volume); 162 void SetVolumeOnIOThread(double volume);
159 163
160 void Send(IPC::Message* message); 164 void Send(IPC::Message* message);
161 165
162 // Method called on the audio thread (+ one call on the IO thread) ---------- 166 // Method called on the audio thread ----------------------------------------
163 // Calls the client's callback for rendering audio. There will also be one 167 // Calls the client's callback for rendering audio.
164 // initial call on the IO thread before the audio thread has been created. 168 // Returns actual number of filled frames that callback returned. This length
165 void FireRenderCallback(int16* data); 169 // is passed to host at the end of the shared memory (i.e. buffer). In case of
170 // continuous stream host just ignores it and assumes buffer is always filled
171 // to it capacity.
henrika (OOO until Aug 14) 2011/12/16 10:52:17 its
enal1 2011/12/16 16:48:23 Done.
172 size_t FireRenderCallback(int16* data);
166 173
167 // DelegateSimpleThread::Delegate implementation. 174 // DelegateSimpleThread::Delegate implementation.
168 virtual void Run() OVERRIDE; 175 virtual void Run() OVERRIDE;
169 176
170 // Closes socket and joins with the audio thread. 177 // Closes socket and joins with the audio thread.
171 void ShutDownAudioThread(); 178 void ShutDownAudioThread();
172 179
173 // Format 180 // Format
174 size_t buffer_size_; // in sample-frames 181 size_t buffer_size_; // in sample-frames
175 int channels_; 182 int channels_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 225
219 // Protects lifetime of: 226 // Protects lifetime of:
220 // socket_handle_ 227 // socket_handle_
221 // audio_thread_ 228 // audio_thread_
222 base::Lock lock_; 229 base::Lock lock_;
223 230
224 DISALLOW_COPY_AND_ASSIGN(AudioDevice); 231 DISALLOW_COPY_AND_ASSIGN(AudioDevice);
225 }; 232 };
226 233
227 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_H_ 234 #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/audio_device.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698