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

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

Issue 2793593002: AudioWorklet prototype
Patch Set: Rebase after ThreadedWorkletMessaginProxy change Created 3 years, 6 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 30 matching lines...) Expand all
41 #include "core/inspector/ConsoleTypes.h" 41 #include "core/inspector/ConsoleTypes.h"
42 #include "modules/mediastream/MediaStream.h" 42 #include "modules/mediastream/MediaStream.h"
43 #include "modules/webaudio/AnalyserNode.h" 43 #include "modules/webaudio/AnalyserNode.h"
44 #include "modules/webaudio/AudioBuffer.h" 44 #include "modules/webaudio/AudioBuffer.h"
45 #include "modules/webaudio/AudioBufferCallback.h" 45 #include "modules/webaudio/AudioBufferCallback.h"
46 #include "modules/webaudio/AudioBufferSourceNode.h" 46 #include "modules/webaudio/AudioBufferSourceNode.h"
47 #include "modules/webaudio/AudioContext.h" 47 #include "modules/webaudio/AudioContext.h"
48 #include "modules/webaudio/AudioListener.h" 48 #include "modules/webaudio/AudioListener.h"
49 #include "modules/webaudio/AudioNodeInput.h" 49 #include "modules/webaudio/AudioNodeInput.h"
50 #include "modules/webaudio/AudioNodeOutput.h" 50 #include "modules/webaudio/AudioNodeOutput.h"
51 #include "modules/webaudio/AudioWorkletMessagingProxy.h"
51 #include "modules/webaudio/BiquadFilterNode.h" 52 #include "modules/webaudio/BiquadFilterNode.h"
52 #include "modules/webaudio/ChannelMergerNode.h" 53 #include "modules/webaudio/ChannelMergerNode.h"
53 #include "modules/webaudio/ChannelSplitterNode.h" 54 #include "modules/webaudio/ChannelSplitterNode.h"
54 #include "modules/webaudio/ConstantSourceNode.h" 55 #include "modules/webaudio/ConstantSourceNode.h"
55 #include "modules/webaudio/ConvolverNode.h" 56 #include "modules/webaudio/ConvolverNode.h"
56 #include "modules/webaudio/DelayNode.h" 57 #include "modules/webaudio/DelayNode.h"
57 #include "modules/webaudio/DynamicsCompressorNode.h" 58 #include "modules/webaudio/DynamicsCompressorNode.h"
58 #include "modules/webaudio/GainNode.h" 59 #include "modules/webaudio/GainNode.h"
59 #include "modules/webaudio/IIRFilterNode.h" 60 #include "modules/webaudio/IIRFilterNode.h"
60 #include "modules/webaudio/MediaElementAudioSourceNode.h" 61 #include "modules/webaudio/MediaElementAudioSourceNode.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 DCHECK(!finished_source_handlers_.size()); 146 DCHECK(!finished_source_handlers_.size());
146 DCHECK(!is_resolving_resume_promises_); 147 DCHECK(!is_resolving_resume_promises_);
147 DCHECK(!resume_resolvers_.size()); 148 DCHECK(!resume_resolvers_.size());
148 DCHECK(!autoplay_status_.has_value()); 149 DCHECK(!autoplay_status_.has_value());
149 } 150 }
150 151
151 void BaseAudioContext::Initialize() { 152 void BaseAudioContext::Initialize() {
152 if (IsDestinationInitialized()) 153 if (IsDestinationInitialized())
153 return; 154 return;
154 155
156 // At this point, AudioWorklet should be initialized. Cache the reference to
157 // it.
158 worklet_messaging_proxy_ = static_cast<AudioWorkletMessagingProxy*>(
159 GetAudioWorklet()->GetWorkletGlobalScopeProxy());
160
161 LOG(INFO) << "BaseAudioContext::Initialize AWMP_rendering_thread = "
162 << worklet_messaging_proxy_->GetRenderingThread();
163
164 // =========================================================================
165 // WebThread* rendering_thread =
166 // destination()->GetAudioDestinationHandler().GetRenderingThread();
167
168 // LOG(INFO) << "rendering_thread = " << rendering_thread;
169
170 // // Reset the worklet thread. Not sure if this is okay.
171 // AudioWorkletThread::SetSharedBackingThread(rendering_thread);
172
173 // LOG(INFO) << "AudioWorkletThread = "
174 // << WorkletThreadHolder<AudioWorkletThread>::GetInstance()->GetThr ead();
175
176 // worklet_messaging_proxy_ =
177 // static_cast<AudioWorkletMessagingProxy*>(
178 // audio_worklet_->GetWorkletGlobalScopeProxy());
179 // LOG(INFO) << "worklet_messaging_proxy_ = " << worklet_messaging_proxy_;
180
181 // worklet_messaging_proxy_->RequestProcessorDefinitionMap();
182 // =========================================================================
183
155 FFTFrame::Initialize(); 184 FFTFrame::Initialize();
156 185
157 if (destination_node_) { 186 if (destination_node_) {
158 destination_node_->Handler().Initialize(); 187 destination_node_->Handler().Initialize();
188
159 // The AudioParams in the listener need access to the destination node, so 189 // The AudioParams in the listener need access to the destination node, so
160 // only create the listener if the destination node exists. 190 // only create the listener if the destination node exists.
161 listener_ = AudioListener::Create(*this); 191 listener_ = AudioListener::Create(*this);
162 } 192 }
163 } 193 }
164 194
165 void BaseAudioContext::Clear() { 195 void BaseAudioContext::Clear() {
166 destination_node_.Clear(); 196 destination_node_.Clear();
167 // The audio rendering thread is dead. Nobody will schedule AudioHandler 197 // The audio rendering thread is dead. Nobody will schedule AudioHandler
168 // deletion. Let's do it ourselves. 198 // deletion. Let's do it ourselves.
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 visitor->Trace(destination_node_); 939 visitor->Trace(destination_node_);
910 visitor->Trace(listener_); 940 visitor->Trace(listener_);
911 visitor->Trace(active_source_nodes_); 941 visitor->Trace(active_source_nodes_);
912 visitor->Trace(resume_resolvers_); 942 visitor->Trace(resume_resolvers_);
913 visitor->Trace(decode_audio_resolvers_); 943 visitor->Trace(decode_audio_resolvers_);
914 944
915 visitor->Trace(periodic_wave_sine_); 945 visitor->Trace(periodic_wave_sine_);
916 visitor->Trace(periodic_wave_square_); 946 visitor->Trace(periodic_wave_square_);
917 visitor->Trace(periodic_wave_sawtooth_); 947 visitor->Trace(periodic_wave_sawtooth_);
918 visitor->Trace(periodic_wave_triangle_); 948 visitor->Trace(periodic_wave_triangle_);
949
919 EventTargetWithInlineData::Trace(visitor); 950 EventTargetWithInlineData::Trace(visitor);
920 SuspendableObject::Trace(visitor); 951 SuspendableObject::Trace(visitor);
921 } 952 }
922 953
923 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const { 954 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const {
924 if (GetExecutionContext()) 955 if (GetExecutionContext())
925 return GetExecutionContext()->GetSecurityOrigin(); 956 return GetExecutionContext()->GetSecurityOrigin();
926 957
927 return nullptr; 958 return nullptr;
928 } 959 }
929 960
961 AudioWorklet* BaseAudioContext::GetAudioWorklet() {
962 return WindowAudioWorklet::audioWorklet(
963 *(SuspendableObject::GetExecutionContext()->ExecutingWindow()));
964 }
965
966 AudioWorkletMessagingProxy* BaseAudioContext::GetWorkletMessagingProxy() {
967 return worklet_messaging_proxy_;
968 }
969
970 WebThreadSupportingGC* BaseAudioContext::GetRenderingThread() {
971 return worklet_messaging_proxy_->GetRenderingThread();
972 }
973
930 } // namespace blink 974 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698