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

Unified Diff: media/filters/audio_renderer_algorithm_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 side-by-side diff with in-line comments
Download patch
Index: media/filters/audio_renderer_algorithm_base.cc
diff --git a/media/filters/audio_renderer_algorithm_base.cc b/media/filters/audio_renderer_algorithm_base.cc
index 8bc742de683078c4eab36776ee8db8577e323df7..57c239280c792eeb214317713171df243006038f 100644
--- a/media/filters/audio_renderer_algorithm_base.cc
+++ b/media/filters/audio_renderer_algorithm_base.cc
@@ -47,21 +47,41 @@ AudioRendererAlgorithmBase::AudioRendererAlgorithmBase()
AudioRendererAlgorithmBase::~AudioRendererAlgorithmBase() {}
+bool AudioRendererAlgorithmBase::VerifyConfig(
+ int channels,
+ int samples_per_second,
+ int bits_per_channel,
+ float initial_playback_rate) {
Ami GONE FROM CHROMIUM 2012/02/07 21:08:42 i_p_r is not inspected. Intentional?
DaleCurtis 2012/02/07 22:48:03 Yup, there was no check before, so I didn't add on
Ami GONE FROM CHROMIUM 2012/02/07 23:00:11 YAGNI principle says drop it now, add it later, if
DaleCurtis 2012/02/08 00:09:43 Done.
+ bool status = true;
+
+ if (channels <= 0 || channels > 8) {
+ DLOG(ERROR) << "We only support audio with between 1 and 8 channels.";
+ status = false;
+ }
+
+ if (samples_per_second <= 0 || samples_per_second > 256000) {
+ DLOG(ERROR) << "We only support sample rates between 1 and 256000Hz.";
+ status = false;
+ }
+
+ if (bits_per_channel != 8 && bits_per_channel != 16 &&
+ bits_per_channel != 32) {
+ DLOG(ERROR) << "We only support 8, 16, 32 bit audio.";
+ status = false;
+ }
+
+ return status;
+}
+
void AudioRendererAlgorithmBase::Initialize(
int channels,
int samples_per_second,
int bits_per_channel,
float initial_playback_rate,
const base::Closure& callback) {
- DCHECK_GT(channels, 0);
- DCHECK_LE(channels, 8) << "We only support <= 8 channel audio.";
- DCHECK_GT(samples_per_second, 0);
- DCHECK_LE(samples_per_second, 256000)
- << "We only support sample rates at or below 256000Hz.";
- DCHECK_GT(bits_per_channel, 0);
- DCHECK_LE(bits_per_channel, 32) << "We only support 8, 16, 32 bit audio.";
- DCHECK_EQ(bits_per_channel % 8, 0) << "We only support 8, 16, 32 bit audio.";
DCHECK(!callback.is_null());
+ DCHECK(VerifyConfig(channels, samples_per_second, bits_per_channel,
+ initial_playback_rate));
channels_ = channels;
samples_per_second_ = samples_per_second;

Powered by Google App Engine
This is Rietveld 408576698