mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-05 17:09: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);
|
||||
|
||||
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_mutex_unlock (&srtobject->sock_lock);
|
||||
|
||||
|
@ -1661,18 +1661,17 @@ gst_srt_object_write_to_callers (GstSRTObject * srtobject,
|
|||
GstBufferList * headers,
|
||||
const GstMapInfo * mapinfo, GCancellable * cancellable)
|
||||
{
|
||||
GList *callers;
|
||||
GList *item, *next;
|
||||
|
||||
g_mutex_lock (&srtobject->sock_lock);
|
||||
callers = srtobject->callers;
|
||||
while (callers != NULL) {
|
||||
for (item = srtobject->callers, next = NULL; item; item = next) {
|
||||
SRTCaller *caller = item->data;
|
||||
gssize len = 0;
|
||||
const guint8 *msg = mapinfo->data;
|
||||
gint sent;
|
||||
gint payload_size, optlen = sizeof (payload_size);
|
||||
|
||||
SRTCaller *caller = callers->data;
|
||||
callers = callers->next;
|
||||
next = item->next;
|
||||
|
||||
if (g_cancellable_is_cancelled (cancellable)) {
|
||||
goto cancelled;
|
||||
|
@ -1714,7 +1713,7 @@ gst_srt_object_write_to_callers (GstSRTObject * srtobject,
|
|||
continue;
|
||||
|
||||
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_free (caller);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue