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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. | 54 // setBuffer() is called on the main thread. This is the buffer we use for p
layback. |
55 void setBuffer(AudioBuffer*, ExceptionState&); | 55 void setBuffer(AudioBuffer*, ExceptionState&); |
56 AudioBuffer* buffer() { return m_buffer.get(); } | 56 AudioBuffer* buffer() { return m_buffer.get(); } |
57 | 57 |
58 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. | 58 // numberOfChannels() returns the number of output channels. This value equ
als the number of channels from the buffer. |
59 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. | 59 // If a new buffer is set with a different number of channels, then this val
ue will dynamically change. |
60 unsigned numberOfChannels(); | 60 unsigned numberOfChannels(); |
61 | 61 |
62 // Play-state | 62 // Play-state |
63 void start(ExceptionState&); | 63 void start(ExceptionState& exceptionState) { start(0, exceptionState); } |
64 void start(double when, ExceptionState&); | 64 void start(double when, ExceptionState&); |
65 void start(double when, double grainOffset, ExceptionState&); | 65 void start(double when, double grainOffset, ExceptionState&); |
66 void start(double when, double grainOffset, double grainDuration, ExceptionS
tate&); | 66 void start(double when, double grainOffset, double grainDuration, ExceptionS
tate&); |
67 | 67 |
68 void noteGrainOn(double when, double grainOffset, double grainDuration, Exce
ptionState&); | 68 void noteGrainOn(double when, double grainOffset, double grainDuration, Exce
ptionState&); |
69 | 69 |
70 // Note: the attribute was originally exposed as .looping, but to be more co
nsistent in naming with <audio> | 70 // Note: the attribute was originally exposed as .looping, but to be more co
nsistent in naming with <audio> |
71 // and with how it's described in the specification, the proper attribute na
me is .loop | 71 // and with how it's described in the specification, the proper attribute na
me is .loop |
72 // The old attribute is kept for backwards compatibility. | 72 // The old attribute is kept for backwards compatibility. |
73 bool loop() const { return m_isLooping; } | 73 bool loop() const { return m_isLooping; } |
(...skipping 14 matching lines...) Expand all Loading... |
88 | 88 |
89 // If we are no longer playing, propogate silence ahead to downstream nodes. | 89 // If we are no longer playing, propogate silence ahead to downstream nodes. |
90 virtual bool propagatesSilence() const OVERRIDE; | 90 virtual bool propagatesSilence() const OVERRIDE; |
91 | 91 |
92 // AudioScheduledSourceNode | 92 // AudioScheduledSourceNode |
93 virtual void finish() OVERRIDE; | 93 virtual void finish() OVERRIDE; |
94 | 94 |
95 private: | 95 private: |
96 AudioBufferSourceNode(AudioContext*, float sampleRate); | 96 AudioBufferSourceNode(AudioContext*, float sampleRate); |
97 | 97 |
98 void startPlaying(bool isGrain, double when, double grainOffset, double grai
nDuration, ExceptionState&); | |
99 | |
100 // Returns true on success. | 98 // Returns true on success. |
101 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); | 99 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); |
102 | 100 |
103 // Render silence starting from "index" frame in AudioBus. | 101 // Render silence starting from "index" frame in AudioBus. |
104 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si
ze_t framesToProcess); | 102 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si
ze_t framesToProcess); |
105 | 103 |
106 // m_buffer holds the sample data which this node outputs. | 104 // m_buffer holds the sample data which this node outputs. |
107 RefPtr<AudioBuffer> m_buffer; | 105 RefPtr<AudioBuffer> m_buffer; |
108 | 106 |
109 // Pointers for the buffer and destination. | 107 // Pointers for the buffer and destination. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // the pitch rate. We manually manage ref-counting because we want to use Re
fTypeConnection. | 139 // the pitch rate. We manually manage ref-counting because we want to use Re
fTypeConnection. |
142 PannerNode* m_pannerNode; | 140 PannerNode* m_pannerNode; |
143 | 141 |
144 // This synchronizes process() with setBuffer() which can cause dynamic chan
nel count changes. | 142 // This synchronizes process() with setBuffer() which can cause dynamic chan
nel count changes. |
145 mutable Mutex m_processLock; | 143 mutable Mutex m_processLock; |
146 }; | 144 }; |
147 | 145 |
148 } // namespace WebCore | 146 } // namespace WebCore |
149 | 147 |
150 #endif // AudioBufferSourceNode_h | 148 #endif // AudioBufferSourceNode_h |
OLD | NEW |