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

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 input message filter and audio input device Created 9 years, 5 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 14 matching lines...) Expand all
84 // These methods are called from AudioRendererBase. 84 // These methods are called from AudioRendererBase.
85 virtual bool OnInitialize(const media::AudioDecoderConfig& config); 85 virtual bool OnInitialize(const media::AudioDecoderConfig& config);
86 virtual void OnStop(); 86 virtual void OnStop();
87 87
88 // Called when the decoder completes a Read(). 88 // Called when the decoder completes a Read().
89 virtual void ConsumeAudioSamples(scoped_refptr<media::Buffer> buffer_in); 89 virtual void ConsumeAudioSamples(scoped_refptr<media::Buffer> buffer_in);
90 90
91 private: 91 private:
92 // For access to constructor and IO thread methods. 92 // For access to constructor and IO thread methods.
93 friend class AudioRendererImplTest; 93 friend class AudioRendererImplTest;
94 friend class DelegateCaller;
94 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, Stop); 95 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, Stop);
95 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, 96 FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest,
96 DestroyedMessageLoop_ConsumeAudioSamples); 97 DestroyedMessageLoop_ConsumeAudioSamples);
98
97 // Helper methods. 99 // Helper methods.
98 // Convert number of bytes to duration of time using information about the 100 // Convert number of bytes to duration of time using information about the
99 // number of channels, sample rate and sample bits. 101 // number of channels, sample rate and sample bits.
100 base::TimeDelta ConvertToDuration(int bytes); 102 base::TimeDelta ConvertToDuration(int bytes);
101 103
102 // Methods call on IO thread ------------------------------------------------ 104 // Methods call on IO thread ------------------------------------------------
103 // The following methods are tasks posted on the IO thread that needs to 105 // The following methods are tasks posted on the IO thread that needs to
104 // be executed on that thread. They interact with AudioMessageFilter and 106 // be executed on that thread. They interact with AudioMessageFilter and
105 // sends IPC messages on that thread. 107 // sends IPC messages on that thread.
106 void CreateStreamTask(const AudioParameters& params); 108 void CreateStreamTask(const AudioParameters& params);
107 void PlayTask(); 109 void PlayTask();
108 void PauseTask(); 110 void PauseTask();
109 void SeekTask(); 111 void SeekTask();
110 void SetVolumeTask(double volume); 112 void SetVolumeTask(double volume);
111 void NotifyPacketReadyTask(); 113 void NotifyPacketReadyTask();
112 void DestroyTask(); 114 void DestroyTask();
113 115
114 // Called on IO thread when message loop is dying. 116 // Called on IO thread when message loop is dying.
115 virtual void WillDestroyCurrentMessageLoop(); 117 virtual void WillDestroyCurrentMessageLoop();
116 118
119 void Send(IPC::Message* message);
120
117 // Used to calculate audio delay given bytes. 121 // Used to calculate audio delay given bytes.
118 uint32 bytes_per_second_; 122 uint32 bytes_per_second_;
119 123
120 scoped_refptr<AudioMessageFilter> filter_;
121
122 // ID of the stream created in the browser process. 124 // ID of the stream created in the browser process.
123 int32 stream_id_; 125 int32 stream_id_;
124 126
125 // Memory shared by the browser process for audio buffer. 127 // Memory shared by the browser process for audio buffer.
126 scoped_ptr<base::SharedMemory> shared_memory_; 128 scoped_ptr<base::SharedMemory> shared_memory_;
127 uint32 shared_memory_size_; 129 uint32 shared_memory_size_;
128 130
129 // Message loop for the IO thread. 131 // Cached audio message filter (lives on the main render thread).
130 MessageLoop* io_loop_; 132 scoped_refptr<AudioMessageFilter> filter_;
131 133
132 // Protects: 134 // Protects:
133 // - |stopped_| 135 // - |stopped_|
134 // - |pending_request_| 136 // - |pending_request_|
135 // - |request_buffers_state_| 137 // - |request_buffers_state_|
136 base::Lock lock_; 138 base::Lock lock_;
137 139
138 // A flag that indicates this filter is called to stop. 140 // A flag that indicates this filter is called to stop.
139 bool stopped_; 141 bool stopped_;
140 142
141 // A flag that indicates an outstanding packet request. 143 // A flag that indicates an outstanding packet request.
142 bool pending_request_; 144 bool pending_request_;
143 145
144 // State of the audio buffers at time of the last request. 146 // State of the audio buffers at time of the last request.
145 AudioBuffersState request_buffers_state_; 147 AudioBuffersState request_buffers_state_;
146 148
147 // State variables for prerolling. 149 // State variables for prerolling.
148 bool prerolling_; 150 bool prerolling_;
149 151
150 // Remaining bytes for prerolling to complete. 152 // Remaining bytes for prerolling to complete.
151 uint32 preroll_bytes_; 153 uint32 preroll_bytes_;
152 154
153 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 155 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
154 }; 156 };
155 157
156 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_ 158 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698