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

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

Issue 2604683002: Remove ASSERT_NOT_REACHED() in audio. (Closed)
Patch Set: fixed. Created 3 years, 11 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 distance = clampTo(distance, m_refDistance, m_maxDistance); 46 distance = clampTo(distance, m_refDistance, m_maxDistance);
47 47
48 switch (m_model) { 48 switch (m_model) {
49 case ModelLinear: 49 case ModelLinear:
50 return linearGain(distance); 50 return linearGain(distance);
51 case ModelInverse: 51 case ModelInverse:
52 return inverseGain(distance); 52 return inverseGain(distance);
53 case ModelExponential: 53 case ModelExponential:
54 return exponentialGain(distance); 54 return exponentialGain(distance);
55 } 55 }
56 ASSERT_NOT_REACHED(); 56 NOTREACHED();
57 return 0.0; 57 return 0.0;
58 } 58 }
59 59
60 double DistanceEffect::linearGain(double distance) { 60 double DistanceEffect::linearGain(double distance) {
61 // We want a gain that decreases linearly from m_refDistance to 61 // We want a gain that decreases linearly from m_refDistance to
62 // m_maxDistance. The gain is 1 at m_refDistance. 62 // m_maxDistance. The gain is 1 at m_refDistance.
63 return (1.0 - 63 return (1.0 -
64 clampTo(m_rolloffFactor, 0.0, 1.0) * (distance - m_refDistance) / 64 clampTo(m_rolloffFactor, 0.0, 1.0) * (distance - m_refDistance) /
65 (m_maxDistance - m_refDistance)); 65 (m_maxDistance - m_refDistance));
66 } 66 }
67 67
68 double DistanceEffect::inverseGain(double distance) { 68 double DistanceEffect::inverseGain(double distance) {
69 return m_refDistance / 69 return m_refDistance /
70 (m_refDistance + 70 (m_refDistance +
71 clampTo(m_rolloffFactor, 0.0) * (distance - m_refDistance)); 71 clampTo(m_rolloffFactor, 0.0) * (distance - m_refDistance));
72 } 72 }
73 73
74 double DistanceEffect::exponentialGain(double distance) { 74 double DistanceEffect::exponentialGain(double distance) {
75 return pow(distance / m_refDistance, -clampTo(m_rolloffFactor, 0.0)); 75 return pow(distance / m_refDistance, -clampTo(m_rolloffFactor, 0.0));
76 } 76 }
77 77
78 } // namespace blink 78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698