mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-10 00:12:48 +00:00
srt: Use simpler list operations for callers
Avoid `g_list_append` and `g_list_remove` (which have to scan the list) and replace them with `g_list_prepend` and `g_list_delete_link`. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3329>
This commit is contained in:
parent
68cd5e1de1
commit
253a5cc125
1 changed files with 6 additions and 7 deletions
|
@ -973,7 +973,7 @@ thread_func (gpointer data)
|
||||||
caller->sock);
|
caller->sock);
|
||||||
|
|
||||||
g_mutex_lock (&srtobject->sock_lock);
|
g_mutex_lock (&srtobject->sock_lock);
|
||||||
srtobject->callers = g_list_append (srtobject->callers, caller);
|
srtobject->callers = g_list_prepend (srtobject->callers, caller);
|
||||||
g_cond_signal (&srtobject->sock_cond);
|
g_cond_signal (&srtobject->sock_cond);
|
||||||
g_mutex_unlock (&srtobject->sock_lock);
|
g_mutex_unlock (&srtobject->sock_lock);
|
||||||
|
|
||||||
|
@ -1661,18 +1661,17 @@ gst_srt_object_write_to_callers (GstSRTObject * srtobject,
|
||||||
GstBufferList * headers,
|
GstBufferList * headers,
|
||||||
const GstMapInfo * mapinfo, GCancellable * cancellable)
|
const GstMapInfo * mapinfo, GCancellable * cancellable)
|
||||||
{
|
{
|
||||||
GList *callers;
|
GList *item, *next;
|
||||||
|
|
||||||
g_mutex_lock (&srtobject->sock_lock);
|
g_mutex_lock (&srtobject->sock_lock);
|
||||||
callers = srtobject->callers;
|
for (item = srtobject->callers, next = NULL; item; item = next) {
|
||||||
while (callers != NULL) {
|
SRTCaller *caller = item->data;
|
||||||
gssize len = 0;
|
gssize len = 0;
|
||||||
const guint8 *msg = mapinfo->data;
|
const guint8 *msg = mapinfo->data;
|
||||||
gint sent;
|
gint sent;
|
||||||
gint payload_size, optlen = sizeof (payload_size);
|
gint payload_size, optlen = sizeof (payload_size);
|
||||||
|
|
||||||
SRTCaller *caller = callers->data;
|
next = item->next;
|
||||||
callers = callers->next;
|
|
||||||
|
|
||||||
if (g_cancellable_is_cancelled (cancellable)) {
|
if (g_cancellable_is_cancelled (cancellable)) {
|
||||||
goto cancelled;
|
goto cancelled;
|
||||||
|
@ -1714,7 +1713,7 @@ gst_srt_object_write_to_callers (GstSRTObject * srtobject,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
srtobject->callers = g_list_remove (srtobject->callers, caller);
|
srtobject->callers = g_list_delete_link (srtobject->callers, item);
|
||||||
srt_caller_signal_removed (caller, srtobject);
|
srt_caller_signal_removed (caller, srtobject);
|
||||||
srt_caller_free (caller);
|
srt_caller_free (caller);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue