mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
Add GST_BUFFER_FLAG_SYNC_AFTER flag, and implement in filesink.
Makes it possible to get filesink to fsync() after rendering a buffer.
This commit is contained in:
parent
499b8d841e
commit
ade4a83e63
2 changed files with 26 additions and 0 deletions
|
@ -194,6 +194,9 @@ typedef struct _GstBufferPool GstBufferPool;
|
||||||
* @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently.
|
* @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently.
|
||||||
* @GST_BUFFER_FLAG_TAG_MEMORY: this flag is set when memory of the buffer
|
* @GST_BUFFER_FLAG_TAG_MEMORY: this flag is set when memory of the buffer
|
||||||
* is added/removed
|
* is added/removed
|
||||||
|
* @GST_BUFFER_FLAG_SYNC_AFTER: Elements which write to disk or permanent
|
||||||
|
* storage should ensure the data is synced after
|
||||||
|
* writing the contents of this buffer. (Since: 1.6)
|
||||||
* @GST_BUFFER_FLAG_LAST: additional media specific flags can be added starting from
|
* @GST_BUFFER_FLAG_LAST: additional media specific flags can be added starting from
|
||||||
* this flag.
|
* this flag.
|
||||||
*
|
*
|
||||||
|
@ -211,6 +214,7 @@ typedef enum {
|
||||||
GST_BUFFER_FLAG_DROPPABLE = (GST_MINI_OBJECT_FLAG_LAST << 8),
|
GST_BUFFER_FLAG_DROPPABLE = (GST_MINI_OBJECT_FLAG_LAST << 8),
|
||||||
GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 9),
|
GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 9),
|
||||||
GST_BUFFER_FLAG_TAG_MEMORY = (GST_MINI_OBJECT_FLAG_LAST << 10),
|
GST_BUFFER_FLAG_TAG_MEMORY = (GST_MINI_OBJECT_FLAG_LAST << 10),
|
||||||
|
GST_BUFFER_FLAG_SYNC_AFTER = (GST_MINI_OBJECT_FLAG_LAST << 11),
|
||||||
|
|
||||||
GST_BUFFER_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 16)
|
GST_BUFFER_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 16)
|
||||||
} GstBufferFlags;
|
} GstBufferFlags;
|
||||||
|
|
|
@ -673,6 +673,7 @@ gst_file_sink_render_list (GstBaseSink * bsink, GstBufferList * buffer_list)
|
||||||
guint8 *mem_nums;
|
guint8 *mem_nums;
|
||||||
guint total_mems;
|
guint total_mems;
|
||||||
guint i, num_buffers;
|
guint i, num_buffers;
|
||||||
|
gboolean sync_after = FALSE;
|
||||||
|
|
||||||
sink = GST_FILE_SINK_CAST (bsink);
|
sink = GST_FILE_SINK_CAST (bsink);
|
||||||
|
|
||||||
|
@ -687,12 +688,23 @@ gst_file_sink_render_list (GstBaseSink * bsink, GstBufferList * buffer_list)
|
||||||
buffers[i] = gst_buffer_list_get (buffer_list, i);
|
buffers[i] = gst_buffer_list_get (buffer_list, i);
|
||||||
mem_nums[i] = gst_buffer_n_memory (buffers[i]);
|
mem_nums[i] = gst_buffer_n_memory (buffers[i]);
|
||||||
total_mems += mem_nums[i];
|
total_mems += mem_nums[i];
|
||||||
|
if (GST_BUFFER_FLAG_IS_SET (buffers[i], GST_BUFFER_FLAG_SYNC_AFTER))
|
||||||
|
sync_after = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
flow =
|
flow =
|
||||||
gst_file_sink_render_buffers (sink, buffers, num_buffers, mem_nums,
|
gst_file_sink_render_buffers (sink, buffers, num_buffers, mem_nums,
|
||||||
total_mems);
|
total_mems);
|
||||||
|
|
||||||
|
if (flow == GST_FLOW_OK && sync_after) {
|
||||||
|
if (fflush (sink->file) || fsync (fileno (sink->file))) {
|
||||||
|
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
|
||||||
|
(_("Error while writing to file \"%s\"."), sink->filename),
|
||||||
|
("%s", g_strerror (errno)));
|
||||||
|
flow = GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
|
|
||||||
no_data:
|
no_data:
|
||||||
|
@ -718,6 +730,16 @@ gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
else
|
else
|
||||||
flow = GST_FLOW_OK;
|
flow = GST_FLOW_OK;
|
||||||
|
|
||||||
|
if (flow == GST_FLOW_OK &&
|
||||||
|
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_SYNC_AFTER)) {
|
||||||
|
if (fflush (filesink->file) || fsync (fileno (filesink->file))) {
|
||||||
|
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
|
||||||
|
(_("Error while writing to file \"%s\"."), filesink->filename),
|
||||||
|
("%s", g_strerror (errno)));
|
||||||
|
flow = GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue