Changeset 90853 in webkit


Ignore:
Timestamp:
Jul 12, 2011 2:46:35 PM (13 years ago)
Author:
crogers@google.com
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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90850 r90853  
     12011-07-12  Chris Rogers  <crogers@google.com>
     2
     3        AudioDevice::Stop can close NULL handle.
     4        https://bugs.webkit.org/show_bug.cgi?id=64157
     5
     6        Reviewed by Kenneth Russell.
     7
     8        No new tests since audio API is not yet implemented.
     9
     10        * bindings/js/JSAudioContextCustom.cpp:
     11        (WebCore::JSAudioContextConstructor::constructJSAudioContext):
     12        * bindings/v8/custom/V8AudioContextCustom.cpp:
     13        (WebCore::V8AudioContext::constructorCallback):
     14        * webaudio/AudioContext.cpp:
     15        (WebCore::AudioContext::create):
     16        (WebCore::AudioContext::uninitialize):
     17        * webaudio/AudioContext.h:
     18
    1192011-07-12  John Bates  <jbates@google.com>
    220
  • trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp

    r90839 r90853  
    6969        // Constructor for default AudioContext which talks to audio hardware.
    7070        audioContext = AudioContext::create(document);
     71        if (!audioContext.get())
     72            return throwVMError(exec, createSyntaxError(exec, "audio resources unavailable for AudioContext construction"));
    7173    } else {
    7274        // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
  • trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp

    r90839 r90853  
    6060        // Constructor for default AudioContext which talks to audio hardware.
    6161        audioContext = AudioContext::create(document);
     62        if (!audioContext.get())
     63            return throwError("audio resources unavailable for AudioContext construction", V8Proxy::SyntaxError);
    6264    } else {
    6365        // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
  • trunk/Source/WebCore/webaudio/AudioContext.cpp

    r90839 r90853  
    8383}
    8484
     85// Don't allow more than this number of simultaneous AudioContexts talking to hardware.
     86const unsigned MaxHardwareContexts = 4;
     87unsigned AudioContext::s_hardwareContextCount = 0;
     88   
    8589PassRefPtr<AudioContext> AudioContext::create(Document* document)
    8690{
    8791    ASSERT(document);
     92    ASSERT(isMainThread());
     93    if (s_hardwareContextCount >= MaxHardwareContexts)
     94        return 0;
     95
     96    ++s_hardwareContextCount;
     97       
    8898    return adoptRef(new AudioContext(document));
    8999}
     
    195205void AudioContext::uninitialize()
    196206{
     207    ASSERT(isMainThread());
     208
    197209    if (m_isInitialized) {   
    198210        // This stops the audio thread and all audio rendering.
     
    204216        // 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.
    205217        m_destinationNode.clear();
     218
     219        if (!isOfflineContext()) {
     220            ASSERT(s_hardwareContextCount);
     221            --s_hardwareContextCount;
     222        }
    206223       
    207224        // Get rid of the sources which may still be playing.
  • trunk/Source/WebCore/webaudio/AudioContext.h

    r90839 r90853  
    214214    void fireCompletionEvent();
    215215   
     216    static unsigned s_hardwareContextCount;
     217   
    216218private:
    217219    AudioContext(Document*);
Note: See TracChangeset for help on using the changeset viewer.