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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
36 #include "wtf/Threading.h" | 36 #include "wtf/Threading.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 class AudioContext; | 40 class AudioContext; |
41 | 41 |
42 // AudioBufferSourceNode is an AudioNode representing an audio source from an in
-memory audio asset represented by an AudioBuffer. | 42 // AudioBufferSourceNode is an AudioNode representing an audio source from an in
-memory audio asset represented by an AudioBuffer. |
43 // It generally will be used for short sounds which require a high degree of sch
eduling flexibility (can playback in rhythmically perfect ways). | 43 // It generally will be used for short sounds which require a high degree of sch
eduling flexibility (can playback in rhythmically perfect ways). |
44 | 44 |
45 class AudioBufferSourceNode FINAL : public AudioScheduledSourceNode { | 45 class AudioBufferSourceNode final : public AudioScheduledSourceNode { |
46 DEFINE_WRAPPERTYPEINFO(); | 46 DEFINE_WRAPPERTYPEINFO(); |
47 public: | 47 public: |
48 static AudioBufferSourceNode* create(AudioContext*, float sampleRate); | 48 static AudioBufferSourceNode* create(AudioContext*, float sampleRate); |
49 | 49 |
50 virtual ~AudioBufferSourceNode(); | 50 virtual ~AudioBufferSourceNode(); |
51 | 51 |
52 // AudioNode | 52 // AudioNode |
53 virtual void dispose() OVERRIDE; | 53 virtual void dispose() override; |
54 virtual void process(size_t framesToProcess) OVERRIDE; | 54 virtual void process(size_t framesToProcess) override; |
55 | 55 |
56 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. | 56 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. |
57 void setBuffer(AudioBuffer*, ExceptionState&); | 57 void setBuffer(AudioBuffer*, ExceptionState&); |
58 AudioBuffer* buffer() { return m_buffer.get(); } | 58 AudioBuffer* buffer() { return m_buffer.get(); } |
59 | 59 |
60 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. | 60 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. |
61 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. | 61 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. |
62 unsigned numberOfChannels(); | 62 unsigned numberOfChannels(); |
63 | 63 |
64 // Play-state | 64 // Play-state |
(...skipping 14 matching lines...) Expand all Loading... |
79 void setLoopStart(double loopStart) { m_loopStart = loopStart; } | 79 void setLoopStart(double loopStart) { m_loopStart = loopStart; } |
80 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } | 80 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } |
81 | 81 |
82 AudioParam* playbackRate() { return m_playbackRate.get(); } | 82 AudioParam* playbackRate() { return m_playbackRate.get(); } |
83 | 83 |
84 // If a panner node is set, then we can incorporate doppler shift into the p
layback pitch rate. | 84 // If a panner node is set, then we can incorporate doppler shift into the p
layback pitch rate. |
85 void setPannerNode(PannerNode*); | 85 void setPannerNode(PannerNode*); |
86 void clearPannerNode(); | 86 void clearPannerNode(); |
87 | 87 |
88 // If we are no longer playing, propogate silence ahead to downstream nodes. | 88 // If we are no longer playing, propogate silence ahead to downstream nodes. |
89 virtual bool propagatesSilence() const OVERRIDE; | 89 virtual bool propagatesSilence() const override; |
90 | 90 |
91 // AudioScheduledSourceNode | 91 // AudioScheduledSourceNode |
92 virtual void finish() OVERRIDE; | 92 virtual void finish() override; |
93 | 93 |
94 virtual void trace(Visitor*) OVERRIDE; | 94 virtual void trace(Visitor*) override; |
95 | 95 |
96 private: | 96 private: |
97 AudioBufferSourceNode(AudioContext*, float sampleRate); | 97 AudioBufferSourceNode(AudioContext*, float sampleRate); |
98 | 98 |
99 // Returns true on success. | 99 // Returns true on success. |
100 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); | 100 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); |
101 | 101 |
102 // Render silence starting from "index" frame in AudioBus. | 102 // Render silence starting from "index" frame in AudioBus. |
103 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si
ze_t framesToProcess); | 103 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si
ze_t framesToProcess); |
104 | 104 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // AudioNode::breakConnection() when we remove an AudioNode from this. | 142 // AudioNode::breakConnection() when we remove an AudioNode from this. |
143 Member<PannerNode> m_pannerNode; | 143 Member<PannerNode> m_pannerNode; |
144 | 144 |
145 // This synchronizes process() with setBuffer() which can cause dynamic chan
nel count changes. | 145 // This synchronizes process() with setBuffer() which can cause dynamic chan
nel count changes. |
146 mutable Mutex m_processLock; | 146 mutable Mutex m_processLock; |
147 }; | 147 }; |
148 | 148 |
149 } // namespace blink | 149 } // namespace blink |
150 | 150 |
151 #endif // AudioBufferSourceNode_h | 151 #endif // AudioBufferSourceNode_h |
OLD | NEW |