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

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

Issue 9344002: Introduce AudioRendererAlgorithmBase::VerifyConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Spacing. 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"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Construct the algorithm. 107 // Construct the algorithm.
108 algorithm_.reset(new AudioRendererAlgorithmBase()); 108 algorithm_.reset(new AudioRendererAlgorithmBase());
109 109
110 // Initialize our algorithm with media properties, initial playback rate, 110 // Initialize our algorithm with media properties, initial playback rate,
111 // and a callback to request more reads from the data source. 111 // and a callback to request more reads from the data source.
112 ChannelLayout channel_layout = decoder_->channel_layout(); 112 ChannelLayout channel_layout = decoder_->channel_layout();
113 int channels = ChannelLayoutToChannelCount(channel_layout); 113 int channels = ChannelLayoutToChannelCount(channel_layout);
114 int bits_per_channel = decoder_->bits_per_channel(); 114 int bits_per_channel = decoder_->bits_per_channel();
115 int sample_rate = decoder_->samples_per_second(); 115 int sample_rate = decoder_->samples_per_second();
116 algorithm_->Initialize(channels, sample_rate, bits_per_channel, 0.0f, cb); 116
117 bool config_ok = algorithm_->VerifyConfig(channels, sample_rate,
118 bits_per_channel, 0.0f);
119 if (config_ok)
120 algorithm_->Initialize(channels, sample_rate, bits_per_channel, 0.0f, cb);
117 121
118 // Give the subclass an opportunity to initialize itself. 122 // Give the subclass an opportunity to initialize itself.
119 if (!OnInitialize(bits_per_channel, channel_layout, sample_rate)) { 123 if (!config_ok || !OnInitialize(bits_per_channel, channel_layout,
124 sample_rate)) {
120 init_callback.Run(PIPELINE_ERROR_INITIALIZATION_FAILED); 125 init_callback.Run(PIPELINE_ERROR_INITIALIZATION_FAILED);
121 return; 126 return;
122 } 127 }
123 128
124 // Finally, execute the start callback. 129 // Finally, execute the start callback.
125 state_ = kPaused; 130 state_ = kPaused;
126 init_callback.Run(PIPELINE_OK); 131 init_callback.Run(PIPELINE_OK);
127 } 132 }
128 133
129 bool AudioRendererBase::HasEnded() { 134 bool AudioRendererBase::HasEnded() {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 base::AutoLock auto_lock(lock_); 301 base::AutoLock auto_lock(lock_);
297 return algorithm_->playback_rate(); 302 return algorithm_->playback_rate();
298 } 303 }
299 304
300 bool AudioRendererBase::IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer) { 305 bool AudioRendererBase::IsBeforeSeekTime(const scoped_refptr<Buffer>& buffer) {
301 return (state_ == kSeeking) && buffer && !buffer->IsEndOfStream() && 306 return (state_ == kSeeking) && buffer && !buffer->IsEndOfStream() &&
302 (buffer->GetTimestamp() + buffer->GetDuration()) < seek_timestamp_; 307 (buffer->GetTimestamp() + buffer->GetDuration()) < seek_timestamp_;
303 } 308 }
304 309
305 } // namespace media 310 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698