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

Side by Side Diff: third_party/WebKit/Source/platform/audio/ReverbInputBuffer.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 18 matching lines...) Expand all
29 #include "platform/audio/ReverbInputBuffer.h" 29 #include "platform/audio/ReverbInputBuffer.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 ReverbInputBuffer::ReverbInputBuffer(size_t length) 33 ReverbInputBuffer::ReverbInputBuffer(size_t length)
34 : m_buffer(length), m_writeIndex(0) {} 34 : m_buffer(length), m_writeIndex(0) {}
35 35
36 void ReverbInputBuffer::write(const float* sourceP, size_t numberOfFrames) { 36 void ReverbInputBuffer::write(const float* sourceP, size_t numberOfFrames) {
37 size_t bufferLength = m_buffer.size(); 37 size_t bufferLength = m_buffer.size();
38 bool isCopySafe = m_writeIndex + numberOfFrames <= bufferLength; 38 bool isCopySafe = m_writeIndex + numberOfFrames <= bufferLength;
39 ASSERT(isCopySafe); 39 DCHECK(isCopySafe);
40 if (!isCopySafe) 40 if (!isCopySafe)
41 return; 41 return;
42 42
43 memcpy(m_buffer.data() + m_writeIndex, sourceP, 43 memcpy(m_buffer.data() + m_writeIndex, sourceP,
44 sizeof(float) * numberOfFrames); 44 sizeof(float) * numberOfFrames);
45 45
46 m_writeIndex += numberOfFrames; 46 m_writeIndex += numberOfFrames;
47 ASSERT(m_writeIndex <= bufferLength); 47 ASSERT(m_writeIndex <= bufferLength);
48 48
49 if (m_writeIndex >= bufferLength) 49 if (m_writeIndex >= bufferLength)
50 m_writeIndex = 0; 50 m_writeIndex = 0;
51 } 51 }
52 52
53 float* ReverbInputBuffer::directReadFrom(int* readIndex, 53 float* ReverbInputBuffer::directReadFrom(int* readIndex,
54 size_t numberOfFrames) { 54 size_t numberOfFrames) {
55 size_t bufferLength = m_buffer.size(); 55 size_t bufferLength = m_buffer.size();
56 bool isPointerGood = readIndex && *readIndex >= 0 && 56 bool isPointerGood = readIndex && *readIndex >= 0 &&
57 *readIndex + numberOfFrames <= bufferLength; 57 *readIndex + numberOfFrames <= bufferLength;
58 ASSERT(isPointerGood); 58 DCHECK(isPointerGood);
59 if (!isPointerGood) { 59 if (!isPointerGood) {
60 // Should never happen in practice but return pointer to start of buffer 60 // Should never happen in practice but return pointer to start of buffer
61 // (avoid crash) 61 // (avoid crash)
62 if (readIndex) 62 if (readIndex)
63 *readIndex = 0; 63 *readIndex = 0;
64 return m_buffer.data(); 64 return m_buffer.data();
65 } 65 }
66 66
67 float* sourceP = m_buffer.data(); 67 float* sourceP = m_buffer.data();
68 float* p = sourceP + *readIndex; 68 float* p = sourceP + *readIndex;
69 69
70 // Update readIndex 70 // Update readIndex
71 *readIndex = (*readIndex + numberOfFrames) % bufferLength; 71 *readIndex = (*readIndex + numberOfFrames) % bufferLength;
72 72
73 return p; 73 return p;
74 } 74 }
75 75
76 void ReverbInputBuffer::reset() { 76 void ReverbInputBuffer::reset() {
77 m_buffer.zero(); 77 m_buffer.zero();
78 m_writeIndex = 0; 78 m_writeIndex = 0;
79 } 79 }
80 80
81 } // namespace blink 81 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698