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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // Memory can be externally referenced, or can be internally allocated with an | 48 // Memory can be externally referenced, or can be internally allocated with an |
49 // AudioFloatArray. | 49 // AudioFloatArray. |
50 | 50 |
51 // Reference an external buffer. | 51 // Reference an external buffer. |
52 AudioChannel(float* storage, size_t length) | 52 AudioChannel(float* storage, size_t length) |
53 : m_length(length), m_rawPointer(storage), m_silent(false) {} | 53 : m_length(length), m_rawPointer(storage), m_silent(false) {} |
54 | 54 |
55 // Manage storage for us. | 55 // Manage storage for us. |
56 explicit AudioChannel(size_t length) | 56 explicit AudioChannel(size_t length) |
57 : m_length(length), m_rawPointer(nullptr), m_silent(true) { | 57 : m_length(length), m_rawPointer(nullptr), m_silent(true) { |
58 m_memBuffer = wrapUnique(new AudioFloatArray(length)); | 58 m_memBuffer = WTF::wrapUnique(new AudioFloatArray(length)); |
59 } | 59 } |
60 | 60 |
61 // A "blank" audio channel -- must call set() before it's useful... | 61 // A "blank" audio channel -- must call set() before it's useful... |
62 AudioChannel() : m_length(0), m_rawPointer(nullptr), m_silent(true) {} | 62 AudioChannel() : m_length(0), m_rawPointer(nullptr), m_silent(true) {} |
63 | 63 |
64 // Redefine the memory for this channel. | 64 // Redefine the memory for this channel. |
65 // storage represents external memory not managed by this object. | 65 // storage represents external memory not managed by this object. |
66 void set(float* storage, size_t length) { | 66 void set(float* storage, size_t length) { |
67 m_memBuffer.reset(); // cleanup managed storage | 67 m_memBuffer.reset(); // cleanup managed storage |
68 m_rawPointer = storage; | 68 m_rawPointer = storage; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 size_t m_length; | 126 size_t m_length; |
127 | 127 |
128 float* m_rawPointer; | 128 float* m_rawPointer; |
129 std::unique_ptr<AudioFloatArray> m_memBuffer; | 129 std::unique_ptr<AudioFloatArray> m_memBuffer; |
130 bool m_silent; | 130 bool m_silent; |
131 }; | 131 }; |
132 | 132 |
133 } // namespace blink | 133 } // namespace blink |
134 | 134 |
135 #endif // AudioChannel_h | 135 #endif // AudioChannel_h |
OLD | NEW |