diff options
author | Wim Taymans <wtaymans@redhat.com> | 2020-04-23 13:01:03 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2020-04-23 13:01:03 +0200 |
commit | 5d1292915309c2168fd413c8dbd36a5a0831549c (patch) | |
tree | a49145d376caadaa131dc09f8115bf06a279f8a6 /src | |
parent | 26fa35a0e7e9588c1d270877996f652bc819c815 (diff) |
gst: use the pw_stream queue
There is no need to keep a separate queue in the source, simply use
the one from pw_stream.
Diffstat (limited to 'src')
-rw-r--r-- | src/gst/gstpipewiresrc.c | 54 | ||||
-rw-r--r-- | src/gst/gstpipewiresrc.h | 1 |
2 files changed, 12 insertions, 43 deletions
diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c index d2e9b321..13f14d45 100644 --- a/src/gst/gstpipewiresrc.c +++ b/src/gst/gstpipewiresrc.c @@ -214,25 +214,11 @@ clock_disabled: } } -static void unref_queue_item(gpointer data, gpointer user_data) -{ - gst_mini_object_unref(data); -} - -static void -clear_queue (GstPipeWireSrc *pwsrc) -{ - g_queue_foreach (&pwsrc->queue, unref_queue_item, pwsrc); - g_queue_clear (&pwsrc->queue); -} - static void gst_pipewire_src_finalize (GObject * object) { GstPipeWireSrc *pwsrc = GST_PIPEWIRE_SRC (object); - clear_queue (pwsrc); - pw_context_destroy (pwsrc->context); pwsrc->context = NULL; pw_thread_loop_destroy (pwsrc->loop); @@ -367,8 +353,6 @@ gst_pipewire_src_init (GstPipeWireSrc * src) src->max_buffers = DEFAULT_MAX_BUFFERS; src->fd = -1; - g_queue_init (&src->queue); - src->client_name = g_strdup(pw_get_client_name ()); src->pool = gst_pipewire_pool_new (); @@ -417,29 +401,16 @@ on_remove_buffer (void *_data, struct pw_buffer *b) GstPipeWireSrc *pwsrc = _data; GstPipeWirePoolData *data = b->user_data; GstBuffer *buf = data->buf; - GList *walk; GST_DEBUG_OBJECT (pwsrc, "remove buffer %p", buf); GST_MINI_OBJECT_CAST (buf)->dispose = NULL; - walk = pwsrc->queue.head; - while (walk) { - GList *next = walk->next; - - if (walk->data == buf) { - gst_buffer_unref (buf); - g_queue_delete_link (&pwsrc->queue, walk); - } - walk = next; - } gst_buffer_unref (buf); } -static void -on_process (void *_data) +static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc) { - GstPipeWireSrc *pwsrc = _data; struct pw_buffer *b; GstBuffer *buf; GstPipeWirePoolData *data; @@ -448,7 +419,7 @@ on_process (void *_data) b = pw_stream_dequeue_buffer (pwsrc->stream); if (b == NULL) - return; + return NULL; data = b->user_data; buf = data->buf; @@ -476,12 +447,14 @@ on_process (void *_data) mem->size = SPA_MIN(d->chunk->size, d->maxsize - mem->offset); mem->offset += data->offset; } + return buf; +} - gst_buffer_ref (buf); - g_queue_push_tail (&pwsrc->queue, buf); - +static void +on_process (void *_data) +{ + GstPipeWireSrc *pwsrc = _data; pw_thread_loop_signal (pwsrc->loop, FALSE); - return; } static void @@ -873,7 +846,8 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer) if (state != PW_STREAM_STATE_STREAMING) goto streaming_stopped; - buf = g_queue_pop_head (&pwsrc->queue); + + buf = dequeue_buffer (pwsrc); GST_LOG_OBJECT (pwsrc, "popped buffer %p", buf); if (buf != NULL) break; @@ -882,8 +856,6 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer) } pw_thread_loop_unlock (pwsrc->loop); - gst_buffer_unref (buf); - if (pwsrc->always_copy) { *buffer = gst_buffer_copy_deep (buf); gst_buffer_unref (buf); @@ -905,7 +877,8 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer) dts = (dts >= base_time ? dts - base_time : 0); GST_LOG_OBJECT (pwsrc, - "pts %" G_GUINT64_FORMAT ", dts %" G_GUINT64_FORMAT ", base-time %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT ", %" GST_TIME_FORMAT, + "pts %" G_GUINT64_FORMAT ", dts %" G_GUINT64_FORMAT + ", base-time %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT ", %" GST_TIME_FORMAT, GST_BUFFER_PTS (*buffer), GST_BUFFER_DTS (*buffer), GST_TIME_ARGS (base_time), GST_TIME_ARGS (pts), GST_TIME_ARGS (dts)); @@ -944,7 +917,6 @@ gst_pipewire_src_stop (GstBaseSrc * basesrc) pwsrc = GST_PIPEWIRE_SRC (basesrc); pw_thread_loop_lock (pwsrc->loop); - clear_queue (pwsrc); pw_thread_loop_unlock (pwsrc->loop); return TRUE; @@ -1037,8 +1009,6 @@ no_stream: static void gst_pipewire_src_close (GstPipeWireSrc * pwsrc) { - clear_queue (pwsrc); - pw_thread_loop_stop (pwsrc->loop); pwsrc->last_time = gst_clock_get_time (pwsrc->clock); diff --git a/src/gst/gstpipewiresrc.h b/src/gst/gstpipewiresrc.h index c80e13ee..acefd078 100644 --- a/src/gst/gstpipewiresrc.h +++ b/src/gst/gstpipewiresrc.h @@ -84,7 +84,6 @@ struct _GstPipeWireSrc { GstStructure *properties; GstPipeWirePool *pool; - GQueue queue; GstClock *clock; GstClockTime last_time; }; |