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

Side by Side Diff: Source/modules/webaudio/AudioContext.cpp

Issue 176683003: HRTFDatabaseLoader is not an absolute condition to run audioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 , m_automaticPullNodesNeedUpdating(false) 121 , m_automaticPullNodesNeedUpdating(false)
122 , m_connectionCount(0) 122 , m_connectionCount(0)
123 , m_audioThread(0) 123 , m_audioThread(0)
124 , m_graphOwnerThread(UndefinedThreadIdentifier) 124 , m_graphOwnerThread(UndefinedThreadIdentifier)
125 , m_isOfflineContext(false) 125 , m_isOfflineContext(false)
126 , m_activeSourceCount(0) 126 , m_activeSourceCount(0)
127 { 127 {
128 constructCommon(); 128 constructCommon();
129 129
130 m_destinationNode = DefaultAudioDestinationNode::create(this); 130 m_destinationNode = DefaultAudioDestinationNode::create(this);
131
132 // This sets in motion an asynchronous loading mechanism on another thread.
133 // We can check m_hrtfDatabaseLoader->isLoaded() to find out whether or not it has been fully loaded.
134 // It's not that useful to have a callback function for this since the audio thread automatically starts rendering on the graph
135 // when this has finished (see AudioDestinationNode).
136 m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNece ssary(sampleRate());
137 } 131 }
138 132
139 // Constructor for offline (non-realtime) rendering. 133 // Constructor for offline (non-realtime) rendering.
140 AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate) 134 AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
141 : ActiveDOMObject(document) 135 : ActiveDOMObject(document)
142 , m_isStopScheduled(false) 136 , m_isStopScheduled(false)
143 , m_isInitialized(false) 137 , m_isInitialized(false)
144 , m_isAudioThreadFinished(false) 138 , m_isAudioThreadFinished(false)
145 , m_destinationNode(nullptr) 139 , m_destinationNode(nullptr)
146 , m_automaticPullNodesNeedUpdating(false) 140 , m_automaticPullNodesNeedUpdating(false)
147 , m_connectionCount(0) 141 , m_connectionCount(0)
148 , m_audioThread(0) 142 , m_audioThread(0)
149 , m_graphOwnerThread(UndefinedThreadIdentifier) 143 , m_graphOwnerThread(UndefinedThreadIdentifier)
150 , m_isOfflineContext(true) 144 , m_isOfflineContext(true)
151 , m_activeSourceCount(0) 145 , m_activeSourceCount(0)
152 { 146 {
153 constructCommon(); 147 constructCommon();
154 148
155 m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNece ssary(sampleRate);
156
157 // Create a new destination for offline rendering. 149 // Create a new destination for offline rendering.
158 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl eRate); 150 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl eRate);
159 ASSERT(m_renderTarget); 151 ASSERT(m_renderTarget);
160 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTarget .get()); 152 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTarget .get());
161 ASSERT(m_destinationNode); 153 ASSERT(m_destinationNode);
162 } 154 }
163 155
164 void AudioContext::constructCommon() 156 void AudioContext::constructCommon()
165 { 157 {
166 ScriptWrappable::init(this); 158 ScriptWrappable::init(this);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 derefUnfinishedSourceNodes(); 245 derefUnfinishedSourceNodes();
254 246
255 m_isInitialized = false; 247 m_isInitialized = false;
256 } 248 }
257 249
258 bool AudioContext::isInitialized() const 250 bool AudioContext::isInitialized() const
259 { 251 {
260 return m_isInitialized; 252 return m_isInitialized;
261 } 253 }
262 254
263 bool AudioContext::isRunnable() const
264 {
265 if (!isInitialized())
266 return false;
267
268 // Check with the HRTF spatialization system to see if it's finished loading .
269 return m_hrtfDatabaseLoader->isLoaded();
270 }
271
272 void AudioContext::stopDispatch(void* userData) 255 void AudioContext::stopDispatch(void* userData)
273 { 256 {
274 AudioContext* context = reinterpret_cast<AudioContext*>(userData); 257 AudioContext* context = reinterpret_cast<AudioContext*>(userData);
275 ASSERT(context); 258 ASSERT(context);
276 if (!context) 259 if (!context)
277 return; 260 return;
278 261
279 context->uninitialize(); 262 context->uninitialize();
280 context->clear(); 263 context->clear();
281 } 264 }
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 } 1040 }
1058 1041
1059 void AudioContext::decrementActiveSourceCount() 1042 void AudioContext::decrementActiveSourceCount()
1060 { 1043 {
1061 atomicDecrement(&m_activeSourceCount); 1044 atomicDecrement(&m_activeSourceCount);
1062 } 1045 }
1063 1046
1064 } // namespace WebCore 1047 } // namespace WebCore
1065 1048
1066 #endif // ENABLE(WEB_AUDIO) 1049 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioContext.h ('k') | Source/modules/webaudio/AudioDestinationNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698