| 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 WebCore { | 38 namespace WebCore { |
| 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 : public AudioScheduledSourceNode { | 45 class AudioBufferSourceNode FINAL : public AudioScheduledSourceNode { |
| 46 public: | 46 public: |
| 47 static PassRefPtr<AudioBufferSourceNode> create(AudioContext*, float sampleR
ate); | 47 static PassRefPtr<AudioBufferSourceNode> create(AudioContext*, float sampleR
ate); |
| 48 | 48 |
| 49 virtual ~AudioBufferSourceNode(); | 49 virtual ~AudioBufferSourceNode(); |
| 50 | 50 |
| 51 // AudioNode | 51 // AudioNode |
| 52 virtual void process(size_t framesToProcess); | 52 virtual void process(size_t framesToProcess) OVERRIDE; |
| 53 virtual void reset(); | 53 virtual void reset() OVERRIDE; |
| 54 | 54 |
| 55 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. | 55 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. |
| 56 void setBuffer(AudioBuffer*, ExceptionState&); | 56 void setBuffer(AudioBuffer*, ExceptionState&); |
| 57 AudioBuffer* buffer() { return m_buffer.get(); } | 57 AudioBuffer* buffer() { return m_buffer.get(); } |
| 58 | 58 |
| 59 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. | 59 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. |
| 60 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. | 60 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. |
| 61 unsigned numberOfChannels(); | 61 unsigned numberOfChannels(); |
| 62 | 62 |
| 63 // Play-state | 63 // Play-state |
| (...skipping 17 matching lines...) Expand all Loading... |
| 81 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } | 81 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } |
| 82 | 82 |
| 83 AudioParam* gain() { return m_gain.get(); } | 83 AudioParam* gain() { return m_gain.get(); } |
| 84 AudioParam* playbackRate() { return m_playbackRate.get(); } | 84 AudioParam* playbackRate() { return m_playbackRate.get(); } |
| 85 | 85 |
| 86 // If a panner node is set, then we can incorporate doppler shift into the p
layback pitch rate. | 86 // If a panner node is set, then we can incorporate doppler shift into the p
layback pitch rate. |
| 87 void setPannerNode(PannerNode*); | 87 void setPannerNode(PannerNode*); |
| 88 void clearPannerNode(); | 88 void clearPannerNode(); |
| 89 | 89 |
| 90 // If we are no longer playing, propogate silence ahead to downstream nodes. | 90 // If we are no longer playing, propogate silence ahead to downstream nodes. |
| 91 virtual bool propagatesSilence() const; | 91 virtual bool propagatesSilence() const OVERRIDE; |
| 92 | 92 |
| 93 // AudioScheduledSourceNode | 93 // AudioScheduledSourceNode |
| 94 virtual void finish() OVERRIDE; | 94 virtual void finish() OVERRIDE; |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 AudioBufferSourceNode(AudioContext*, float sampleRate); | 97 AudioBufferSourceNode(AudioContext*, float sampleRate); |
| 98 | 98 |
| 99 void startPlaying(bool isGrain, double when, double grainOffset, double grai
nDuration, ExceptionState&); | 99 void startPlaying(bool isGrain, double when, double grainOffset, double grai
nDuration, ExceptionState&); |
| 100 | 100 |
| 101 // Returns true on success. | 101 // Returns true on success. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // the pitch rate. We manually manage ref-counting because we want to use Re
fTypeConnection. | 142 // the pitch rate. We manually manage ref-counting because we want to use Re
fTypeConnection. |
| 143 PannerNode* m_pannerNode; | 143 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 WebCore | 149 } // namespace WebCore |
| 150 | 150 |
| 151 #endif // AudioBufferSourceNode_h | 151 #endif // AudioBufferSourceNode_h |
| OLD | NEW |