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

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

Issue 15872004: Disable preroll duration increase on underflow for MediaSource playback. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address CR comments Created 7 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
« no previous file with comments | « media/base/pipeline.cc ('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)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { 45 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
46 public: 46 public:
47 // |message_loop| is the thread on which AudioRendererImpl will execute. 47 // |message_loop| is the thread on which AudioRendererImpl will execute.
48 // 48 //
49 // |sink| is used as the destination for the rendered audio. 49 // |sink| is used as the destination for the rendered audio.
50 // 50 //
51 // |decoders| contains the AudioDecoders to use when initializing. 51 // |decoders| contains the AudioDecoders to use when initializing.
52 // 52 //
53 // |set_decryptor_ready_cb| is fired when the audio decryptor is available 53 // |set_decryptor_ready_cb| is fired when the audio decryptor is available
54 // (only applicable if the stream is encrypted and we have a decryptor). 54 // (only applicable if the stream is encrypted and we have a decryptor).
55 //
56 // |increase_preroll_on_underflow| Set to true if the preroll duration
57 // should be increased when ResumeAfterUnderflow() is called.
55 AudioRendererImpl(const scoped_refptr<base::MessageLoopProxy>& message_loop, 58 AudioRendererImpl(const scoped_refptr<base::MessageLoopProxy>& message_loop,
56 AudioRendererSink* sink, 59 AudioRendererSink* sink,
57 ScopedVector<AudioDecoder> decoders, 60 ScopedVector<AudioDecoder> decoders,
58 const SetDecryptorReadyCB& set_decryptor_ready_cb); 61 const SetDecryptorReadyCB& set_decryptor_ready_cb,
62 bool increase_preroll_on_underflow);
59 virtual ~AudioRendererImpl(); 63 virtual ~AudioRendererImpl();
60 64
61 // AudioRenderer implementation. 65 // AudioRenderer implementation.
62 virtual void Initialize(DemuxerStream* stream, 66 virtual void Initialize(DemuxerStream* stream,
63 const PipelineStatusCB& init_cb, 67 const PipelineStatusCB& init_cb,
64 const StatisticsCB& statistics_cb, 68 const StatisticsCB& statistics_cb,
65 const base::Closure& underflow_cb, 69 const base::Closure& underflow_cb,
66 const TimeCB& time_cb, 70 const TimeCB& time_cb,
67 const base::Closure& ended_cb, 71 const base::Closure& ended_cb,
68 const base::Closure& disabled_cb, 72 const base::Closure& disabled_cb,
69 const PipelineStatusCB& error_cb) OVERRIDE; 73 const PipelineStatusCB& error_cb) OVERRIDE;
70 virtual void Play(const base::Closure& callback) OVERRIDE; 74 virtual void Play(const base::Closure& callback) OVERRIDE;
71 virtual void Pause(const base::Closure& callback) OVERRIDE; 75 virtual void Pause(const base::Closure& callback) OVERRIDE;
72 virtual void Flush(const base::Closure& callback) OVERRIDE; 76 virtual void Flush(const base::Closure& callback) OVERRIDE;
73 virtual void Stop(const base::Closure& callback) OVERRIDE; 77 virtual void Stop(const base::Closure& callback) OVERRIDE;
74 virtual void SetPlaybackRate(float rate) OVERRIDE; 78 virtual void SetPlaybackRate(float rate) OVERRIDE;
75 virtual void Preroll(base::TimeDelta time, 79 virtual void Preroll(base::TimeDelta time,
76 const PipelineStatusCB& cb) OVERRIDE; 80 const PipelineStatusCB& cb) OVERRIDE;
77 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; 81 virtual void ResumeAfterUnderflow() OVERRIDE;
78 virtual void SetVolume(float volume) OVERRIDE; 82 virtual void SetVolume(float volume) OVERRIDE;
79 83
80 // Disables underflow support. When used, |state_| will never transition to 84 // Disables underflow support. When used, |state_| will never transition to
81 // kUnderflow resulting in Render calls that underflow returning 0 frames 85 // kUnderflow resulting in Render calls that underflow returning 0 frames
82 // instead of some number of silence frames. Must be called prior to 86 // instead of some number of silence frames. Must be called prior to
83 // Initialize(). 87 // Initialize().
84 void DisableUnderflowForTesting(); 88 void DisableUnderflowForTesting();
85 89
86 // Allows injection of a custom time callback for non-realtime testing. 90 // Allows injection of a custom time callback for non-realtime testing.
87 typedef base::Callback<base::Time()> NowCB; 91 typedef base::Callback<base::Time()> NowCB;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // Instead of trying to invent OS-specific solution for each and every OS we 253 // Instead of trying to invent OS-specific solution for each and every OS we
250 // are supporting, use simple workaround: every time we fill the buffer we 254 // are supporting, use simple workaround: every time we fill the buffer we
251 // remember when it should stop playing, and do not assume that buffer is 255 // remember when it should stop playing, and do not assume that buffer is
252 // empty till that time. Workaround is not bulletproof, as we don't exactly 256 // empty till that time. Workaround is not bulletproof, as we don't exactly
253 // know when that particular data would start playing, but it is much better 257 // know when that particular data would start playing, but it is much better
254 // than nothing. 258 // than nothing.
255 base::Time earliest_end_time_; 259 base::Time earliest_end_time_;
256 size_t total_frames_filled_; 260 size_t total_frames_filled_;
257 261
258 bool underflow_disabled_; 262 bool underflow_disabled_;
263 bool increase_preroll_on_underflow_;
259 264
260 // True if the renderer receives a buffer with kAborted status during preroll, 265 // True if the renderer receives a buffer with kAborted status during preroll,
261 // false otherwise. This flag is cleared on the next Preroll() call. 266 // false otherwise. This flag is cleared on the next Preroll() call.
262 bool preroll_aborted_; 267 bool preroll_aborted_;
263 268
264 // End variables which must be accessed under |lock_|. ---------------------- 269 // End variables which must be accessed under |lock_|. ----------------------
265 270
266 // Variables used only on the audio thread. --------------------------------- 271 // Variables used only on the audio thread. ---------------------------------
267 int actual_frames_per_buffer_; 272 int actual_frames_per_buffer_;
268 scoped_ptr<uint8[]> audio_buffer_; 273 scoped_ptr<uint8[]> audio_buffer_;
269 274
270 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 275 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
271 }; 276 };
272 277
273 } // namespace media 278 } // namespace media
274 279
275 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 280 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/filters/audio_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698