Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: Source/modules/webaudio/AudioBufferSourceNode.h

Issue 54173005: Signal exceptions if start/stop is called out-of-order or too many times. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
64 void start(double when = 0); 64 void start(ExceptionState&);
65 void start(double when, double grainOffset); 65 void start(double when, ExceptionState&);
66 void start(double when, double grainOffset, double grainDuration); 66 void start(double when, double grainOffset, ExceptionState&);
67 void start(double when, double grainOffset, double grainDuration, ExceptionS tate&);
67 68
68 void noteGrainOn(double when, double grainOffset, double grainDuration); 69 void noteGrainOn(double when, double grainOffset, double grainDuration, Exce ptionState&);
69 70
70 // Note: the attribute was originally exposed as .looping, but to be more co nsistent in naming with <audio> 71 // 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 72 // 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. 73 // The old attribute is kept for backwards compatibility.
73 bool loop() const { return m_isLooping; } 74 bool loop() const { return m_isLooping; }
74 void setLoop(bool looping) { m_isLooping = looping; } 75 void setLoop(bool looping) { m_isLooping = looping; }
75 76
76 // Loop times in seconds. 77 // Loop times in seconds.
77 double loopStart() const { return m_loopStart; } 78 double loopStart() const { return m_loopStart; }
78 double loopEnd() const { return m_loopEnd; } 79 double loopEnd() const { return m_loopEnd; }
79 void setLoopStart(double loopStart) { m_loopStart = loopStart; } 80 void setLoopStart(double loopStart) { m_loopStart = loopStart; }
80 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; } 81 void setLoopEnd(double loopEnd) { m_loopEnd = loopEnd; }
81 82
82 AudioParam* gain() { return m_gain.get(); } 83 AudioParam* gain() { return m_gain.get(); }
83 AudioParam* playbackRate() { return m_playbackRate.get(); } 84 AudioParam* playbackRate() { return m_playbackRate.get(); }
84 85
85 // 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.
86 void setPannerNode(PannerNode*); 87 void setPannerNode(PannerNode*);
87 void clearPannerNode(); 88 void clearPannerNode();
88 89
89 // 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.
90 virtual bool propagatesSilence() const; 91 virtual bool propagatesSilence() const;
91 92
92 // AudioScheduledSourceNode 93 // AudioScheduledSourceNode
93 virtual void finish() OVERRIDE; 94 virtual void finish() OVERRIDE;
94 95
95 private: 96 private:
96 AudioBufferSourceNode(AudioContext*, float sampleRate); 97 AudioBufferSourceNode(AudioContext*, float sampleRate);
97 98
98 void startPlaying(bool isGrain, double when, double grainOffset, double grai nDuration); 99 void startPlaying(bool isGrain, double when, double grainOffset, double grai nDuration, ExceptionState&);
99 100
100 // Returns true on success. 101 // Returns true on success.
101 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num berOfFrames); 102 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num berOfFrames);
102 103
103 // Render silence starting from "index" frame in AudioBus. 104 // Render silence starting from "index" frame in AudioBus.
104 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si ze_t framesToProcess); 105 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si ze_t framesToProcess);
105 106
106 // m_buffer holds the sample data which this node outputs. 107 // m_buffer holds the sample data which this node outputs.
107 RefPtr<AudioBuffer> m_buffer; 108 RefPtr<AudioBuffer> m_buffer;
108 109
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // 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.
142 PannerNode* m_pannerNode; 143 PannerNode* m_pannerNode;
143 144
144 // 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.
145 mutable Mutex m_processLock; 146 mutable Mutex m_processLock;
146 }; 147 };
147 148
148 } // namespace WebCore 149 } // namespace WebCore
149 150
150 #endif // AudioBufferSourceNode_h 151 #endif // AudioBufferSourceNode_h
OLDNEW
« no previous file with comments | « LayoutTests/webaudio/dom-exceptions-expected.txt ('k') | Source/modules/webaudio/AudioBufferSourceNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698