[Bug 610364] udpsrc: allocates buffers with size a lot bigger than needed

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Tue Sep 9 10:07:53 PDT 2014


https://bugzilla.gnome.org/show_bug.cgi?id=610364
  GStreamer | gst-plugins-good | git

Tim-Philipp Müller <t.i.m> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|HEAD                        |1.5.1

--- Comment #11 from Tim-Philipp Müller <t.i.m at zen.co.uk> 2014-09-09 17:07:42 UTC ---
This should do the trick:

commit e6f77948acb5fdd5bac673a4ad669ed4360a6952
Author: Tim-Philipp Müller <tim at centricular.com>
Date:   Tue Sep 9 13:46:56 2014 +0100

    udpsrc: more efficient memory handling

    Drop use of g_socket_get_available_bytes() which is
    not useful on all systems (where it returns the size
    of the entire buffer not that of the next pending
    packet), and is yet another syscall and apparently
    very inefficient on Windows in the UDP case.

    Instead, when reading UDP packets, use the more featureful
    g_socket_receive_message() call that allows to read into
    scattered memory, and allocate one memory chunk which is
    likely to be large enough for a packet, while also providing
    a larger allocated memory chunk just in case the packet
    is larger than expected. If the received data fits into the
    first chunk, we'll just add that to the buffer we return
    and re-use the fallback buffer for next time, otherwise we
    add both chunks to the buffer.

    This reduces memory waste more reliably on systems where
    get_available_bytes() doesn't work properly.

    In a multimedia streaming scenario, incoming UDP packets
    are almost never fragmented and thus almost always smaller
    than the MTU size, which is also why we don't try to do
    something smarter with more fallback memory chunks of
    different sizes. The fallback scenario is just for when
    someone built a broken sender pipeline (not using a
    payloader or somesuch)

    https://bugzilla.gnome.org/show_bug.cgi?id=610364

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the gstreamer-bugs mailing list