[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

crogers at google.com crogers at google.com
Wed Dec 22 13:15:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 3bc1d78cd9d045abdfa17e6f1f0279e94e3ee8f5
Author: crogers at google.com <crogers at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Sep 9 23:58:41 2010 +0000

    2010-09-09  Chris Rogers  <crogers at google.com>
    
            Reviewed by Kenneth Russell.
    
            Add AudioBuffer files
            https://bugs.webkit.org/show_bug.cgi?id=45003
    
            No new tests since audio API is not yet implemented.
    
            * webaudio/AudioBuffer.cpp: Added.
            (WebCore::AudioBuffer::create):
            (WebCore::AudioBuffer::createFromAudioFileData):
            (WebCore::AudioBuffer::AudioBuffer):
            (WebCore::AudioBuffer::releaseMemory):
            (WebCore::AudioBuffer::getChannelData):
            (WebCore::AudioBuffer::zero):
            * webaudio/AudioBuffer.h: Added.
            (WebCore::AudioBuffer::length):
            (WebCore::AudioBuffer::duration):
            (WebCore::AudioBuffer::sampleRate):
            (WebCore::AudioBuffer::numberOfChannels):
            (WebCore::AudioBuffer::gain):
            (WebCore::AudioBuffer::setGain):
            * webaudio/AudioBuffer.idl: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67128 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d4b869f..23aa646 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-09-09  Chris Rogers  <crogers at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        Add AudioBuffer files
+        https://bugs.webkit.org/show_bug.cgi?id=45003
+
+        No new tests since audio API is not yet implemented.
+
+        * webaudio/AudioBuffer.cpp: Added.
+        (WebCore::AudioBuffer::create):
+        (WebCore::AudioBuffer::createFromAudioFileData):
+        (WebCore::AudioBuffer::AudioBuffer):
+        (WebCore::AudioBuffer::releaseMemory):
+        (WebCore::AudioBuffer::getChannelData):
+        (WebCore::AudioBuffer::zero):
+        * webaudio/AudioBuffer.h: Added.
+        (WebCore::AudioBuffer::length):
+        (WebCore::AudioBuffer::duration):
+        (WebCore::AudioBuffer::sampleRate):
+        (WebCore::AudioBuffer::numberOfChannels):
+        (WebCore::AudioBuffer::gain):
+        (WebCore::AudioBuffer::setGain):
+        * webaudio/AudioBuffer.idl: Added.
+
 2010-09-09  Alexey Marinichev  <amarinichev at chromium.org>
 
         Reviewed by James Robinson.
diff --git a/WebCore/webaudio/AudioBuffer.cpp b/WebCore/webaudio/AudioBuffer.cpp
new file mode 100644
index 0000000..f46d153
--- /dev/null
+++ b/WebCore/webaudio/AudioBuffer.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO) & ENABLE(3D_CANVAS)
+
+#include "AudioBuffer.h"
+
+#include "AudioBus.h"
+#include "AudioFileReader.h"
+#include "ExceptionCode.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+PassRefPtr<AudioBuffer> AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrames, double sampleRate)
+{
+    return adoptRef(new AudioBuffer(numberOfChannels, numberOfFrames, sampleRate));
+}
+
+PassRefPtr<AudioBuffer> AudioBuffer::createFromAudioFileData(const void* data, size_t dataSize, bool mixToMono, double sampleRate)
+{
+    OwnPtr<AudioBus> bus = createBusFromInMemoryAudioFile(data, dataSize, mixToMono, sampleRate);
+    if (bus.get())
+        return adoptRef(new AudioBuffer(bus.get()));
+
+    return 0;
+}
+
+AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, double sampleRate)
+    : m_gain(1.0)
+    , m_sampleRate(sampleRate)
+    , m_length(numberOfFrames)
+{
+    m_channels.reserveCapacity(numberOfChannels);
+
+    for (unsigned i = 0; i < numberOfChannels; ++i) {
+        RefPtr<Float32Array> channelDataArray = Float32Array::create(m_length);
+        m_channels.append(channelDataArray);
+    }
+}
+
+AudioBuffer::AudioBuffer(AudioBus* bus)
+    : m_gain(1.0)
+    , m_sampleRate(bus->sampleRate())
+    , m_length(bus->length())
+{
+    // Copy audio data from the bus to the Float32Arrays we manage.
+    unsigned numberOfChannels = bus->numberOfChannels();
+    m_channels.reserveCapacity(numberOfChannels);
+    for (unsigned i = 0; i < numberOfChannels; ++i) {
+        RefPtr<Float32Array> channelDataArray = Float32Array::create(m_length);
+        ExceptionCode ec;
+        channelDataArray->setRange(bus->channel(i)->data(), m_length, 0, ec);
+        m_channels.append(channelDataArray);
+    }
+}
+
+void AudioBuffer::releaseMemory()
+{
+    m_channels.clear();
+}
+
+Float32Array* AudioBuffer::getChannelData(unsigned channelIndex)
+{
+    if (channelIndex >= m_channels.size())
+        return 0;
+
+    return m_channels[channelIndex].get();
+}
+
+void AudioBuffer::zero()
+{
+    for (unsigned i = 0; i < m_channels.size(); ++i) {
+        if (getChannelData(i)) {
+            ExceptionCode ec;
+            getChannelData(i)->zeroRange(0, length(), ec);
+        }
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO) & ENABLE(3D_CANVAS)
diff --git a/WebCore/webaudio/AudioBuffer.h b/WebCore/webaudio/AudioBuffer.h
new file mode 100644
index 0000000..b11a20e
--- /dev/null
+++ b/WebCore/webaudio/AudioBuffer.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AudioBuffer_h
+#define AudioBuffer_h
+
+#include "Float32Array.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class AudioBus;
+    
+class AudioBuffer : public RefCounted<AudioBuffer> {
+public:   
+    static PassRefPtr<AudioBuffer> create(unsigned numberOfChannels, size_t numberOfFrames, double sampleRate);
+
+    // Returns 0 if data is not a valid audio file.
+    static PassRefPtr<AudioBuffer> createFromAudioFileData(const void* data, size_t dataSize, bool mixToMono, double sampleRate);
+
+    // Format
+    size_t length() const { return m_length; }
+    double duration() const { return length() / sampleRate(); }
+    double sampleRate() const { return m_sampleRate; }
+
+    // Channel data access
+    unsigned numberOfChannels() const { return m_channels.size(); }
+    Float32Array* getChannelData(unsigned channelIndex);
+    void zero();
+
+    // Scalar gain
+    double gain() const { return m_gain; }
+    void setGain(double gain) { m_gain = gain; }
+
+    // Because an AudioBuffer has a JavaScript wrapper, which will be garbage collected, it may take awhile for this object to be deleted.
+    // releaseMemory() can be called when the AudioContext goes away, so we can release the memory earlier than when the garbage collection happens.
+    // Careful! Only call this when the page unloads, after the AudioContext is no longer processing.
+    void releaseMemory();
+    
+protected:
+    AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, double sampleRate);
+    AudioBuffer(AudioBus* bus);
+
+    double m_gain; // scalar gain
+    double m_sampleRate;
+    size_t m_length;
+
+    Vector<RefPtr<Float32Array> > m_channels;
+};
+
+} // namespace WebCore
+
+#endif // AudioBuffer_h
diff --git a/WebCore/webaudio/AudioBuffer.idl b/WebCore/webaudio/AudioBuffer.idl
new file mode 100644
index 0000000..e7353bf
--- /dev/null
+++ b/WebCore/webaudio/AudioBuffer.idl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module audio {
+    interface [
+        Conditional=WEB_AUDIO & 3D_CANVAS
+    ] AudioBuffer {
+        readonly attribute long length; // in sample-frames
+        readonly attribute float duration; // in seconds
+        readonly attribute float sampleRate; // in sample-frames per second
+
+        attribute float gain; // linear gain (default 1.0)
+
+        // Channel access
+        readonly attribute unsigned long numberOfChannels;
+        Float32Array getChannelData(in unsigned long channelIndex);
+    };
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list