mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
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.
This commit is contained in:
parent
26fa35a0e7
commit
5d12929153
2 changed files with 12 additions and 43 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ struct _GstPipeWireSrc {
|
|||
GstStructure *properties;
|
||||
|
||||
GstPipeWirePool *pool;
|
||||
GQueue queue;
|
||||
GstClock *clock;
|
||||
GstClockTime last_time;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue