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

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

Issue 1865583002: Implement BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, 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 OfflineAudioContext_h 25 #ifndef OfflineAudioContext_h
26 #define OfflineAudioContext_h 26 #define OfflineAudioContext_h
27 27
28 #include "modules/ModulesExport.h" 28 #include "modules/ModulesExport.h"
29 #include "modules/webaudio/AbstractAudioContext.h" 29 #include "modules/webaudio/BaseAudioContext.h"
30 #include "wtf/HashMap.h" 30 #include "wtf/HashMap.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 class ExceptionState; 34 class ExceptionState;
35 class OfflineAudioDestinationHandler; 35 class OfflineAudioDestinationHandler;
36 36
37 class MODULES_EXPORT OfflineAudioContext final : public AbstractAudioContext { 37 class MODULES_EXPORT OfflineAudioContext final : public BaseAudioContext {
38 DEFINE_WRAPPERTYPEINFO(); 38 DEFINE_WRAPPERTYPEINFO();
39 public: 39 public:
40 static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChann els, unsigned numberOfFrames, float sampleRate, ExceptionState&); 40 static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChann els, unsigned numberOfFrames, float sampleRate, ExceptionState&);
41 41
42 ~OfflineAudioContext() override; 42 ~OfflineAudioContext() override;
43 43
44 DECLARE_VIRTUAL_TRACE(); 44 DECLARE_VIRTUAL_TRACE();
45 45
46 unsigned length() const { return m_totalRenderFrames; } 46 unsigned length() const { return m_totalRenderFrames; }
47 47
48 ScriptPromise startOfflineRendering(ScriptState*); 48 ScriptPromise startOfflineRendering(ScriptState*);
49 49
50 ScriptPromise closeContext(ScriptState*) final; 50 ScriptPromise closeContext(ScriptState*) final;
51 ScriptPromise suspendContext(ScriptState*, double); 51 ScriptPromise suspendContext(ScriptState*, double);
52 ScriptPromise resumeContext(ScriptState*) final; 52 ScriptPromise resumeContext(ScriptState*) final;
53 53
54 // This is to implement the pure virtual method from AbstractAudioContext. 54 // This is to implement the pure virtual method from BaseAudioContext.
55 // CANNOT be called from an OfflineAudioContext. 55 // CANNOT be called from an OfflineAudioContext.
56 ScriptPromise suspendContext(ScriptState*) final; 56 ScriptPromise suspendContext(ScriptState*) final;
57 57
58 bool hasRealtimeConstraint() final { return false; } 58 bool hasRealtimeConstraint() final { return false; }
59 59
60 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete); 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete);
61 61
62 // Fire completion event when the rendering is finished. 62 // Fire completion event when the rendering is finished.
63 void fireCompletionEvent(); 63 void fireCompletionEvent();
64 64
65 // This is same with the online version in AbstractAudioContext class except 65 // This is same with the online version in BaseAudioContext class except
66 // for returning a boolean value after checking the scheduled suspends. 66 // for returning a boolean value after checking the scheduled suspends.
67 bool handlePreOfflineRenderTasks(); 67 bool handlePreOfflineRenderTasks();
68 68
69 void handlePostOfflineRenderTasks(); 69 void handlePostOfflineRenderTasks();
70 70
71 // Resolve a suspend scheduled at the specified frame. With this specified 71 // Resolve a suspend scheduled at the specified frame. With this specified
72 // frame as a unique key, the associated promise resolver can be retrieved 72 // frame as a unique key, the associated promise resolver can be retrieved
73 // from the map (m_scheduledSuspends) and resolved. 73 // from the map (m_scheduledSuspends) and resolved.
74 void resolveSuspendOnMainThread(size_t); 74 void resolveSuspendOnMainThread(size_t);
75 75
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // state when the context is suspended. 111 // state when the context is suspended.
112 bool m_isRenderingStarted; 112 bool m_isRenderingStarted;
113 113
114 // Total render sample length. 114 // Total render sample length.
115 size_t m_totalRenderFrames; 115 size_t m_totalRenderFrames;
116 }; 116 };
117 117
118 } // namespace blink 118 } // namespace blink
119 119
120 #endif // OfflineAudioContext_h 120 #endif // OfflineAudioContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698