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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #ifndef WebAudioBus_h | 25 #ifndef WebAudioBus_h |
26 #define WebAudioBus_h | 26 #define WebAudioBus_h |
27 | 27 |
28 #include "WebCommon.h" | 28 #include "WebCommon.h" |
29 | 29 |
30 #if INSIDE_BLINK | 30 #if INSIDE_BLINK |
31 namespace WTF { | 31 namespace WTF { |
32 template <typename T> | 32 template <typename T> |
33 class PassRefPtr; | 33 class PassRefPtr; |
34 } | 34 } |
35 #endif | 35 #endif |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class AudioBus; | 39 class AudioBus; |
40 | 40 |
41 // A container for multi-channel linear PCM audio data. | 41 // A container for multi-channel linear PCM audio data. |
42 // | 42 // |
43 // WARNING: It is not safe to pass a WebAudioBus across threads!!! | 43 // WARNING: It is not safe to pass a WebAudioBus across threads!!! |
44 // | 44 // |
45 class BLINK_PLATFORM_EXPORT WebAudioBus { | 45 class BLINK_PLATFORM_EXPORT WebAudioBus { |
46 public: | 46 public: |
47 WebAudioBus() : m_private(0) {} | 47 WebAudioBus() : m_private(0) {} |
48 ~WebAudioBus() { reset(); } | 48 ~WebAudioBus() { reset(); } |
49 | 49 |
50 // initialize() allocates memory of the given length for the given number of c
hannels. | 50 // initialize() allocates memory of the given length for the given number of |
| 51 // channels. |
51 void initialize(unsigned numberOfChannels, size_t length, double sampleRate); | 52 void initialize(unsigned numberOfChannels, size_t length, double sampleRate); |
52 | 53 |
53 // resizeSmaller() can only be called after initialize() with a new length <=
the initialization length. | 54 // resizeSmaller() can only be called after initialize() with a new length <= |
54 // The data stored in the bus will remain undisturbed. | 55 // the initialization length. The data stored in the bus will remain |
| 56 // undisturbed. |
55 void resizeSmaller(size_t newLength); | 57 void resizeSmaller(size_t newLength); |
56 | 58 |
57 // reset() releases the memory allocated from initialize(). | 59 // reset() releases the memory allocated from initialize(). |
58 void reset(); | 60 void reset(); |
59 | 61 |
60 unsigned numberOfChannels() const; | 62 unsigned numberOfChannels() const; |
61 size_t length() const; | 63 size_t length() const; |
62 double sampleRate() const; | 64 double sampleRate() const; |
63 | 65 |
64 float* channelData(unsigned channelIndex); | 66 float* channelData(unsigned channelIndex); |
65 | 67 |
66 #if INSIDE_BLINK | 68 #if INSIDE_BLINK |
67 WTF::PassRefPtr<AudioBus> release(); | 69 WTF::PassRefPtr<AudioBus> release(); |
68 #endif | 70 #endif |
69 | 71 |
70 private: | 72 private: |
71 // Disallow copy and assign. | 73 // Disallow copy and assign. |
72 WebAudioBus(const WebAudioBus&); | 74 WebAudioBus(const WebAudioBus&); |
73 void operator=(const WebAudioBus&); | 75 void operator=(const WebAudioBus&); |
74 | 76 |
75 AudioBus* m_private; | 77 AudioBus* m_private; |
76 }; | 78 }; |
77 | 79 |
78 } // namespace blink | 80 } // namespace blink |
79 | 81 |
80 #endif // WebAudioBus_h | 82 #endif // WebAudioBus_h |
OLD | NEW |