Title: [131262] trunk/Source
Revision
131262
Author
[email protected]
Date
2012-10-13 11:21:50 -0700 (Sat, 13 Oct 2012)

Log Message

WebAudioBus needs support for resizing bus to a smaller size
https://bugs.webkit.org/show_bug.cgi?id=99215

Reviewed by Dimitri Glazkov.

Upgrade AudioBus and WebAudioBus to support resizing to a smaller size, once it has been created.
This is useful, for example, when decoding VBR formats and the actual length can't be exactly determined
until the entire file is decoded.

Source/Platform:

* chromium/public/WebAudioBus.h:
(WebAudioBus):

Source/WebCore:

* platform/audio/AudioBus.cpp:
(WebCore::AudioBus::resizeSmaller):
(WebCore):
* platform/audio/AudioBus.h:
(AudioBus):
* platform/audio/AudioChannel.cpp:
(WebCore::AudioChannel::resizeSmaller):
(WebCore):
* platform/audio/AudioChannel.h:
(AudioChannel):
* platform/chromium/support/WebAudioBus.cpp:
(WebKit::WebAudioBus::resizeSmaller):
(WebKit):

Modified Paths

Diff

Modified: trunk/Source/Platform/ChangeLog (131261 => 131262)


--- trunk/Source/Platform/ChangeLog	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/Platform/ChangeLog	2012-10-13 18:21:50 UTC (rev 131262)
@@ -1,3 +1,17 @@
+2012-10-13  Chris Rogers  <[email protected]>
+
+        WebAudioBus needs support for resizing bus to a smaller size
+        https://bugs.webkit.org/show_bug.cgi?id=99215
+
+        Reviewed by Dimitri Glazkov.
+
+        Upgrade AudioBus and WebAudioBus to support resizing to a smaller size, once it has been created.
+        This is useful, for example, when decoding VBR formats and the actual length can't be exactly determined
+        until the entire file is decoded.
+
+        * chromium/public/WebAudioBus.h:
+        (WebAudioBus):
+
 2012-10-10  Scott Violet  <[email protected]>
 
         Expose background color in WebLayer https://bugs.webkit.org/show_bug.cgi?id=98707

Modified: trunk/Source/Platform/chromium/public/WebAudioBus.h (131261 => 131262)


--- trunk/Source/Platform/chromium/public/WebAudioBus.h	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/Platform/chromium/public/WebAudioBus.h	2012-10-13 18:21:50 UTC (rev 131262)
@@ -49,6 +49,10 @@
     // initialize() allocates memory of the given length for the given number of channels.
     WEBKIT_EXPORT void initialize(unsigned numberOfChannels, size_t length, double sampleRate);
 
+    // resizeSmaller() can only be called after initialize() with a new length <= the initialization length.
+    // The data stored in the bus will remain undisturbed.
+    WEBKIT_EXPORT void resizeSmaller(size_t newLength);
+
     // reset() releases the memory allocated from initialize().
     WEBKIT_EXPORT void reset();
     

Modified: trunk/Source/WebCore/ChangeLog (131261 => 131262)


--- trunk/Source/WebCore/ChangeLog	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/WebCore/ChangeLog	2012-10-13 18:21:50 UTC (rev 131262)
@@ -1,3 +1,28 @@
+2012-10-13  Chris Rogers  <[email protected]>
+
+        WebAudioBus needs support for resizing bus to a smaller size
+        https://bugs.webkit.org/show_bug.cgi?id=99215
+
+        Reviewed by Dimitri Glazkov.
+
+        Upgrade AudioBus and WebAudioBus to support resizing to a smaller size, once it has been created.
+        This is useful, for example, when decoding VBR formats and the actual length can't be exactly determined
+        until the entire file is decoded.
+
+        * platform/audio/AudioBus.cpp:
+        (WebCore::AudioBus::resizeSmaller):
+        (WebCore):
+        * platform/audio/AudioBus.h:
+        (AudioBus):
+        * platform/audio/AudioChannel.cpp:
+        (WebCore::AudioChannel::resizeSmaller):
+        (WebCore):
+        * platform/audio/AudioChannel.h:
+        (AudioChannel):
+        * platform/chromium/support/WebAudioBus.cpp:
+        (WebKit::WebAudioBus::resizeSmaller):
+        (WebKit):
+
 2012-10-13  Gregg Tavares  <[email protected]>
 
         Add warning for unrenderable textures

Modified: trunk/Source/WebCore/platform/audio/AudioBus.cpp (131261 => 131262)


--- trunk/Source/WebCore/platform/audio/AudioBus.cpp	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/WebCore/platform/audio/AudioBus.cpp	2012-10-13 18:21:50 UTC (rev 131262)
@@ -76,6 +76,16 @@
     }
 }
 
+void AudioBus::resizeSmaller(size_t newLength)
+{
+    ASSERT(newLength <= m_length);
+    if (newLength <= m_length)
+        m_length = newLength;
+
+    for (unsigned i = 0; i < m_channels.size(); ++i)
+        m_channels[i]->resizeSmaller(newLength);
+}
+
 void AudioBus::zero()
 {
     for (unsigned i = 0; i < m_channels.size(); ++i)

Modified: trunk/Source/WebCore/platform/audio/AudioBus.h (131261 => 131262)


--- trunk/Source/WebCore/platform/audio/AudioBus.h	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/WebCore/platform/audio/AudioBus.h	2012-10-13 18:21:50 UTC (rev 131262)
@@ -76,6 +76,10 @@
     // Number of sample-frames
     size_t length() const { return m_length; }
 
+    // resizeSmaller() can only be called with a new length <= the current length.
+    // The data stored in the bus will remain undisturbed.
+    void resizeSmaller(size_t newLength);
+
     // Sample-rate : 0.0 if unknown or "don't care"
     float sampleRate() const { return m_sampleRate; }
     void setSampleRate(float sampleRate) { m_sampleRate = sampleRate; }

Modified: trunk/Source/WebCore/platform/audio/AudioChannel.cpp (131261 => 131262)


--- trunk/Source/WebCore/platform/audio/AudioChannel.cpp	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/WebCore/platform/audio/AudioChannel.cpp	2012-10-13 18:21:50 UTC (rev 131262)
@@ -41,6 +41,13 @@
 
 using namespace VectorMath;
 
+void AudioChannel::resizeSmaller(size_t newLength)
+{
+    ASSERT(newLength <= m_length);
+    if (newLength <= m_length)
+        m_length = newLength;
+}
+
 void AudioChannel::scale(float scale)
 {
     if (isSilent())

Modified: trunk/Source/WebCore/platform/audio/AudioChannel.h (131261 => 131262)


--- trunk/Source/WebCore/platform/audio/AudioChannel.h	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/WebCore/platform/audio/AudioChannel.h	2012-10-13 18:21:50 UTC (rev 131262)
@@ -79,6 +79,10 @@
     // How many sample-frames do we contain?
     size_t length() const { return m_length; }
 
+    // resizeSmaller() can only be called with a new length <= the current length.
+    // The data stored in the bus will remain undisturbed.
+    void resizeSmaller(size_t newLength);
+
     // Direct access to PCM sample data. Non-const accessor clears silent flag.
     float* mutableData()
     {

Modified: trunk/Source/WebCore/platform/chromium/support/WebAudioBus.cpp (131261 => 131262)


--- trunk/Source/WebCore/platform/chromium/support/WebAudioBus.cpp	2012-10-13 17:55:36 UTC (rev 131261)
+++ trunk/Source/WebCore/platform/chromium/support/WebAudioBus.cpp	2012-10-13 18:21:50 UTC (rev 131262)
@@ -58,6 +58,19 @@
 #endif
 }
 
+void WebAudioBus::resizeSmaller(size_t newLength)
+{
+#if ENABLE(WEB_AUDIO)
+    ASSERT(m_private);
+    if (m_private) {
+        ASSERT(newLength <= length());
+        m_private->resizeSmaller(newLength);
+    }
+#else
+    ASSERT_NOT_REACHED();
+#endif
+}
+
 void WebAudioBus::reset()
 {
 #if ENABLE(WEB_AUDIO)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to