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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h

Issue 1978063002: [DO NOT SUBMIT] AudioWorklet FS2a: AudioWorkletThread on OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FS2-audiorendersink-audioworkletthread
Patch Set: Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #ifndef OfflineAudioDestinationNode_h 25 #ifndef OfflineAudioDestinationNode_h
26 #define OfflineAudioDestinationNode_h 26 #define OfflineAudioDestinationNode_h
27 27
28 #include "modules/webaudio/AudioBuffer.h" 28 #include "modules/webaudio/AudioBuffer.h"
29 #include "modules/webaudio/AudioDestinationNode.h" 29 #include "modules/webaudio/AudioDestinationNode.h"
30 #include "modules/webaudio/AudioWorkletThread.h"
30 #include "modules/webaudio/OfflineAudioContext.h" 31 #include "modules/webaudio/OfflineAudioContext.h"
31 #include "public/platform/WebThread.h" 32 // #include "public/platform/WebThread.h"
32 #include "wtf/PassRefPtr.h" 33 #include "wtf/PassRefPtr.h"
33 #include "wtf/RefPtr.h" 34 #include "wtf/RefPtr.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 class AbstractAudioContext; 38 class AbstractAudioContext;
38 class AudioBus; 39 class AudioBus;
39 class OfflineAudioContext; 40 class OfflineAudioContext;
40 41
41 class OfflineAudioDestinationHandler final : public AudioDestinationHandler { 42 class OfflineAudioDestinationHandler final : public AudioDestinationHandler {
42 public: 43 public:
43 static PassRefPtr<OfflineAudioDestinationHandler> create(AudioNode&, AudioBu ffer* renderTarget); 44 static PassRefPtr<OfflineAudioDestinationHandler> create(AudioNode&, AudioBu ffer* renderTarget);
44 ~OfflineAudioDestinationHandler() override; 45 ~OfflineAudioDestinationHandler() override;
45 46
46 // AudioHandler 47 // AudioHandler
47 void dispose() override; 48 void dispose() override;
48 void initialize() override; 49 void initialize() override;
49 void uninitialize() override; 50 void uninitialize() override;
50 51
51 OfflineAudioContext* context() const final; 52 OfflineAudioContext* context() const final;
52 53
53 // AudioDestinationHandler 54 // AudioDestinationHandler
54 void startRendering() override; 55 void startRendering() override;
55 void stopRendering() override; 56 void stopRendering() override;
56 57
57 float sampleRate() const override { return m_renderTarget->sampleRate(); } 58 float sampleRate() const override { return m_renderTarget->sampleRate(); }
58 59
59 size_t renderQuantumFrames() const { return renderQuantumSize; } 60 size_t renderQuantumFrames() const { return renderQuantumSize; }
60 61
61 WebThread* offlineRenderThread(); 62 AudioWorkletThread* offlineRenderThread();
62 63
63 private: 64 private:
64 OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget); 65 OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget);
65 66
66 static const size_t renderQuantumSize; 67 static const size_t renderQuantumSize;
67 68
68 // Set up the rendering and start. After setting the context up, it will 69 // Set up the rendering and start. After setting the context up, it will
69 // eventually call |doOfflineRendering|. 70 // eventually call |doOfflineRendering|.
70 void startOfflineRendering(); 71 void startOfflineRendering();
71 72
(...skipping 18 matching lines...) Expand all
90 bool renderIfNotSuspended(AudioBus* sourceBus, AudioBus* destinationBus, siz e_t numberOfFrames); 91 bool renderIfNotSuspended(AudioBus* sourceBus, AudioBus* destinationBus, siz e_t numberOfFrames);
91 92
92 // This AudioHandler renders into this AudioBuffer. 93 // This AudioHandler renders into this AudioBuffer.
93 // This Persistent doesn't make a reference cycle including the owner 94 // This Persistent doesn't make a reference cycle including the owner
94 // OfflineAudioDestinationNode. 95 // OfflineAudioDestinationNode.
95 Persistent<AudioBuffer> m_renderTarget; 96 Persistent<AudioBuffer> m_renderTarget;
96 // Temporary AudioBus for each render quantum. 97 // Temporary AudioBus for each render quantum.
97 RefPtr<AudioBus> m_renderBus; 98 RefPtr<AudioBus> m_renderBus;
98 99
99 // Rendering thread. 100 // Rendering thread.
100 OwnPtr<WebThread> m_renderThread; 101 // OwnPtr<WebThread> m_renderThread;
102 RefPtr<AudioWorkletThread> m_renderThread;
101 103
102 // These variables are for counting the number of frames for the current 104 // These variables are for counting the number of frames for the current
103 // progress and the remaining frames to be processed. 105 // progress and the remaining frames to be processed.
104 size_t m_framesProcessed; 106 size_t m_framesProcessed;
105 size_t m_framesToProcess; 107 size_t m_framesToProcess;
106 108
107 // This flag is necessary to distinguish the state of the context between 109 // This flag is necessary to distinguish the state of the context between
108 // 'created' and 'suspended'. If this flag is false and the current state 110 // 'created' and 'suspended'. If this flag is false and the current state
109 // is 'suspended', it means the context is created and have not started yet. 111 // is 'suspended', it means the context is created and have not started yet.
110 bool m_isRenderingStarted; 112 bool m_isRenderingStarted;
111 113
112 // This flag indicates whether the rendering should be suspended or not. 114 // This flag indicates whether the rendering should be suspended or not.
113 bool m_shouldSuspend; 115 bool m_shouldSuspend;
114 }; 116 };
115 117
116 class OfflineAudioDestinationNode final : public AudioDestinationNode { 118 class OfflineAudioDestinationNode final : public AudioDestinationNode {
117 public: 119 public:
118 static OfflineAudioDestinationNode* create(AbstractAudioContext*, AudioBuffe r* renderTarget); 120 static OfflineAudioDestinationNode* create(AbstractAudioContext*, AudioBuffe r* renderTarget);
119 121
120 private: 122 private:
121 OfflineAudioDestinationNode(AbstractAudioContext&, AudioBuffer* renderTarget ); 123 OfflineAudioDestinationNode(AbstractAudioContext&, AudioBuffer* renderTarget );
122 }; 124 };
123 125
124 } // namespace blink 126 } // namespace blink
125 127
126 #endif // OfflineAudioDestinationNode_h 128 #endif // OfflineAudioDestinationNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698