Title: [90853] trunk/Source/WebCore
Revision
90853
Author
[email protected]
Date
2011-07-12 14:46:35 -0700 (Tue, 12 Jul 2011)

Log Message

AudioDevice::Stop can close NULL handle.
https://bugs.webkit.org/show_bug.cgi?id=64157

Reviewed by Kenneth Russell.

No new tests since audio API is not yet implemented.

* bindings/js/JSAudioContextCustom.cpp:
(WebCore::JSAudioContextConstructor::constructJSAudioContext):
* bindings/v8/custom/V8AudioContextCustom.cpp:
(WebCore::V8AudioContext::constructorCallback):
* webaudio/AudioContext.cpp:
(WebCore::AudioContext::create):
(WebCore::AudioContext::uninitialize):
* webaudio/AudioContext.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (90852 => 90853)


--- trunk/Source/WebCore/ChangeLog	2011-07-12 21:38:21 UTC (rev 90852)
+++ trunk/Source/WebCore/ChangeLog	2011-07-12 21:46:35 UTC (rev 90853)
@@ -1,3 +1,21 @@
+2011-07-12  Chris Rogers  <[email protected]>
+
+        AudioDevice::Stop can close NULL handle.
+        https://bugs.webkit.org/show_bug.cgi?id=64157
+
+        Reviewed by Kenneth Russell.
+
+        No new tests since audio API is not yet implemented.
+
+        * bindings/js/JSAudioContextCustom.cpp:
+        (WebCore::JSAudioContextConstructor::constructJSAudioContext):
+        * bindings/v8/custom/V8AudioContextCustom.cpp:
+        (WebCore::V8AudioContext::constructorCallback):
+        * webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::create):
+        (WebCore::AudioContext::uninitialize):
+        * webaudio/AudioContext.h:
+
 2011-07-12  John Bates  <[email protected]>
 
         Move call to syncCompositingLayers so that we do not trigger redundant draws.

Modified: trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp (90852 => 90853)


--- trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp	2011-07-12 21:38:21 UTC (rev 90852)
+++ trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp	2011-07-12 21:46:35 UTC (rev 90853)
@@ -68,6 +68,8 @@
     if (!exec->argumentCount()) {
         // Constructor for default AudioContext which talks to audio hardware.
         audioContext = AudioContext::create(document);
+        if (!audioContext.get())
+            return throwVMError(exec, createSyntaxError(exec, "audio resources unavailable for AudioContext construction"));
     } else {
         // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
         // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);

Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (90852 => 90853)


--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2011-07-12 21:38:21 UTC (rev 90852)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2011-07-12 21:46:35 UTC (rev 90853)
@@ -59,6 +59,8 @@
     if (!args.Length()) {
         // Constructor for default AudioContext which talks to audio hardware.
         audioContext = AudioContext::create(document);
+        if (!audioContext.get())
+            return throwError("audio resources unavailable for AudioContext construction", V8Proxy::SyntaxError);
     } else {
         // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
         // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);

Modified: trunk/Source/WebCore/webaudio/AudioContext.cpp (90852 => 90853)


--- trunk/Source/WebCore/webaudio/AudioContext.cpp	2011-07-12 21:38:21 UTC (rev 90852)
+++ trunk/Source/WebCore/webaudio/AudioContext.cpp	2011-07-12 21:46:35 UTC (rev 90853)
@@ -82,9 +82,19 @@
 
 }
 
+// Don't allow more than this number of simultaneous AudioContexts talking to hardware.
+const unsigned MaxHardwareContexts = 4;
+unsigned AudioContext::s_hardwareContextCount = 0;
+    
 PassRefPtr<AudioContext> AudioContext::create(Document* document)
 {
     ASSERT(document);
+    ASSERT(isMainThread());
+    if (s_hardwareContextCount >= MaxHardwareContexts)
+        return 0;
+
+    ++s_hardwareContextCount;
+        
     return adoptRef(new AudioContext(document));
 }
 
@@ -194,6 +204,8 @@
 
 void AudioContext::uninitialize()
 {
+    ASSERT(isMainThread());
+
     if (m_isInitialized) {    
         // This stops the audio thread and all audio rendering.
         m_destinationNode->uninitialize();
@@ -203,6 +215,11 @@
 
         // We have to release our reference to the destination node before the context will ever be deleted since the destination node holds a reference to the context.
         m_destinationNode.clear();
+
+        if (!isOfflineContext()) {
+            ASSERT(s_hardwareContextCount);
+            --s_hardwareContextCount;
+        }
         
         // Get rid of the sources which may still be playing.
         derefUnfinishedSourceNodes();

Modified: trunk/Source/WebCore/webaudio/AudioContext.h (90852 => 90853)


--- trunk/Source/WebCore/webaudio/AudioContext.h	2011-07-12 21:38:21 UTC (rev 90852)
+++ trunk/Source/WebCore/webaudio/AudioContext.h	2011-07-12 21:46:35 UTC (rev 90853)
@@ -213,6 +213,8 @@
     void startRendering();
     void fireCompletionEvent();
     
+    static unsigned s_hardwareContextCount;
+    
 private:
     AudioContext(Document*);
     AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, double sampleRate);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to