OLD | NEW |
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 26 matching lines...) Expand all Loading... |
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 DCHECK(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 DCHECK_LE(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; |
(...skipping 14 matching lines...) Expand all Loading... |
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 |
OLD | NEW |