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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp

Issue 2793593002: AudioWorklet prototype
Patch Set: Merge changes, AudioParam bug fix Created 3 years, 5 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) 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/inspector/ConsoleMessage.h" 42 #include "core/inspector/ConsoleMessage.h"
43 #include "core/inspector/ConsoleTypes.h" 43 #include "core/inspector/ConsoleTypes.h"
44 #include "modules/mediastream/MediaStream.h" 44 #include "modules/mediastream/MediaStream.h"
45 #include "modules/webaudio/AnalyserNode.h" 45 #include "modules/webaudio/AnalyserNode.h"
46 #include "modules/webaudio/AudioBuffer.h" 46 #include "modules/webaudio/AudioBuffer.h"
47 #include "modules/webaudio/AudioBufferSourceNode.h" 47 #include "modules/webaudio/AudioBufferSourceNode.h"
48 #include "modules/webaudio/AudioContext.h" 48 #include "modules/webaudio/AudioContext.h"
49 #include "modules/webaudio/AudioListener.h" 49 #include "modules/webaudio/AudioListener.h"
50 #include "modules/webaudio/AudioNodeInput.h" 50 #include "modules/webaudio/AudioNodeInput.h"
51 #include "modules/webaudio/AudioNodeOutput.h" 51 #include "modules/webaudio/AudioNodeOutput.h"
52 #include "modules/webaudio/AudioWorkletMessagingProxy.h"
52 #include "modules/webaudio/BiquadFilterNode.h" 53 #include "modules/webaudio/BiquadFilterNode.h"
53 #include "modules/webaudio/ChannelMergerNode.h" 54 #include "modules/webaudio/ChannelMergerNode.h"
54 #include "modules/webaudio/ChannelSplitterNode.h" 55 #include "modules/webaudio/ChannelSplitterNode.h"
55 #include "modules/webaudio/ConstantSourceNode.h" 56 #include "modules/webaudio/ConstantSourceNode.h"
56 #include "modules/webaudio/ConvolverNode.h" 57 #include "modules/webaudio/ConvolverNode.h"
57 #include "modules/webaudio/DelayNode.h" 58 #include "modules/webaudio/DelayNode.h"
58 #include "modules/webaudio/DynamicsCompressorNode.h" 59 #include "modules/webaudio/DynamicsCompressorNode.h"
59 #include "modules/webaudio/GainNode.h" 60 #include "modules/webaudio/GainNode.h"
60 #include "modules/webaudio/IIRFilterNode.h" 61 #include "modules/webaudio/IIRFilterNode.h"
61 #include "modules/webaudio/MediaElementAudioSourceNode.h" 62 #include "modules/webaudio/MediaElementAudioSourceNode.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 DCHECK(!active_source_nodes_.size()); 154 DCHECK(!active_source_nodes_.size());
154 DCHECK(!is_resolving_resume_promises_); 155 DCHECK(!is_resolving_resume_promises_);
155 DCHECK(!resume_resolvers_.size()); 156 DCHECK(!resume_resolvers_.size());
156 DCHECK(!autoplay_status_.has_value()); 157 DCHECK(!autoplay_status_.has_value());
157 } 158 }
158 159
159 void BaseAudioContext::Initialize() { 160 void BaseAudioContext::Initialize() {
160 if (IsDestinationInitialized()) 161 if (IsDestinationInitialized())
161 return; 162 return;
162 163
164 // At this point, AudioWorklet should be initialized. Cache the reference to
165 // it.
166 worklet_messaging_proxy_ = GetAudioWorklet()->GetWorkletMessagingProxy();
167
168 LOG(INFO) << "BaseAudioContext::Initialize AWMP_rendering_thread = "
169 << worklet_messaging_proxy_->GetRenderingThread();
170
171 // =========================================================================
172 // WebThread* rendering_thread =
173 // destination()->GetAudioDestinationHandler().GetRenderingThread();
174
175 // LOG(INFO) << "rendering_thread = " << rendering_thread;
176
177 // // Reset the worklet thread. Not sure if this is okay.
178 // AudioWorkletThread::SetSharedBackingThread(rendering_thread);
179
180 // LOG(INFO) << "AudioWorkletThread = "
181 // << WorkletThreadHolder<AudioWorkletThread>::GetInstance()->GetThr ead();
182
183 // worklet_messaging_proxy_ =
184 // static_cast<AudioWorkletMessagingProxy*>(
185 // audio_worklet_->GetWorkletGlobalScopeProxy());
186 // LOG(INFO) << "worklet_messaging_proxy_ = " << worklet_messaging_proxy_;
187
188 // worklet_messaging_proxy_->RequestProcessorDefinitionMap();
189 // =========================================================================
190
163 FFTFrame::Initialize(); 191 FFTFrame::Initialize();
164 192
165 if (destination_node_) { 193 if (destination_node_) {
166 destination_node_->Handler().Initialize(); 194 destination_node_->Handler().Initialize();
195
167 // The AudioParams in the listener need access to the destination node, so 196 // The AudioParams in the listener need access to the destination node, so
168 // only create the listener if the destination node exists. 197 // only create the listener if the destination node exists.
169 listener_ = AudioListener::Create(*this); 198 listener_ = AudioListener::Create(*this);
170 } 199 }
171 } 200 }
172 201
173 void BaseAudioContext::Clear() { 202 void BaseAudioContext::Clear() {
174 destination_node_.Clear(); 203 destination_node_.Clear();
175 // The audio rendering thread is dead. Nobody will schedule AudioHandler 204 // The audio rendering thread is dead. Nobody will schedule AudioHandler
176 // deletion. Let's do it ourselves. 205 // deletion. Let's do it ourselves.
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 visitor->Trace(active_source_nodes_); 1018 visitor->Trace(active_source_nodes_);
990 visitor->Trace(resume_resolvers_); 1019 visitor->Trace(resume_resolvers_);
991 visitor->Trace(success_callbacks_); 1020 visitor->Trace(success_callbacks_);
992 visitor->Trace(error_callbacks_); 1021 visitor->Trace(error_callbacks_);
993 visitor->Trace(decode_audio_resolvers_); 1022 visitor->Trace(decode_audio_resolvers_);
994 1023
995 visitor->Trace(periodic_wave_sine_); 1024 visitor->Trace(periodic_wave_sine_);
996 visitor->Trace(periodic_wave_square_); 1025 visitor->Trace(periodic_wave_square_);
997 visitor->Trace(periodic_wave_sawtooth_); 1026 visitor->Trace(periodic_wave_sawtooth_);
998 visitor->Trace(periodic_wave_triangle_); 1027 visitor->Trace(periodic_wave_triangle_);
1028
1029 visitor->Trace(worklet_messaging_proxy_);
1030
999 EventTargetWithInlineData::Trace(visitor); 1031 EventTargetWithInlineData::Trace(visitor);
1000 SuspendableObject::Trace(visitor); 1032 SuspendableObject::Trace(visitor);
1001 } 1033 }
1002 1034
1003 DEFINE_TRACE_WRAPPERS(BaseAudioContext) { 1035 DEFINE_TRACE_WRAPPERS(BaseAudioContext) {
1004 // Inform V8's GC that we have references to these objects so they 1036 // Inform V8's GC that we have references to these objects so they
1005 // don't get collected until we're done with them. 1037 // don't get collected until we're done with them.
1006 for (auto callback : success_callbacks_) { 1038 for (auto callback : success_callbacks_) {
1007 visitor->TraceWrappers(callback); 1039 visitor->TraceWrappers(callback);
1008 } 1040 }
1009 for (auto callback : error_callbacks_) { 1041 for (auto callback : error_callbacks_) {
1010 visitor->TraceWrappers(callback); 1042 visitor->TraceWrappers(callback);
1011 } 1043 }
1012 } 1044 }
1013 1045
1014 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const { 1046 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const {
1015 if (GetExecutionContext()) 1047 if (GetExecutionContext())
1016 return GetExecutionContext()->GetSecurityOrigin(); 1048 return GetExecutionContext()->GetSecurityOrigin();
1017 1049
1018 return nullptr; 1050 return nullptr;
1019 } 1051 }
1020 1052
1053 AudioWorklet* BaseAudioContext::GetAudioWorklet() {
1054 return WindowAudioWorklet::audioWorklet(
1055 *(SuspendableObject::GetExecutionContext()->ExecutingWindow()));
1056 }
1057
1058 AudioWorkletMessagingProxy* BaseAudioContext::GetWorkletMessagingProxy() {
1059 return worklet_messaging_proxy_;
1060 }
1061
1062 WebThreadSupportingGC* BaseAudioContext::GetRenderingThread() {
1063 return worklet_messaging_proxy_->GetRenderingThread();
1064 }
1065
1021 } // namespace blink 1066 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698