mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
buffer: allow building into custom memory
Make it possible to pass custom memory to the builder so that it can construct packets directly into specified memory and avoid allocs. Remove GError and GSocketControlMessage in the buffer API to make it possible to use other (rt-safe) API later.
This commit is contained in:
parent
91385a782e
commit
c67d3d7f04
9 changed files with 240 additions and 175 deletions
|
|
@ -201,7 +201,7 @@ release_fds (GstPinosSocketSink *this, GstBuffer *buffer)
|
|||
pinos_buffer_builder_end (&b, &pbuf);
|
||||
g_array_unref (fdids);
|
||||
|
||||
data = pinos_buffer_steal (&pbuf, &size, NULL);
|
||||
data = pinos_buffer_steal_data (&pbuf, &size);
|
||||
|
||||
outbuf = gst_buffer_new_wrapped (data, size);
|
||||
ev = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
|
||||
|
|
@ -223,7 +223,7 @@ gst_pinos_socket_sink_render_pinos (GstPinosSocketSink * this, GstBuffer * buffe
|
|||
GArray *fdids = NULL;
|
||||
|
||||
gst_buffer_map (buffer, &info, GST_MAP_READ);
|
||||
pinos_buffer_init_data (&pbuf, info.data, info.size, NULL);
|
||||
pinos_buffer_init_data (&pbuf, info.data, info.size, NULL, 0);
|
||||
pinos_buffer_iter_init (&it, &pbuf);
|
||||
while (pinos_buffer_iter_next (&it)) {
|
||||
switch (pinos_buffer_iter_get_type (&it)) {
|
||||
|
|
@ -314,6 +314,7 @@ gst_pinos_socket_sink_render_other (GstPinosSocketSink * this, GstBuffer * buffe
|
|||
gpointer data;
|
||||
GSocketControlMessage *msg;
|
||||
gboolean tmpfile = TRUE;
|
||||
gint *fds, n_fds, i;
|
||||
|
||||
hdr.flags = 0;
|
||||
hdr.seq = GST_BUFFER_OFFSET (buffer);
|
||||
|
|
@ -324,9 +325,7 @@ gst_pinos_socket_sink_render_other (GstPinosSocketSink * this, GstBuffer * buffe
|
|||
pinos_buffer_builder_add_header (&builder, &hdr);
|
||||
|
||||
fdmem = gst_pinos_socket_sink_get_fd_memory (this, buffer, &tmpfile);
|
||||
p.fd_index = pinos_buffer_builder_add_fd (&builder, gst_fd_memory_get_fd (fdmem), &err);
|
||||
if (p.fd_index == -1)
|
||||
goto add_fd_failed;
|
||||
p.fd_index = pinos_buffer_builder_add_fd (&builder, gst_fd_memory_get_fd (fdmem));
|
||||
p.id = pinos_fd_manager_get_id (this->fdmanager);
|
||||
p.offset = fdmem->offset;
|
||||
p.size = fdmem->size;
|
||||
|
|
@ -336,10 +335,9 @@ gst_pinos_socket_sink_render_other (GstPinosSocketSink * this, GstBuffer * buffe
|
|||
p.id, hdr.pts, GST_BUFFER_PTS (buffer), GST_ELEMENT_CAST (this)->base_time);
|
||||
|
||||
pinos_buffer_builder_end (&builder, &pbuf);
|
||||
gst_memory_unref(fdmem);
|
||||
fdmem = NULL;
|
||||
|
||||
data = pinos_buffer_steal (&pbuf, &size, &msg);
|
||||
data = pinos_buffer_steal_data (&pbuf, &size);
|
||||
fds = pinos_buffer_steal_fds (&pbuf, &n_fds);
|
||||
|
||||
outbuf = gst_buffer_new_wrapped (data, size);
|
||||
GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (buffer);
|
||||
|
|
@ -348,6 +346,18 @@ gst_pinos_socket_sink_render_other (GstPinosSocketSink * this, GstBuffer * buffe
|
|||
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer);
|
||||
GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET_END (buffer);
|
||||
|
||||
msg = g_unix_fd_message_new ();
|
||||
for (i = 0; i < n_fds; i++) {
|
||||
if (!g_unix_fd_message_append_fd (G_UNIX_FD_MESSAGE (msg), fds[i], &err))
|
||||
goto add_fd_failed;
|
||||
}
|
||||
gst_buffer_add_net_control_message_meta (outbuf, msg);
|
||||
g_object_unref (msg);
|
||||
g_free (fds);
|
||||
|
||||
gst_memory_unref(fdmem);
|
||||
fdmem = NULL;
|
||||
|
||||
if (!tmpfile) {
|
||||
GArray *fdids;
|
||||
/* we are using the original buffer fd in the control message, we need
|
||||
|
|
@ -363,8 +373,6 @@ gst_pinos_socket_sink_render_other (GstPinosSocketSink * this, GstBuffer * buffe
|
|||
gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (outbuf),
|
||||
orig_buffer_quark, gst_buffer_ref (buffer), (GDestroyNotify) gst_buffer_unref);
|
||||
}
|
||||
gst_buffer_add_net_control_message_meta (outbuf, msg);
|
||||
g_object_unref (msg);
|
||||
|
||||
gst_burst_cache_queue_buffer (this->cache, outbuf);
|
||||
|
||||
|
|
@ -534,7 +542,7 @@ myreader_receive_buffer (GstPinosSocketSink *this, MyReader *myreader)
|
|||
pinos_buffer_builder_init (&b);
|
||||
}
|
||||
|
||||
pinos_buffer_init_data (&pbuf, mem, maxmem, NULL);
|
||||
pinos_buffer_init_data (&pbuf, mem, maxmem, NULL, 0);
|
||||
pinos_buffer_iter_init (&it, &pbuf);
|
||||
while (pinos_buffer_iter_next (&it)) {
|
||||
switch (pinos_buffer_iter_get_type (&it)) {
|
||||
|
|
@ -585,7 +593,7 @@ myreader_receive_buffer (GstPinosSocketSink *this, MyReader *myreader)
|
|||
if (have_out) {
|
||||
pinos_buffer_builder_end (&b, &pbuf);
|
||||
|
||||
data = pinos_buffer_steal (&pbuf, &size, NULL);
|
||||
data = pinos_buffer_steal_data (&pbuf, &size);
|
||||
|
||||
outbuf = gst_buffer_new_wrapped (data, size);
|
||||
ev = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue