Bug 849713 - Part 1: Add DOM bindings for AudioBufferSourceNode loop attributes; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 10 Mar 2013 12:56:14 -0400
changeset 124742 f74273a94c5b2c23df7172daf7966007b4840c06
parent 124741 c9bbfe4c72ff94cbca85c0e4a65b79cb73699fb6
child 124743 3df9da356bdc9596a147dee15a3753b377818248
push id24575
push usereakhgari@mozilla.com
push dateWed, 13 Mar 2013 20:31:42 +0000
treeherdermozilla-inbound@c7382fcb77a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs849713
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 849713 - Part 1: Add DOM bindings for AudioBufferSourceNode loop attributes; r=roc
content/media/webaudio/AudioBufferSourceNode.cpp
content/media/webaudio/AudioBufferSourceNode.h
content/media/webaudio/test/test_singleSourceDest.html
dom/webidl/AudioBufferSourceNode.webidl
--- a/content/media/webaudio/AudioBufferSourceNode.cpp
+++ b/content/media/webaudio/AudioBufferSourceNode.cpp
@@ -122,16 +122,19 @@ public:
   TrackTicks mStop;
   nsRefPtr<ThreadSharedFloatArrayBufferList> mBuffer;
   int32_t mOffset;
   int32_t mDuration;
 };
 
 AudioBufferSourceNode::AudioBufferSourceNode(AudioContext* aContext)
   : AudioSourceNode(aContext)
+  , mLoopStart(0.0)
+  , mLoopEnd(0.0)
+  , mLoop(false)
   , mStartCalled(false)
 {
   SetProduceOwnOutput(true);
   mStream = aContext->Graph()->CreateAudioNodeStream(new AudioBufferSourceNodeEngine());
   mStream->AddMainThreadListener(this);
 }
 
 AudioBufferSourceNode::~AudioBufferSourceNode()
--- a/content/media/webaudio/AudioBufferSourceNode.h
+++ b/content/media/webaudio/AudioBufferSourceNode.h
@@ -46,20 +46,48 @@ public:
   {
     return mBuffer;
   }
   void SetBuffer(AudioBuffer* aBuffer)
   {
     mBuffer = aBuffer;
   }
 
+  bool Loop() const
+  {
+    return mLoop;
+  }
+  void SetLoop(bool aLoop)
+  {
+    mLoop = aLoop;
+  }
+  double LoopStart() const
+  {
+    return mLoopStart;
+  }
+  void SetLoopStart(double aStart)
+  {
+    mLoopStart = aStart;
+  }
+  double LoopEnd() const
+  {
+    return mLoopEnd;
+  }
+  void SetLoopEnd(double aEnd)
+  {
+    mLoopEnd = aEnd;
+  }
+
   virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
 
 private:
   nsRefPtr<AudioBuffer> mBuffer;
+  double mLoopStart;
+  double mLoopEnd;
+  bool mLoop;
   bool mStartCalled;
 };
 
 }
 }
 
 #endif
 
--- a/content/media/webaudio/test/test_singleSourceDest.html
+++ b/content/media/webaudio/test/test_singleSourceDest.html
@@ -24,16 +24,19 @@ addLoadEvent(function() {
   is(destination.context, context, "Destination node has proper context");
   is(destination.numberOfInputs, 1, "Destination node has 1 inputs");
   is(destination.numberOfOutputs, 0, "Destination node has 0 outputs");
 
   var source = context.createBufferSource();
   is(source.context, context, "Source node has proper context");
   is(source.numberOfInputs, 0, "Source node has 0 inputs");
   is(source.numberOfOutputs, 1, "Source node has 1 outputs");
+  is(source.loop, false, "Source node is not looping");
+  is(source.loopStart, 0, "Correct default value for loopStart");
+  is(source.loopEnd, 0, "Correct default value for loopEnd");
   ok(!source.buffer, "Source node should not have a buffer when it's created");
 
   source.buffer = buffer;
   ok(source.buffer, "Source node should have a buffer now");
 
   source.connect(destination);
 
   is(source.numberOfInputs, 0, "Source node has 0 inputs");
--- a/dom/webidl/AudioBufferSourceNode.webidl
+++ b/dom/webidl/AudioBufferSourceNode.webidl
@@ -20,16 +20,19 @@ interface AudioBufferSourceNode : AudioS
 
     //readonly attribute unsigned short playbackState;
 
     // Playback this in-memory audio asset  
     // Many sources can share the same buffer  
     attribute AudioBuffer? buffer;
 
     //attribute AudioParam playbackRate;
-    //attribute boolean loop;
+
+    attribute boolean loop;
+    attribute double loopStart;
+    attribute double loopEnd;
 
     [Throws]
     void start(optional double when = 0, optional double grainOffset = 0,
                optional double grainDuration);
     [Throws]
     void stop(optional double when = 0);
 };