Title: [147567] trunk/Source/WebCore
Revision
147567
Author
[email protected]
Date
2013-04-03 11:12:40 -0700 (Wed, 03 Apr 2013)

Log Message

[Gstreamer] Use gst_buffer_extract() in copyGstreamerBuffersToAudioChannel()
https://bugs.webkit.org/show_bug.cgi?id=113880

Reviewed by Philippe Normand.

copyGstreamerBuffersToAudioChannel() was mapping the GstBuffer content to memcpy
it to the AudioChannel buffer. This patch leverages gst_buffer_extract() to
simplify the code as it does exactly what we need: gst_buffer_map, memcpy,
gst_buffer_unmap and error handling.

Also replace GstBuffer NULL check by an assertion as we already make sure they
are not NULL before adding them to the list. Additionally, we now call
audioChannel->mutableData() only once instead of once per iteration. It is
a bit better as the getter does some work internally.

No new tests, no behavior change.

* platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
(WebCore::copyGstreamerBuffersToAudioChannel):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147566 => 147567)


--- trunk/Source/WebCore/ChangeLog	2013-04-03 17:30:32 UTC (rev 147566)
+++ trunk/Source/WebCore/ChangeLog	2013-04-03 18:12:40 UTC (rev 147567)
@@ -1,3 +1,25 @@
+2013-04-03  Christophe Dumez  <[email protected]>
+
+        [Gstreamer] Use gst_buffer_extract() in copyGstreamerBuffersToAudioChannel()
+        https://bugs.webkit.org/show_bug.cgi?id=113880
+
+        Reviewed by Philippe Normand.
+
+        copyGstreamerBuffersToAudioChannel() was mapping the GstBuffer content to memcpy
+        it to the AudioChannel buffer. This patch leverages gst_buffer_extract() to
+        simplify the code as it does exactly what we need: gst_buffer_map, memcpy,
+        gst_buffer_unmap and error handling.
+
+        Also replace GstBuffer NULL check by an assertion as we already make sure they
+        are not NULL before adding them to the list. Additionally, we now call
+        audioChannel->mutableData() only once instead of once per iteration. It is
+        a bit better as the getter does some work internally.
+
+        No new tests, no behavior change.
+
+        * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
+        (WebCore::copyGstreamerBuffersToAudioChannel):
+
 2013-04-03  Antoine Quint  <[email protected]>
 
         Web Inspector: DOM.highlightRect() and DOM.highlightQuad() should allow for page coordinates

Modified: trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp (147566 => 147567)


--- trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2013-04-03 17:30:32 UTC (rev 147566)
+++ trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2013-04-03 18:12:40 UTC (rev 147567)
@@ -100,16 +100,14 @@
 static void copyGstreamerBuffersToAudioChannel(GstBufferList* buffers, AudioChannel* audioChannel)
 {
 #ifdef GST_API_VERSION_1
-    gsize offset = 0;
-    for (unsigned i = 0; i < gst_buffer_list_length(buffers); i++) {
+    float* destination = audioChannel->mutableData();
+    unsigned bufferCount = gst_buffer_list_length(buffers);
+    for (unsigned i = 0; i < bufferCount; ++i) {
         GstBuffer* buffer = gst_buffer_list_get(buffers, i);
-        if (!buffer)
-            continue;
-        GstMapInfo info;
-        gst_buffer_map(buffer, &info, GST_MAP_READ);
-        memcpy(audioChannel->mutableData() + offset, reinterpret_cast<float*>(info.data), info.size);
-        offset += info.size / sizeof(float);
-        gst_buffer_unmap(buffer, &info);
+        ASSERT(buffer);
+        gsize bufferSize = gst_buffer_get_size(buffer);
+        gst_buffer_extract(buffer, 0, destination, bufferSize);
+        destination += bufferSize / sizeof(float);
     }
 #else
     GstBufferListIterator* iter = gst_buffer_list_iterate(buffers);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to