[Webkit-unassigned] [Bug 69834] [GStreamer] WebAudio AudioFileReader implementation

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Oct 14 02:09:22 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=69834





--- Comment #20 from Sebastian Dröge <slomo at circular-chaos.org>  2011-10-14 02:09:22 PST ---
(From update of attachment 110979)
View in context: https://bugs.webkit.org/attachment.cgi?id=110979&action=review

> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:73
> +    GOwnPtr<gchar> capsDescription(g_strdup_printf(capsTemplate, static_cast<int>(sampleRate), channels, G_BYTE_ORDER));

You can use BYTE_ORDER directly in the caps template string or even easier:
return gst_caps_new_simple ("audio/x-raw-float", "rate", G_TYPE_INT, (int) sampleRate, "channels", G_TYPE_INT, channels, "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL)

> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:88
> +    GstByteReader* byteReader = gst_byte_reader_new_from_buffer(buffer);

GstByteReader byteReader = GST_BYTE_READER_INIT_FROM_BUFFER(buffer)

No need to free it later then, keeps memory fragmentation smaller, etc.

> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:92
> +        *audioChannel++ = value;

You can simple memcpy() here. Just cast GST_BUFFER_DATA() to a float*. It already has correct alignment and endianness and everything.

Also, how do you know that audioChannel is large enough for all samples inside the buffer?

> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:162
> +    if (!channels || !channelPositionsValue || !gst_value_is_fixed(channelPositionsValue)) {

No need to check for !fixed here. That can never ever happen

> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:174
> +        m_bufferFrontRight = gst_buffer_join(m_bufferFrontRight, buffer);

Instead of joining the buffers here you might want to keep a list of buffers and copy from them in copyGstreamerBufferToAudioChannel(). That keeps the copying, reallocations, etc lower. Just make sure to get an additional ref of the buffer.

> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:216
> +    GstElement* sink = gst_element_factory_make("appsink", 0);

You probably want to set "sync" to FALSE on appsink. Otherwise it will only give you buffers in real time, not as fast as it can.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list