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

Side by Side Diff: third_party/WebKit/Source/platform/audio/AudioUtilities.cpp

Issue 2807593003: Revert of Convert RELEASE_ASSERT()/ASSERT(...) to CHECK()/DCHECK_op(...) in platform/audio (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 18 matching lines...) Expand all
29 29
30 namespace blink { 30 namespace blink {
31 31
32 namespace AudioUtilities { 32 namespace AudioUtilities {
33 33
34 float decibelsToLinear(float decibels) { 34 float decibelsToLinear(float decibels) {
35 return powf(10, 0.05f * decibels); 35 return powf(10, 0.05f * decibels);
36 } 36 }
37 37
38 float linearToDecibels(float linear) { 38 float linearToDecibels(float linear) {
39 DCHECK_GE(linear, 0); 39 ASSERT(linear >= 0);
40 40
41 return 20 * log10f(linear); 41 return 20 * log10f(linear);
42 } 42 }
43 43
44 double discreteTimeConstantForSampleRate(double timeConstant, 44 double discreteTimeConstantForSampleRate(double timeConstant,
45 double sampleRate) { 45 double sampleRate) {
46 return 1 - exp(-1 / (sampleRate * timeConstant)); 46 return 1 - exp(-1 / (sampleRate * timeConstant));
47 } 47 }
48 48
49 size_t timeToSampleFrame(double time, double sampleRate) { 49 size_t timeToSampleFrame(double time, double sampleRate) {
50 DCHECK_GE(time, 0); 50 ASSERT(time >= 0);
51 double frame = round(time * sampleRate); 51 double frame = round(time * sampleRate);
52 52
53 // Just return the largest possible size_t value if necessary. 53 // Just return the largest possible size_t value if necessary.
54 if (frame >= std::numeric_limits<size_t>::max()) { 54 if (frame >= std::numeric_limits<size_t>::max()) {
55 return std::numeric_limits<size_t>::max(); 55 return std::numeric_limits<size_t>::max();
56 } 56 }
57 57
58 return static_cast<size_t>(frame); 58 return static_cast<size_t>(frame);
59 } 59 }
60 60
(...skipping 16 matching lines...) Expand all
77 bool isPowerOfTwo(size_t x) { 77 bool isPowerOfTwo(size_t x) {
78 // From Hacker's Delight. x & (x - 1) turns off (zeroes) the 78 // From Hacker's Delight. x & (x - 1) turns off (zeroes) the
79 // rightmost 1-bit in the word x. If x is a power of two, then the 79 // rightmost 1-bit in the word x. If x is a power of two, then the
80 // result is, of course, 0. 80 // result is, of course, 0.
81 return x > 0 && ((x & (x - 1)) == 0); 81 return x > 0 && ((x & (x - 1)) == 0);
82 } 82 }
83 83
84 } // namespace AudioUtilities 84 } // namespace AudioUtilities
85 85
86 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698