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

Side by Side Diff: media/filters/audio_renderer_base.cc

Issue 9325044: Remove AudioDecoder from the Filter heirarchy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved audio_decoder_ out of Pipeline; AudioRendererBase is in charge of it now. Created 8 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
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 #include "media/filters/audio_renderer_base.h" 5 #include "media/filters/audio_renderer_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "media/base/audio_decoder.h"
scherkus (not reviewing) 2012/02/06 21:04:04 this is included in .h
Ami GONE FROM CHROMIUM 2012/02/06 21:38:48 Done.
13 #include "media/base/filter_host.h" 14 #include "media/base/filter_host.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 AudioRendererBase::AudioRendererBase() 18 AudioRendererBase::AudioRendererBase()
18 : state_(kUninitialized), 19 : state_(kUninitialized),
19 pending_read_(false), 20 pending_read_(false),
20 recieved_end_of_stream_(false), 21 recieved_end_of_stream_(false),
21 rendered_end_of_stream_(false), 22 rendered_end_of_stream_(false),
22 read_cb_(base::Bind(&AudioRendererBase::DecodedAudioReady, 23 read_cb_(base::Bind(&AudioRendererBase::DecodedAudioReady,
(...skipping 21 matching lines...) Expand all
44 45
45 // Pause only when we've completed our pending read. 46 // Pause only when we've completed our pending read.
46 if (!pending_read_) { 47 if (!pending_read_) {
47 pause_callback_.Run(); 48 pause_callback_.Run();
48 pause_callback_.Reset(); 49 pause_callback_.Reset();
49 } else { 50 } else {
50 state_ = kPaused; 51 state_ = kPaused;
51 } 52 }
52 } 53 }
53 54
55 void AudioRendererBase::Flush(const base::Closure& callback) {
56 decoder_->Reset(callback);
57 }
58
54 void AudioRendererBase::Stop(const base::Closure& callback) { 59 void AudioRendererBase::Stop(const base::Closure& callback) {
55 OnStop(); 60 OnStop();
56 { 61 {
57 base::AutoLock auto_lock(lock_); 62 base::AutoLock auto_lock(lock_);
58 state_ = kStopped; 63 state_ = kStopped;
59 algorithm_.reset(NULL); 64 algorithm_.reset(NULL);
60 audio_time_cb_.Reset(); 65 audio_time_cb_.Reset();
61 underflow_callback_.Reset(); 66 underflow_callback_.Reset();
62 } 67 }
63 if (!callback.is_null()) { 68 if (!callback.is_null()) {
(...skipping 13 matching lines...) Expand all
77 82
78 // Throw away everything and schedule our reads. 83 // Throw away everything and schedule our reads.
79 last_fill_buffer_time_ = base::TimeDelta(); 84 last_fill_buffer_time_ = base::TimeDelta();
80 recieved_end_of_stream_ = false; 85 recieved_end_of_stream_ = false;
81 rendered_end_of_stream_ = false; 86 rendered_end_of_stream_ = false;
82 87
83 // |algorithm_| will request more reads. 88 // |algorithm_| will request more reads.
84 algorithm_->FlushBuffers(); 89 algorithm_->FlushBuffers();
85 } 90 }
86 91
87 void AudioRendererBase::Initialize(AudioDecoder* decoder, 92 void AudioRendererBase::Initialize(const scoped_refptr<AudioDecoder> decoder,
scherkus (not reviewing) 2012/02/06 21:04:04 const-ref
Ami GONE FROM CHROMIUM 2012/02/06 21:38:48 Done.
88 const PipelineStatusCB& init_callback, 93 const PipelineStatusCB& init_callback,
89 const base::Closure& underflow_callback, 94 const base::Closure& underflow_callback,
90 const AudioTimeCB& audio_time_cb) { 95 const AudioTimeCB& audio_time_cb) {
91 DCHECK(decoder); 96 DCHECK(decoder);
92 DCHECK(!init_callback.is_null()); 97 DCHECK(!init_callback.is_null());
93 DCHECK(!underflow_callback.is_null()); 98 DCHECK(!underflow_callback.is_null());
94 DCHECK(!audio_time_cb.is_null()); 99 DCHECK(!audio_time_cb.is_null());
95 DCHECK_EQ(kUninitialized, state_); 100 DCHECK_EQ(kUninitialized, state_);
96 decoder_ = decoder; 101 decoder_ = decoder;
97 underflow_callback_ = underflow_callback; 102 underflow_callback_ = underflow_callback;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 base::AutoLock auto_lock(lock_); 297 base::AutoLock auto_lock(lock_);
293 return algorithm_->playback_rate(); 298 return algorithm_->playback_rate();
294 } 299 }
295 300
296 bool AudioRendererBase::IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer) { 301 bool AudioRendererBase::IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer) {
297 return (state_ == kSeeking) && buffer && !buffer->IsEndOfStream() && 302 return (state_ == kSeeking) && buffer && !buffer->IsEndOfStream() &&
298 (buffer->GetTimestamp() + buffer->GetDuration()) < seek_timestamp_; 303 (buffer->GetTimestamp() + buffer->GetDuration()) < seek_timestamp_;
299 } 304 }
300 305
301 } // namespace media 306 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698