Exception should be thrown when noteOn and noteOff are not called properly
authorPraveen R Jadhav <praveen.j@samsung.com>
Fri, 22 Mar 2013 12:22:36 +0000 (21:22 +0900)
committerGerrit Code Review <gerrit2@kim11>
Tue, 26 Mar 2013 12:39:49 +0000 (21:39 +0900)
[Title] : Exception should be thrown when noteOn and noteOff are not called properly
[Issue] : TWEB-1091
[Problem] : Exception handling mechanism implementation is not available
[Solution] : Exception handling mechanism is implemented

Change-Id: I92735f97e0df3481f46b06272e2215a7295d4283

Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp
Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h
Source/WebCore/Modules/webaudio/AudioBufferSourceNode.idl
Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp
Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h
Source/WebCore/Modules/webaudio/OscillatorNode.idl

index 42fdd7e..5903020 100644 (file)
@@ -372,18 +372,37 @@ unsigned AudioBufferSourceNode::numberOfChannels()
     return output(0)->numberOfChannels();
 }
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+void AudioBufferSourceNode::startGrain(double when, double grainOffset, ExceptionCode& ec)
+{
+    // Duration of 0 has special value, meaning calculate based on the entire buffer's duration.
+    startGrain(when, grainOffset, 0, ec);
+}
+#else
 void AudioBufferSourceNode::startGrain(double when, double grainOffset)
 {
     // Duration of 0 has special value, meaning calculate based on the entire buffer's duration.
     startGrain(when, grainOffset, 0);
 }
+#endif
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
+#else
 void AudioBufferSourceNode::startGrain(double when, double grainOffset, double grainDuration)
+#endif
 {
     ASSERT(isMainThread());
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+    if (m_playbackState != UNSCHEDULED_STATE) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+#else
     if (m_playbackState != UNSCHEDULED_STATE)
         return;
+#endif
 
     if (!buffer())
         return;
@@ -416,12 +435,21 @@ void AudioBufferSourceNode::startGrain(double when, double grainOffset, double g
     m_playbackState = SCHEDULED_STATE;
 }
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+#if ENABLE(LEGACY_WEB_AUDIO)
+void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration, ExceptionCode& ec)
+{
+    startGrain(when, grainOffset, grainDuration, ec);
+}
+#endif
+#else
 #if ENABLE(LEGACY_WEB_AUDIO)
 void AudioBufferSourceNode::noteGrainOn(double when, double grainOffset, double grainDuration)
 {
     startGrain(when, grainOffset, grainDuration);
 }
 #endif
+#endif
 
 double AudioBufferSourceNode::totalPitchRate()
 {
index fc5699b..186cdee 100644 (file)
@@ -29,6 +29,9 @@
 #include "AudioBus.h"
 #include "AudioGain.h"
 #include "AudioScheduledSourceNode.h"
+#if ENABLE(TIZEN_WEB_AUDIO)
+#include "ExceptionCode.h"
+#endif
 #include "PannerNode.h"
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/PassRefPtr.h>
@@ -60,7 +63,16 @@ public:
     // numberOfChannels() returns the number of output channels.  This value equals the number of channels from the buffer.
     // If a new buffer is set with a different number of channels, then this value will dynamically change.
     unsigned numberOfChannels();
-                    
+
+#if ENABLE(TIZEN_WEB_AUDIO)
+    // Play-state
+    void startGrain(double when, double grainOffset, ExceptionCode&);
+    void startGrain(double when, double grainOffset, double grainDuration, ExceptionCode&);
+
+#if ENABLE(LEGACY_WEB_AUDIO)
+    void noteGrainOn(double when, double grainOffset, double grainDuration, ExceptionCode&);
+#endif
+#else
     // Play-state
     void startGrain(double when, double grainOffset);
     void startGrain(double when, double grainOffset, double grainDuration);
@@ -68,6 +80,7 @@ public:
 #if ENABLE(LEGACY_WEB_AUDIO)
     void noteGrainOn(double when, double grainOffset, double grainDuration);
 #endif
+#endif
 
     // Note: the attribute was originally exposed as .looping, but to be more consistent in naming with <audio>
     // and with how it's described in the specification, the proper attribute name is .loop
index 24e45cd..a90c033 100644 (file)
@@ -46,6 +46,27 @@ module audio {
         attribute double loopStart;
         attribute double loopEnd;
 
+#if defined(ENABLE_TIZEN_WEB_AUDIO)
+        [V8MeasureAs=WebAudioStart] void start(in double when)
+            raises (DOMException);
+        [V8MeasureAs=WebAudioStart, ImplementedAs=startGrain] void start(in double when, in double grainOffset)
+            raises (DOMException);
+        [V8MeasureAs=WebAudioStart, ImplementedAs=startGrain] void start(in double when, in double grainOffset, in double grainDuration)
+            raises (DOMException);
+        void stop(in double when)
+            raises (DOMException);
+
+#if defined(ENABLE_LEGACY_WEB_AUDIO) && ENABLE_LEGACY_WEB_AUDIO
+        attribute boolean looping; // This is an alias for the .loop attribute for backwards compatibility.
+
+        [V8MeasureAs=LegacyWebAudio] void noteOn(in double when)
+            raises (DOMException);
+        [V8MeasureAs=LegacyWebAudio] void noteGrainOn(in double when, in double grainOffset, in double grainDuration)
+            raises (DOMException);
+        void noteOff(in double when)
+            raises (DOMException);
+#endif
+#else
         [V8MeasureAs=WebAudioStart] void start(in double when);
         [V8MeasureAs=WebAudioStart, ImplementedAs=startGrain] void start(in double when, in double grainOffset);
         [V8MeasureAs=WebAudioStart, ImplementedAs=startGrain] void start(in double when, in double grainOffset, in double grainDuration);
@@ -58,5 +79,6 @@ module audio {
         [V8MeasureAs=LegacyWebAudio] void noteGrainOn(in double when, in double grainOffset, in double grainDuration);
         void noteOff(in double when);
 #endif
+#endif
     };
 }
index f157fb7..9a79e2b 100644 (file)
@@ -132,6 +132,43 @@ void AudioScheduledSourceNode::updateSchedulingInfo(size_t quantumFrameSize,
     return;
 }
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+void AudioScheduledSourceNode::start(double when, ExceptionCode& ec)
+{
+    ASSERT(isMainThread());
+    if (m_playbackState != UNSCHEDULED_STATE) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
+    m_startTime = when;
+    m_playbackState = SCHEDULED_STATE;
+}
+
+void AudioScheduledSourceNode::stop(double when, ExceptionCode& ec)
+{
+    ASSERT(isMainThread());
+    if (!(m_playbackState == SCHEDULED_STATE || m_playbackState == PLAYING_STATE) || (m_endTime != UnknownTime)) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+
+    when = max(0.0, when);
+    m_endTime = when;
+}
+
+#if ENABLE(LEGACY_WEB_AUDIO)
+void AudioScheduledSourceNode::noteOn(double when, ExceptionCode& ec)
+{
+    start(when, ec);
+}
+
+void AudioScheduledSourceNode::noteOff(double when, ExceptionCode& ec)
+{
+    stop(when, ec);
+}
+#endif
+#else
 void AudioScheduledSourceNode::start(double when)
 {
     ASSERT(isMainThread());
@@ -163,6 +200,7 @@ void AudioScheduledSourceNode::noteOff(double when)
     stop(when);
 }
 #endif
+#endif
 
 void AudioScheduledSourceNode::finish()
 {
index 0a4502e..f14d143 100644 (file)
@@ -30,6 +30,9 @@
 #define AudioScheduledSourceNode_h
 
 #include "AudioSourceNode.h"
+#if ENABLE(TIZEN_WEB_AUDIO)
+#include "ExceptionCode.h"
+#endif
 
 namespace WebCore {
 
@@ -56,6 +59,16 @@ public:
     
     AudioScheduledSourceNode(AudioContext*, float sampleRate);
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+    // Scheduling.
+    void start(double when, ExceptionCode&);
+    void stop(double when, ExceptionCode&);
+
+#if ENABLE(LEGACY_WEB_AUDIO)
+    void noteOn(double when, ExceptionCode&);
+    void noteOff(double when, ExceptionCode&);
+#endif
+#else
     // Scheduling.
     void start(double when);
     void stop(double when);
@@ -64,6 +77,7 @@ public:
     void noteOn(double when);
     void noteOff(double when);
 #endif
+#endif
 
     unsigned short playbackState() const { return static_cast<unsigned short>(m_playbackState); }
     bool isPlayingOrScheduled() const { return m_playbackState == PLAYING_STATE || m_playbackState == SCHEDULED_STATE; }
index 92901a3..24a3e0a 100644 (file)
@@ -49,6 +49,19 @@ module audio {
         readonly attribute AudioParam frequency; // in Hertz
         readonly attribute AudioParam detune; // in Cents
 
+#if defined(ENABLE_TIZEN_WEB_AUDIO)
+        void start(in double when)
+            raises (DOMException);
+        void stop(in double when)
+            raises (DOMException);
+
+#if defined(ENABLE_LEGACY_WEB_AUDIO) && ENABLE_LEGACY_WEB_AUDIO
+        void noteOn(in double when)
+            raises (DOMException);
+        void noteOff(in double when)
+            raises (DOMException);
+#endif
+#else
         void start(in double when);
         void stop(in double when);
 
@@ -56,6 +69,7 @@ module audio {
         void noteOn(in double when);
         void noteOff(in double when);
 #endif
+#endif
 
         void setWaveTable(in WaveTable waveTable);