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

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

Issue 2803733002: Convert ASSERT(foo) to DCHECK(foo) in platform/audio (Closed)
Patch Set: Mechanical change from ASSERT(foo) to DCHECK(foo) 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 * 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 24 matching lines...) Expand all
35 35
36 ReverbAccumulationBuffer::ReverbAccumulationBuffer(size_t length) 36 ReverbAccumulationBuffer::ReverbAccumulationBuffer(size_t length)
37 : m_buffer(length), m_readIndex(0), m_readTimeFrame(0) {} 37 : m_buffer(length), m_readIndex(0), m_readTimeFrame(0) {}
38 38
39 void ReverbAccumulationBuffer::readAndClear(float* destination, 39 void ReverbAccumulationBuffer::readAndClear(float* destination,
40 size_t numberOfFrames) { 40 size_t numberOfFrames) {
41 size_t bufferLength = m_buffer.size(); 41 size_t bufferLength = m_buffer.size();
42 bool isCopySafe = 42 bool isCopySafe =
43 m_readIndex <= bufferLength && numberOfFrames <= bufferLength; 43 m_readIndex <= bufferLength && numberOfFrames <= bufferLength;
44 44
45 ASSERT(isCopySafe); 45 DCHECK(isCopySafe);
46 if (!isCopySafe) 46 if (!isCopySafe)
47 return; 47 return;
48 48
49 size_t framesAvailable = bufferLength - m_readIndex; 49 size_t framesAvailable = bufferLength - m_readIndex;
50 size_t numberOfFrames1 = std::min(numberOfFrames, framesAvailable); 50 size_t numberOfFrames1 = std::min(numberOfFrames, framesAvailable);
51 size_t numberOfFrames2 = numberOfFrames - numberOfFrames1; 51 size_t numberOfFrames2 = numberOfFrames - numberOfFrames1;
52 52
53 float* source = m_buffer.data(); 53 float* source = m_buffer.data();
54 memcpy(destination, source + m_readIndex, sizeof(float) * numberOfFrames1); 54 memcpy(destination, source + m_readIndex, sizeof(float) * numberOfFrames1);
55 memset(source + m_readIndex, 0, sizeof(float) * numberOfFrames1); 55 memset(source + m_readIndex, 0, sizeof(float) * numberOfFrames1);
(...skipping 28 matching lines...) Expand all
84 84
85 size_t framesAvailable = bufferLength - writeIndex; 85 size_t framesAvailable = bufferLength - writeIndex;
86 size_t numberOfFrames1 = std::min(numberOfFrames, framesAvailable); 86 size_t numberOfFrames1 = std::min(numberOfFrames, framesAvailable);
87 size_t numberOfFrames2 = numberOfFrames - numberOfFrames1; 87 size_t numberOfFrames2 = numberOfFrames - numberOfFrames1;
88 88
89 float* destination = m_buffer.data(); 89 float* destination = m_buffer.data();
90 90
91 bool isSafe = writeIndex <= bufferLength && 91 bool isSafe = writeIndex <= bufferLength &&
92 numberOfFrames1 + writeIndex <= bufferLength && 92 numberOfFrames1 + writeIndex <= bufferLength &&
93 numberOfFrames2 <= bufferLength; 93 numberOfFrames2 <= bufferLength;
94 ASSERT(isSafe); 94 DCHECK(isSafe);
95 if (!isSafe) 95 if (!isSafe)
96 return 0; 96 return 0;
97 97
98 vadd(source, 1, destination + writeIndex, 1, destination + writeIndex, 1, 98 vadd(source, 1, destination + writeIndex, 1, destination + writeIndex, 1,
99 numberOfFrames1); 99 numberOfFrames1);
100 100
101 // Handle wrap-around if necessary 101 // Handle wrap-around if necessary
102 if (numberOfFrames2 > 0) 102 if (numberOfFrames2 > 0)
103 vadd(source + numberOfFrames1, 1, destination, 1, destination, 1, 103 vadd(source + numberOfFrames1, 1, destination, 1, destination, 1,
104 numberOfFrames2); 104 numberOfFrames2);
105 105
106 return writeIndex; 106 return writeIndex;
107 } 107 }
108 108
109 void ReverbAccumulationBuffer::reset() { 109 void ReverbAccumulationBuffer::reset() {
110 m_buffer.zero(); 110 m_buffer.zero();
111 m_readIndex = 0; 111 m_readIndex = 0;
112 m_readTimeFrame = 0; 112 m_readTimeFrame = 0;
113 } 113 }
114 114
115 } // namespace blink 115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/Reverb.cpp ('k') | third_party/WebKit/Source/platform/audio/ReverbConvolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698