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

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

Issue 205173002: Move webaudio to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WIP Created 6 years, 9 months 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 26 matching lines...) Expand all
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 FINAL : public AudioScheduledSourceNode { 45 class AudioBufferSourceNode FINAL : public AudioScheduledSourceNode {
46 public: 46 public:
47 static PassRefPtr<AudioBufferSourceNode> create(AudioContext*, float sampleR ate); 47 static PassRefPtrWillBeRawPtr<AudioBufferSourceNode> create(AudioContext*, f loat sampleRate);
48 48
49 virtual ~AudioBufferSourceNode(); 49 virtual ~AudioBufferSourceNode();
50 50
51 // AudioNode 51 // AudioNode
52 virtual void process(size_t framesToProcess) OVERRIDE; 52 virtual void process(size_t framesToProcess) OVERRIDE;
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
(...skipping 27 matching lines...) Expand all
85 // If a panner node is set, then we can incorporate doppler shift into the p layback pitch rate. 85 // If a panner node is set, then we can incorporate doppler shift into the p layback pitch rate.
86 void setPannerNode(PannerNode*); 86 void setPannerNode(PannerNode*);
87 void clearPannerNode(); 87 void clearPannerNode();
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 virtual void trace(Visitor*) OVERRIDE;
96
95 private: 97 private:
96 AudioBufferSourceNode(AudioContext*, float sampleRate); 98 AudioBufferSourceNode(AudioContext*, float sampleRate);
97 99
98 // Returns true on success. 100 // Returns true on success.
99 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num berOfFrames); 101 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num berOfFrames);
100 102
101 // Render silence starting from "index" frame in AudioBus. 103 // Render silence starting from "index" frame in AudioBus.
102 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si ze_t framesToProcess); 104 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si ze_t framesToProcess);
103 105
104 // m_buffer holds the sample data which this node outputs. 106 // m_buffer holds the sample data which this node outputs.
105 RefPtr<AudioBuffer> m_buffer; 107 RefPtrWillBeMember<AudioBuffer> m_buffer;
106 108
107 // Pointers for the buffer and destination. 109 // Pointers for the buffer and destination.
108 OwnPtr<const float*[]> m_sourceChannels; 110 OwnPtr<const float*[]> m_sourceChannels;
109 OwnPtr<float*[]> m_destinationChannels; 111 OwnPtr<float*[]> m_destinationChannels;
110 112
111 // Used for the "gain" and "playbackRate" attributes. 113 // Used for the "gain" and "playbackRate" attributes.
112 RefPtr<AudioParam> m_gain; 114 RefPtrWillBeMember<AudioParam> m_gain;
113 RefPtr<AudioParam> m_playbackRate; 115 RefPtrWillBeMember<AudioParam> m_playbackRate;
114 116
115 // If m_isLooping is false, then this node will be done playing and become i nactive after it reaches the end of the sample data in the buffer. 117 // If m_isLooping is false, then this node will be done playing and become i nactive after it reaches the end of the sample data in the buffer.
116 // If true, it will wrap around to the start of the buffer each time it reac hes the end. 118 // If true, it will wrap around to the start of the buffer each time it reac hes the end.
117 bool m_isLooping; 119 bool m_isLooping;
118 120
119 double m_loopStart; 121 double m_loopStart;
120 double m_loopEnd; 122 double m_loopEnd;
121 123
122 // m_virtualReadIndex is a sample-frame index into our buffer representing t he current playback position. 124 // m_virtualReadIndex is a sample-frame index into our buffer representing t he current playback position.
123 // Since it's floating-point, it has sub-sample accuracy. 125 // Since it's floating-point, it has sub-sample accuracy.
124 double m_virtualReadIndex; 126 double m_virtualReadIndex;
125 127
126 // Granular playback 128 // Granular playback
127 bool m_isGrain; 129 bool m_isGrain;
128 double m_grainOffset; // in seconds 130 double m_grainOffset; // in seconds
129 double m_grainDuration; // in seconds 131 double m_grainDuration; // in seconds
130 132
131 // totalPitchRate() returns the instantaneous pitch rate (non-time preservin g). 133 // totalPitchRate() returns the instantaneous pitch rate (non-time preservin g).
132 // It incorporates the base pitch rate, any sample-rate conversion factor fr om the buffer, and any doppler shift from an associated panner node. 134 // It incorporates the base pitch rate, any sample-rate conversion factor fr om the buffer, and any doppler shift from an associated panner node.
133 double totalPitchRate(); 135 double totalPitchRate();
134 136
135 // m_lastGain provides continuity when we dynamically adjust the gain. 137 // m_lastGain provides continuity when we dynamically adjust the gain.
136 float m_lastGain; 138 float m_lastGain;
137 139
138 // We optionally keep track of a panner node which has a doppler shift that is incorporated into 140 // We optionally keep track of a panner node which has a doppler shift that is incorporated into
139 // the pitch rate. We manually manage ref-counting because we want to use Re fTypeConnection. 141 // the pitch rate. We manually manage ref-counting because we want to use Re fTypeConnection.
140 PannerNode* m_pannerNode; 142 PannerNode* m_pannerNode;
haraken 2014/03/27 11:44:05 I think PannerNode and AudioBufferSourceNode shoul
keishi 2014/04/08 02:33:40 AudioNodes use their own ref counting so I don't t
141 143
142 // This synchronizes process() with setBuffer() which can cause dynamic chan nel count changes. 144 // This synchronizes process() with setBuffer() which can cause dynamic chan nel count changes.
143 mutable Mutex m_processLock; 145 mutable Mutex m_processLock;
144 }; 146 };
145 147
146 } // namespace WebCore 148 } // namespace WebCore
147 149
148 #endif // AudioBufferSourceNode_h 150 #endif // AudioBufferSourceNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698