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

Side by Side Diff: media/filters/audio_renderer_impl.h

Issue 12262058: Revert r180578, r180591, and r180604 from 1410 branch. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « media/base/video_renderer.h ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 an AudioRendererSink to output data. 5 // Audio rendering unit utilizing an AudioRendererSink to output data.
6 // 6 //
7 // This class lives inside three threads during it's lifetime, namely: 7 // This class lives inside three threads during it's lifetime, namely:
8 // 1. Render thread 8 // 1. Render thread
9 // Where the object is created. 9 // Where the object is created.
10 // 2. Media thread (provided via constructor) 10 // 2. Media thread (provided via constructor)
11 // All AudioDecoder methods are called on this thread. 11 // All AudioDecoder methods are called on this thread.
12 // 3. Audio thread created by the AudioRendererSink. 12 // 3. Audio thread created by the AudioRendererSink.
13 // Render() is called here where audio data is decoded into raw PCM data. 13 // Render() is called here where audio data is decoded into raw PCM data.
14 // 14 //
15 // AudioRendererImpl talks to an AudioRendererAlgorithm that takes care of 15 // AudioRendererImpl talks to an AudioRendererAlgorithm that takes care of
16 // queueing audio data and stretching/shrinking audio data when playback rate != 16 // queueing audio data and stretching/shrinking audio data when playback rate !=
17 // 1.0 or 0.0. 17 // 1.0 or 0.0.
18 18
19 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 19 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
20 #define MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 20 #define MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
21 21
22 #include <deque> 22 #include <deque>
23 23
24 #include "base/gtest_prod_util.h" 24 #include "base/gtest_prod_util.h"
25 #include "base/memory/weak_ptr.h"
26 #include "base/synchronization/lock.h" 25 #include "base/synchronization/lock.h"
27 #include "media/base/audio_decoder.h" 26 #include "media/base/audio_decoder.h"
28 #include "media/base/audio_renderer.h" 27 #include "media/base/audio_renderer.h"
29 #include "media/base/audio_renderer_sink.h" 28 #include "media/base/audio_renderer_sink.h"
30 #include "media/base/decryptor.h" 29 #include "media/base/decryptor.h"
31 #include "media/filters/audio_renderer_algorithm.h" 30 #include "media/filters/audio_renderer_algorithm.h"
32 31
33 namespace base { 32 namespace base {
34 class MessageLoopProxy; 33 class MessageLoopProxy;
35 } 34 }
36 35
37 namespace media { 36 namespace media {
38 37
39 class AudioDecoderSelector; 38 class AudioDecoderSelector;
40 class AudioSplicer; 39 class AudioSplicer;
41 class DecryptingDemuxerStream; 40 class DecryptingDemuxerStream;
42 41
43 class MEDIA_EXPORT AudioRendererImpl 42 class MEDIA_EXPORT AudioRendererImpl
44 : public AudioRenderer, 43 : public AudioRenderer,
45 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { 44 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
46 public: 45 public:
47 // An AudioRendererSink is used as the destination for the rendered audio. 46 // An AudioRendererSink is used as the destination for the rendered audio.
48 AudioRendererImpl(const scoped_refptr<base::MessageLoopProxy>& message_loop, 47 AudioRendererImpl(const scoped_refptr<base::MessageLoopProxy>& message_loop,
49 AudioRendererSink* sink, 48 AudioRendererSink* sink,
50 const SetDecryptorReadyCB& set_decryptor_ready_cb); 49 const SetDecryptorReadyCB& set_decryptor_ready_cb);
51 virtual ~AudioRendererImpl();
52 50
53 // AudioRenderer implementation. 51 // AudioRenderer implementation.
54 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 52 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
55 const AudioDecoderList& decoders, 53 const AudioDecoderList& decoders,
56 const PipelineStatusCB& init_cb, 54 const PipelineStatusCB& init_cb,
57 const StatisticsCB& statistics_cb, 55 const StatisticsCB& statistics_cb,
58 const base::Closure& underflow_cb, 56 const base::Closure& underflow_cb,
59 const TimeCB& time_cb, 57 const TimeCB& time_cb,
60 const base::Closure& ended_cb, 58 const base::Closure& ended_cb,
61 const base::Closure& disabled_cb, 59 const base::Closure& disabled_cb,
(...skipping 13 matching lines...) Expand all
75 // instead of some number of silence frames. Must be called prior to 73 // instead of some number of silence frames. Must be called prior to
76 // Initialize(). 74 // Initialize().
77 void DisableUnderflowForTesting(); 75 void DisableUnderflowForTesting();
78 76
79 // Allows injection of a custom time callback for non-realtime testing. 77 // Allows injection of a custom time callback for non-realtime testing.
80 typedef base::Callback<base::Time()> NowCB; 78 typedef base::Callback<base::Time()> NowCB;
81 void set_now_cb_for_testing(const NowCB& now_cb) { 79 void set_now_cb_for_testing(const NowCB& now_cb) {
82 now_cb_ = now_cb; 80 now_cb_ = now_cb;
83 } 81 }
84 82
83 protected:
84 virtual ~AudioRendererImpl();
85
85 private: 86 private:
86 friend class AudioRendererImplTest; 87 friend class AudioRendererImplTest;
87 88
88 // Callback from the audio decoder delivering decoded audio samples. 89 // Callback from the audio decoder delivering decoded audio samples.
89 void DecodedAudioReady(AudioDecoder::Status status, 90 void DecodedAudioReady(AudioDecoder::Status status,
90 const scoped_refptr<DataBuffer>& buffer); 91 const scoped_refptr<DataBuffer>& buffer);
91 92
92 // Handles buffers that come out of |splicer_|. 93 // Handles buffers that come out of |splicer_|.
93 // Returns true if more buffers are needed. 94 // Returns true if more buffers are needed.
94 bool HandleSplicerBuffer(const scoped_refptr<DataBuffer>& buffer); 95 bool HandleSplicerBuffer(const scoped_refptr<DataBuffer>& buffer);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Note: |decoder_selector| is passed here to keep the AudioDecoderSelector 153 // Note: |decoder_selector| is passed here to keep the AudioDecoderSelector
153 // alive until OnDecoderSelected() finishes. 154 // alive until OnDecoderSelected() finishes.
154 void OnDecoderSelected( 155 void OnDecoderSelected(
155 scoped_ptr<AudioDecoderSelector> decoder_selector, 156 scoped_ptr<AudioDecoderSelector> decoder_selector,
156 const scoped_refptr<AudioDecoder>& selected_decoder, 157 const scoped_refptr<AudioDecoder>& selected_decoder,
157 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); 158 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream);
158 159
159 void ResetDecoder(const base::Closure& callback); 160 void ResetDecoder(const base::Closure& callback);
160 161
161 scoped_refptr<base::MessageLoopProxy> message_loop_; 162 scoped_refptr<base::MessageLoopProxy> message_loop_;
162 base::WeakPtrFactory<AudioRendererImpl> weak_factory_;
163 base::WeakPtr<AudioRendererImpl> weak_this_;
164 163
165 scoped_ptr<AudioSplicer> splicer_; 164 scoped_ptr<AudioSplicer> splicer_;
166 165
167 // The sink (destination) for rendered audio. |sink_| must only be accessed 166 // The sink (destination) for rendered audio. |sink_| must only be accessed
168 // on |message_loop_|. |sink_| must never be called under |lock_| or else we 167 // on |message_loop_|. |sink_| must never be called under |lock_| or else we
169 // may deadlock between |message_loop_| and the audio callback thread. 168 // may deadlock between |message_loop_| and the audio callback thread.
170 scoped_refptr<media::AudioRendererSink> sink_; 169 scoped_refptr<media::AudioRendererSink> sink_;
171 170
172 SetDecryptorReadyCB set_decryptor_ready_cb_; 171 SetDecryptorReadyCB set_decryptor_ready_cb_;
173 172
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // Variables used only on the audio thread. --------------------------------- 256 // Variables used only on the audio thread. ---------------------------------
258 int actual_frames_per_buffer_; 257 int actual_frames_per_buffer_;
259 scoped_array<uint8> audio_buffer_; 258 scoped_array<uint8> audio_buffer_;
260 259
261 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 260 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
262 }; 261 };
263 262
264 } // namespace media 263 } // namespace media
265 264
266 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 265 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/video_renderer.h ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698