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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ASSERT(isPointerGood); |
59 if (!isPointerGood) { | 59 if (!isPointerGood) { |
60 // Should never happen in practice but return pointer to start of buffer (av
oid crash) | 60 // Should never happen in practice but return pointer to start of buffer |
| 61 // (avoid crash) |
61 if (readIndex) | 62 if (readIndex) |
62 *readIndex = 0; | 63 *readIndex = 0; |
63 return m_buffer.data(); | 64 return m_buffer.data(); |
64 } | 65 } |
65 | 66 |
66 float* sourceP = m_buffer.data(); | 67 float* sourceP = m_buffer.data(); |
67 float* p = sourceP + *readIndex; | 68 float* p = sourceP + *readIndex; |
68 | 69 |
69 // Update readIndex | 70 // Update readIndex |
70 *readIndex = (*readIndex + numberOfFrames) % bufferLength; | 71 *readIndex = (*readIndex + numberOfFrames) % bufferLength; |
71 | 72 |
72 return p; | 73 return p; |
73 } | 74 } |
74 | 75 |
75 void ReverbInputBuffer::reset() { | 76 void ReverbInputBuffer::reset() { |
76 m_buffer.zero(); | 77 m_buffer.zero(); |
77 m_writeIndex = 0; | 78 m_writeIndex = 0; |
78 } | 79 } |
79 | 80 |
80 } // namespace blink | 81 } // namespace blink |
OLD | NEW |