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

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

Issue 7157001: Implements AudioMessageFilter as member in RenderThread (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Added TODO() comment in failing unit test Created 9 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) 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 // 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 // AudioRendererHost AudioRendererImpl 10 // AudioRendererHost AudioRendererImpl
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "media/base/filters.h" 49 #include "media/base/filters.h"
50 #include "media/filters/audio_renderer_base.h" 50 #include "media/filters/audio_renderer_base.h"
51 51
52 class AudioMessageFilter; 52 class AudioMessageFilter;
53 53
54 class AudioRendererImpl : public media::AudioRendererBase, 54 class AudioRendererImpl : public media::AudioRendererBase,
55 public AudioMessageFilter::Delegate, 55 public AudioMessageFilter::Delegate,
56 public MessageLoop::DestructionObserver { 56 public MessageLoop::DestructionObserver {
57 public: 57 public:
58 // Methods called on Render thread ------------------------------------------ 58 // Methods called on Render thread ------------------------------------------
59 explicit AudioRendererImpl(AudioMessageFilter* filter); 59 AudioRendererImpl();
60 virtual ~AudioRendererImpl(); 60 virtual ~AudioRendererImpl();
61 61
62 // Methods called on IO thread ---------------------------------------------- 62 // Methods called on IO thread ----------------------------------------------
63 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. 63 // AudioMessageFilter::Delegate methods, called by AudioMessageFilter.
64 virtual void OnRequestPacket(AudioBuffersState buffers_state); 64 virtual void OnRequestPacket(AudioBuffersState buffers_state);
65 virtual void OnStateChanged(AudioStreamState state); 65 virtual void OnStateChanged(AudioStreamState state);
66 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length); 66 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length);
67 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, 67 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle,
68 base::SyncSocket::Handle socket_handle, 68 base::SyncSocket::Handle socket_handle,
69 uint32 length); 69 uint32 length);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 void PlayTask(); 107 void PlayTask();
108 void PauseTask(); 108 void PauseTask();
109 void SeekTask(); 109 void SeekTask();
110 void SetVolumeTask(double volume); 110 void SetVolumeTask(double volume);
111 void NotifyPacketReadyTask(); 111 void NotifyPacketReadyTask();
112 void DestroyTask(); 112 void DestroyTask();
113 113
114 // Called on IO thread when message loop is dying. 114 // Called on IO thread when message loop is dying.
115 virtual void WillDestroyCurrentMessageLoop(); 115 virtual void WillDestroyCurrentMessageLoop();
116 116
117 void Send(IPC::Message* message);
118
117 // Used to calculate audio delay given bytes. 119 // Used to calculate audio delay given bytes.
118 uint32 bytes_per_second_; 120 uint32 bytes_per_second_;
119 121
120 scoped_refptr<AudioMessageFilter> filter_;
121
122 // ID of the stream created in the browser process. 122 // ID of the stream created in the browser process.
123 int32 stream_id_; 123 int32 stream_id_;
124 124
125 // Memory shared by the browser process for audio buffer. 125 // Memory shared by the browser process for audio buffer.
126 scoped_ptr<base::SharedMemory> shared_memory_; 126 scoped_ptr<base::SharedMemory> shared_memory_;
127 uint32 shared_memory_size_; 127 uint32 shared_memory_size_;
128 128
129 // Message loop for the IO thread. 129 // Message loop for the IO thread.
130 MessageLoop* io_loop_; 130 MessageLoop* io_loop_;
131 131
132 // Cached audio message filter (lives on the main render thread).
133 scoped_refptr<AudioMessageFilter> filter_;
134
132 // Protects: 135 // Protects:
133 // - |stopped_| 136 // - |stopped_|
134 // - |pending_request_| 137 // - |pending_request_|
135 // - |request_buffers_state_| 138 // - |request_buffers_state_|
136 base::Lock lock_; 139 base::Lock lock_;
137 140
138 // A flag that indicates this filter is called to stop. 141 // A flag that indicates this filter is called to stop.
139 bool stopped_; 142 bool stopped_;
140 143
141 // A flag that indicates an outstanding packet request. 144 // A flag that indicates an outstanding packet request.
142 bool pending_request_; 145 bool pending_request_;
143 146
144 // State of the audio buffers at time of the last request. 147 // State of the audio buffers at time of the last request.
145 AudioBuffersState request_buffers_state_; 148 AudioBuffersState request_buffers_state_;
146 149
147 // State variables for prerolling. 150 // State variables for prerolling.
148 bool prerolling_; 151 bool prerolling_;
149 152
150 // Remaining bytes for prerolling to complete. 153 // Remaining bytes for prerolling to complete.
151 uint32 preroll_bytes_; 154 uint32 preroll_bytes_;
152 155
153 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 156 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
154 }; 157 };
155 158
156 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_ 159 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698