⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176311 in webkit


Ignore:
Timestamp:
Nov 18, 2014, 11:49:29 PM (12 years ago)
Author:
Philippe Normand
Message:

start/stop method for AudioBufferSourceNodes and OscillatorNodes can take no args
https://bugs.webkit.org/show_bug.cgi?id=138739

Reviewed by Darin Adler.

Source/WebCore:

The patch is inspired by the following Blink revision by
<Raymond Toy>:
<https://src.chromium.org/viewvc/blink?view=rev&revision=160845>

Test: webaudio/dom-exceptions.html

  • Modules/webaudio/AudioBufferSourceNode.cpp:

(WebCore::AudioBufferSourceNode::start):
(WebCore::AudioBufferSourceNode::startPlaying):
(WebCore::AudioBufferSourceNode::noteGrainOn):
(WebCore::AudioBufferSourceNode::startGrain): Deleted.

  • Modules/webaudio/AudioBufferSourceNode.h:
  • Modules/webaudio/AudioBufferSourceNode.idl:
  • Modules/webaudio/AudioScheduledSourceNode.cpp:

(WebCore::AudioScheduledSourceNode::start):
(WebCore::AudioScheduledSourceNode::stop):

  • Modules/webaudio/AudioScheduledSourceNode.h:
  • Modules/webaudio/OscillatorNode.idl:

LayoutTests:

  • webaudio/dom-exceptions-expected.txt: Added.
  • webaudio/dom-exceptions.html: Added.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r176310 r176311  
     12014-11-18  Philippe Normand  <pnormand@igalia.com>
     2
     3        start/stop method for AudioBufferSourceNodes and OscillatorNodes can take no args
     4        https://bugs.webkit.org/show_bug.cgi?id=138739
     5
     6        Reviewed by Darin Adler.
     7
     8        * webaudio/dom-exceptions-expected.txt: Added.
     9        * webaudio/dom-exceptions.html: Added.
     10
    1112014-11-18  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r176307 r176311  
     12014-11-18  Philippe Normand  <pnormand@igalia.com>
     2
     3        start/stop method for AudioBufferSourceNodes and OscillatorNodes can take no args
     4        https://bugs.webkit.org/show_bug.cgi?id=138739
     5
     6        Reviewed by Darin Adler.
     7
     8        The patch is inspired by the following Blink revision by
     9        <rtoy@google.com>:
     10        <https://src.chromium.org/viewvc/blink?view=rev&revision=160845>
     11
     12        Test: webaudio/dom-exceptions.html
     13
     14        * Modules/webaudio/AudioBufferSourceNode.cpp:
     15        (WebCore::AudioBufferSourceNode::start):
     16        (WebCore::AudioBufferSourceNode::startPlaying):
     17        (WebCore::AudioBufferSourceNode::noteGrainOn):
     18        (WebCore::AudioBufferSourceNode::startGrain): Deleted.
     19        * Modules/webaudio/AudioBufferSourceNode.h:
     20        * Modules/webaudio/AudioBufferSourceNode.idl:
     21        * Modules/webaudio/AudioScheduledSourceNode.cpp:
     22        (WebCore::AudioScheduledSourceNode::start):
     23        (WebCore::AudioScheduledSourceNode::stop):
     24        * Modules/webaudio/AudioScheduledSourceNode.h:
     25        * Modules/webaudio/OscillatorNode.idl:
     26
    1272014-11-18  Benjamin Poulain  <benjamin@webkit.org>
    228
  • trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp

    r163568 r176311  
    371371}
    372372
    373 void AudioBufferSourceNode::startGrain(double when, double grainOffset, ExceptionCode& ec)
    374 {
    375     // Duration of 0 has special value, meaning calculate based on the entire buffer's duration.
    376     startGrain(when, grainOffset, 0, ec);
    377 }
    378 
    379 void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
     373void AudioBufferSourceNode::start(ExceptionCode& ec)
     374{
     375    startPlaying(Entire, 0, 0, buffer() ? buffer()->duration() : 0, ec);
     376}
     377
     378void AudioBufferSourceNode::start(double when, ExceptionCode& ec)
     379{
     380    startPlaying(Entire, when, 0, buffer() ? buffer()->duration() : 0, ec);
     381}
     382
     383void AudioBufferSourceNode::start(double when, double grainOffset, ExceptionCode& ec)
     384{
     385    startPlaying(Partial, when, grainOffset, 0, ec);
     386}
     387
     388void AudioBufferSourceNode::start(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
     389{
     390    startPlaying(Partial, when, grainOffset, grainDuration, ec);
     391}
     392
     393void AudioBufferSourceNode::startPlaying(BufferPlaybackMode playbackMode, double when, double grainOffset, double grainDuration, ExceptionCode& ec)
    380394{
    381395    ASSERT(isMainThread());
     
    389403    }
    390404
     405    if (!std::isfinite(when) || (when < 0)) {
     406        ec = INVALID_STATE_ERR;
     407        return;
     408    }
     409
     410    if (!std::isfinite(grainOffset) || (grainOffset < 0)) {
     411        ec = INVALID_STATE_ERR;
     412        return;
     413    }
     414
     415    if (!std::isfinite(grainDuration) || (grainDuration < 0)) {
     416        ec = INVALID_STATE_ERR;
     417        return;
     418    }
     419
    391420    if (!buffer())
    392421        return;
    393        
    394     // Do sanity checking of grain parameters versus buffer size.
    395     double bufferDuration = buffer()->duration();
    396 
    397     grainOffset = std::max(0.0, grainOffset);
    398     grainOffset = std::min(bufferDuration, grainOffset);
    399     m_grainOffset = grainOffset;
    400 
    401     // Handle default/unspecified duration.
    402     double maxDuration = bufferDuration - grainOffset;
    403     if (!grainDuration)
    404         grainDuration = maxDuration;
    405 
    406     grainDuration = std::max(0.0, grainDuration);
    407     grainDuration = std::min(maxDuration, grainDuration);
    408     m_grainDuration = grainDuration;
    409 
    410     m_isGrain = true;
     422
     423    m_isGrain = playbackMode == Partial;
     424    if (m_isGrain) {
     425        // Do sanity checking of grain parameters versus buffer size.
     426        double bufferDuration = buffer()->duration();
     427
     428        m_grainOffset = std::min(bufferDuration, grainOffset);
     429
     430        double maxDuration = bufferDuration - m_grainOffset;
     431        m_grainDuration = std::min(maxDuration, grainDuration);
     432    } else {
     433        m_grainOffset = 0.0;
     434        m_grainDuration = DefaultGrainDuration;
     435    }
     436
    411437    m_startTime = when;
    412438   
     
    423449void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
    424450{
    425     startGrain(when, grainOffset, grainDuration, ec);
     451    // Handle unspecified duration where 0 means the rest of the buffer.
     452    if (!grainDuration)
     453        grainDuration = buffer()->duration();
     454    startPlaying(Partial, when, grainOffset, grainDuration, ec);
    426455}
    427456#endif
  • trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h

    r162296 r176311  
    6464
    6565    // Play-state
    66     void startGrain(double when, double grainOffset, ExceptionCode&);
    67     void startGrain(double when, double grainOffset, double grainDuration, ExceptionCode&);
     66    void start(ExceptionCode&);
     67    void start(double when, ExceptionCode&);
     68    void start(double when, double grainOffset, ExceptionCode&);
     69    void start(double when, double grainOffset, double grainDuration, ExceptionCode&);
    6870
    6971#if ENABLE(LEGACY_WEB_AUDIO)
     
    105107    virtual double tailTime() const override { return 0; }
    106108    virtual double latencyTime() const override { return 0; }
     109
     110    enum BufferPlaybackMode {
     111        Entire,
     112        Partial
     113    };
     114
     115    void startPlaying(BufferPlaybackMode, double when, double grainOffset, double grainDuration, ExceptionCode&);
    107116
    108117    // Returns true on success.
  • trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.idl

    r168302 r176311  
    4545    attribute unrestricted double loopEnd;
    4646
    47     [RaisesException] void start(unrestricted double when);
    48     [ImplementedAs=startGrain, RaisesException] void start(unrestricted double when, unrestricted double grainOffset);
    49     [ImplementedAs=startGrain, RaisesException] void start(unrestricted double when, unrestricted double grainOffset, unrestricted double grainDuration);
    50     [RaisesException] void stop(unrestricted double when);
     47    [RaisesException] void start(optional unrestricted double when, optional unrestricted double grainOffset, optional unrestricted double grainDuration);
     48    [RaisesException] void stop(optional unrestricted double when);
    5149
    5250    [Conditional=LEGACY_WEB_AUDIO] attribute boolean looping; // This is an alias for the .loop attribute for backwards compatibility.
  • trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp

    r165716 r176311  
    138138}
    139139
     140void AudioScheduledSourceNode::start(ExceptionCode& ec)
     141{
     142    start(0, ec);
     143}
     144
    140145void AudioScheduledSourceNode::start(double when, ExceptionCode& ec)
    141146{
     
    150155    }
    151156
     157    if (!std::isfinite(when) || (when < 0)) {
     158        ec = INVALID_STATE_ERR;
     159        return;
     160    }
     161
    152162    m_startTime = when;
    153163    m_playbackState = SCHEDULED_STATE;
    154164}
    155165
     166void AudioScheduledSourceNode::stop(ExceptionCode& ec)
     167{
     168    stop(0, ec);
     169}
     170
    156171void AudioScheduledSourceNode::stop(double when, ExceptionCode& ec)
    157172{
     
    161176        return;
    162177    }
    163    
    164     when = std::max<double>(0, when);
     178
     179    if (!std::isfinite(when) || (when < 0)) {
     180        ec = INVALID_STATE_ERR;
     181        return;
     182    }
     183
    165184    m_endTime = when;
    166185}
  • trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h

    r165676 r176311  
    5959
    6060    // Scheduling.
     61    void start(ExceptionCode&);
     62    void stop(ExceptionCode&);
    6163    void start(double when, ExceptionCode&);
    6264    void stop(double when, ExceptionCode&);
  • trunk/Source/WebCore/Modules/webaudio/OscillatorNode.idl

    r168302 r176311  
    4949    readonly attribute AudioParam detune; // in Cents
    5050
    51     [RaisesException] void start(unrestricted double when);
    52     [RaisesException] void stop(unrestricted double when);
     51    [RaisesException] void start(optional unrestricted double when);
     52    [RaisesException] void stop(optional unrestricted double when);
    5353
    5454    [Conditional=LEGACY_WEB_AUDIO, RaisesException] void noteOn(unrestricted double when);
Note: See TracChangeset for help on using the changeset viewer.