Commit graph

162 commits

Author SHA1 Message Date
Sebastian Dröge
5bdbde32da plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-04 15:49:24 -04:00
Mathieu Duponchelle
710ce84d0c filesink: port over unlock code from fdsink
See also: 5216322d39

The previous code was causing "random" flushing returns
in scenarios with intensive state changes such as within
a buffering pipeline.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/476>
2020-05-20 14:10:14 +00:00
Sebastian Dröge
dcb2be3282 filesink: Add a new full buffer mode to filesink
Previously the default and full modes were the same. Now the default
mode is like before: it accumulates all buffers in a buffer list until
the threshold is reached and then writes them all out, potentially in
multiple writes.

The new full mode works by always copying memory to a single memory area
and writing everything out with a single write once the threshold is
reached.
2020-03-26 11:31:03 +00:00
Sebastian Dröge
c15f1b2bec fdsink/filesink: Refactor writev() code to prevent stack overflows
If buffer lists with too many buffers would be written before, a stack
overflow would happen because of memory linear with the number of
GstMemory would be allocated on the stack. This could happen for example
when filesink is configured with a very big buffer size.

Instead now move the buffer and buffer list writing into the helper
functions and at most write IOV_MAX memories at once. Anything bigger
than that wouldn't be passed to writev() anyway and written differently
in the previous code, so this also potentially speeds up writing for
these cases.

For example the following pipeline would crash with a stackoverflow:
gst-launch-1.0 audiotestsrc ! filesink buffer-size=1073741824 location=/dev/null
2020-03-26 11:31:03 +00:00
Peter Seiderer
afa802e4aa filesink: handle fsync interrupted by signal (EINTR)
According to [1] EINTR is a possible errno for fsync() and it happens in
reality on linux (video writing via splitmuxsink with robust muxing enabled
on a cifs mounted network share), so handle it as all other EINTR
(do/while(errno == EINTR)).

Fixes:

  GError.message: Error while writing to file "vidoe_001.mp4". GError.domain: 2372 GError.code: 10 from: FileSink debug: gstfilesink.c(849): gst_file_sink_render (): /GstPipeline:Pipeline/GstSplitMuxSink:SplitMuxSink/GstBin:QueueBin/GstFileSink:FileSink: Interrupted system call

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2019-12-12 20:49:36 +01:00
Sebastian Dröge
eec9bd8db3 filesink: Implement workaround for some (network) filesystems that spuriously return EACCES on write
This seems to happen when another client is accessing the file at the
same time, and retrying after a short amount of time solves it.

Sometimes partial data is written at that point already but we have no
idea how much it is, or if what was written is correct (it sometimes
isn't) so we always first seek back to the current position and repeat
the whole failed write.

It happens at least on Linux and macOS on SMB/CIFS and NFS file systems.

Between write attempts that failed with EACCES we wait 10ms, and after
enough consecutive tries that failed with EACCES we simply time out.

In theory a valid EACCES for files to which we simply have no access
should've happened already during the call to open(), except for NFS
(see open(2)).

This can be enabled with the new max-transient-error-timeout property, and
a new o-sync boolean property was added to open the file in O_SYNC mode
as without that it's not guaranteed that we get EACCES for the actual
writev() call that failed but might only get it at a later time.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/305
2019-05-16 14:15:02 +03:00
Nicolas Dufresne
c81b2f6207 filesink: Fix wrong printf format
We add a guint64 and a guint, the result is a guint64. On 64bit
architecture, this is the same, but on 32bit architecture, it's not.

https://bugzilla.gnome.org/show_bug.cgi?id=797127
2018-09-11 21:33:51 -04:00
Sebastian Dröge
b324e4b802 filesink: Flush buffers before directly writing out buffers with the SYNC_AFTER flag
Otherwise we write out the SYNC_AFTER buffer immediately, and the
previously queued up buffers afterwards which then breaks the order of
data.

Also add various debug output.
2018-08-28 14:23:32 +03:00
Sebastian Dröge
035045c981 filesink: Consider the current buffer size when checking the current position 2018-08-17 17:26:17 +03:00
Sebastian Dröge
cbcad53b45 filesink: Reset the current buffer size to NULL and clear the buffer on close and FLUSH_STOP 2018-08-17 17:26:17 +03:00
Sebastian Dröge
6b4fc62b7b filesink: Implement buffering internally
We use writev() so every call ends up going to the kernel but for small
buffers we generally would prefer to do as few write calls as possible.

https://bugzilla.gnome.org/show_bug.cgi?id=794173
2018-08-16 17:01:07 +03:00
Sebastian Dröge
e975e0cae8 filesink: Remove buffer, deprecate line-buffer mode and don't use fflush()
fflush() has no effect because we use writev() directly, so fsync()
should be used instead which is actually flushing the kernel-side
buffers.

As a next step, a non-line-buffered buffering mode is to be added.

https://bugzilla.gnome.org/show_bug.cgi?id=794173
2018-08-14 13:56:08 +03:00
Matthew Waters
5a5a548b09 plugins: Don't force 64-bit file/seek functions variants on android
Most functions are automatically chosen from the _FILE_OFFSET_BITS
define, the remaining one (fstat) is only available on API >= 21 so
check for that
2018-03-02 18:25:21 +11:00
Thibault Saunier
a87b4551a6 Port gtk-doc comments to their equivalent markdown syntax
Modernizing our documentation and preparing a possible move to hotdoc.
This commits also adds missing @title metadatas to all SECTIONs
2017-01-27 16:36:38 -03:00
Olivier Crête
5216322d39 fdsink: Block in preroll_wait on unlock
The correct behaviour of anything stuck in the ->render() function
between ->unlock() and ->unlock_stop() is to call
gst_base_sink_wait_preroll() and only return an error if this returns an
error, otherwise, it must continue where it left off!

https://bugzilla.gnome.org/show_bug.cgi?id=773912
2016-11-23 11:58:43 -05:00
Tim-Philipp Müller
cf0680017e elements: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=762778
2016-02-28 13:10:07 +00:00
Reynaldo H. Verdejo Pinochet
add4526314 filesink: enable large file support on Android
https://bugzilla.gnome.org/show_bug.cgi?id=758980
2015-12-09 14:15:26 -08:00
Reynaldo H. Verdejo Pinochet
c0d2c1e793 filesink: indentation fixes 2015-12-09 14:15:26 -08:00
Anton Bondarenko
f468eb7db0 filesink: continue element cleanup even if fclose fails
Sometimes filesink cleanup during stop may fail due to fclose error.
In this case object left partial cleanup with no file opened
but still holding old file descriptor.

It's not possible to change location property in a such state,
so next start will cause old file overwrite if 'append' does not set.

According to man page and POSIX standard about fclose behavior(extract):
------------------------------------------------------------------------
The fclose() function shall cause the stream pointed to by stream
to be flushed and the associated file to be closed.
...
Whether or not the call succeeds, the stream shall be disassociated
from the file and any buffer set by the setbuf() or setvbuf()
function shall be disassociated from the stream.
...
The fclose() function shall perform the equivalent of a close()
on the file descriptor that is associated with the stream
pointed to by stream.

After the call to fclose(), any use of stream results
in undefined behavior.
------------------------------------------------------------------------

So file is in 'closed' state no matter if fclose succeed or not.
And cleanup could be continued.

https://bugzilla.gnome.org/show_bug.cgi?id=757596
2015-11-05 10:17:41 +01:00
Stefan Sauer
3ee4d608c2 filesink: use GST_INFO_OBJECT for more detail
Helps to distiguish multiple filesinks.
2015-08-04 00:12:57 +02:00
Nicolas Dufresne
25fa87a9e4 doc/filesink: Add BufferMode enumeration
This is purely for documentation purpose. This way the values will
show up in the HTML documentation.
2015-07-28 16:57:36 -04:00
Edward Hervey
084f6859ea filesink: Fix fsync/_commit usage
_MSC_VER will only be defined when building *on* windows and not just
*for* windows. Instead, use the G_OS_WIN32 define
2015-06-09 11:03:28 +02:00
Jan Schmidt
ef2a4083af filesink: Fix Windows build by using _commit instead of fsync. 2015-06-09 00:52:34 +10:00
Jan Schmidt
ade4a83e63 Add GST_BUFFER_FLAG_SYNC_AFTER flag, and implement in filesink.
Makes it possible to get filesink to fsync() after rendering
a buffer.
2015-06-08 19:13:18 +10:00
Tim-Philipp Müller
1a9a3c7ef9 docs: gst-launch -> gst-launch-1.0 in example pipelines
And some small example pipeline fix-ups.
2015-05-10 11:35:50 +01:00
Tim-Philipp Müller
5b50f39015 filesink: use writev() in ::render() to write out memories without merging them 2014-11-30 14:40:46 +00:00
Tim-Philipp Müller
5a4fb5c314 filesink: implement ::render_list() function that uses writev() 2014-11-30 14:40:46 +00:00
Alessandro Decina
a2bc789de6 filesink: please gcc (avoid a warn_unused_result warning) 2013-08-27 09:31:22 +02:00
Alessandro Decina
924acf5e92 filesink: flush (discard data) on FLUSH_STOP
Reset the write position to 0 and truncate the file on FLUSH_STOP.
2013-08-27 08:00:09 +02:00
Tim-Philipp Müller
666c8c11c6 Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 20:44:48 +00:00
Mark Nauwelaerts
947635d893 filesink: fix build on Cygwin
... where __fbufsize is not available
2012-09-12 17:16:41 +02:00
Edward Hervey
d3ffa82639 Remove 0.10-related documentation and "Since" markers 2012-07-10 12:03:27 +02:00
Tim-Philipp Müller
a63829b4ff plugins: use new gst_element_class_set_static_metadata() 2012-04-09 13:05:07 +01:00
Tim-Philipp Müller
1fbcc71dbd Merge remote-tracking branch 'origin/master' into 0.11
Conflicts:
	NEWS
	RELEASE
	configure.ac
	docs/plugins/gstreamer-plugins.hierarchy
	docs/plugins/inspect/plugin-coreelements.xml
	libs/gst/base/gstcollectpads.c
	libs/gst/base/gstcollectpads2.c
	plugins/elements/gstfdsink.c
	win32/common/config.h
	win32/common/gstenumtypes.c
	win32/common/gstversion.h
2012-02-27 00:08:39 +00:00
Tim-Philipp Müller
82a9544385 filesink: implement SEEKING query
We may or may not do seeking, depends on the
output file/device really, it doesn't have to
be a file after all.
2012-02-25 15:07:43 +00:00
Wim Taymans
a521252845 Add new GstMapInfo
Use a structure to hold info about the mapping. The application then keeps track
of this state and we can use it to unmap the memory again later.
2012-01-25 11:54:23 +01:00
Wim Taymans
0e38f0dad0 basesink: clean up event handling
Add new wait_eos vmethod to wait for the eos timeout before posting the EOS
message on the bus.
Add default event handler. Move the default event actions in there. Call the
event vmethod from the pad event handler. Subclasses are now supposed to chain
up to the parent event handler or unref the event and do their own thing.
Avoid passing unused parameters to functions.
2011-12-02 22:20:08 +01:00
Tim-Philipp Müller
f598856765 plugins, tools: update for get_protocols() return value change 2011-11-13 23:25:23 +00:00
Tim-Philipp Müller
dfa9bb8088 elements: update fd + file sources and sinks for GstUriHandler changes 2011-11-13 18:05:24 +00:00
Nicolas Dufresne
f0219b327d basesink: make it easy to override the pad query
Add a vmethod to handle the pad query.
Install a default handler for the pad query.
Use the new query function in filesink
2011-09-08 14:46:59 +02:00
Josep Torra
178bdccb76 Fix and clarify debug statements
Fixes build on MacOSX

Signed-off-by: Edward Hervey <edward.hervey@collabora.co.uk>
2011-08-10 11:01:58 +02:00
Wim Taymans
32841d258d basesink: make it easy to override the pad query
Add a vmethod to handle the pad query.
Install a default handler for the pad query.
Add a vmethod to setup the allocation properties.
Use the new query function in filesink
2011-07-26 12:21:38 +02:00
Wim Taymans
b322a401c7 uri: remove some _full variants 2011-06-22 16:38:04 +02:00
Sebastian Dröge
a46c9c2a62 event: Make SEGMENT event parsing API more consistent with the others 2011-05-18 16:56:43 +02:00
Sebastian Dröge
3d2127f865 Revert "query: allow _make_writable on query handlers"
This reverts commit cf4fbc005c.

This change did not improve the situation for bindings because
queries are usually created, then directly passed to a function
and not stored elsewhere, and the writability problem with
miniobjects usually happens with buffers or caps instead.
2011-05-17 11:21:41 +02:00
Wim Taymans
bdbc069348 Rework GstSegment handling
Improve GstSegment, rename some fields. The idea is to have the GstSegment
structure represent the timing structure of the buffers as they are generated by
the source or demuxer element.
gst_segment_set_seek() -> gst_segment_do_seek()
Rename the NEWSEGMENT event to SEGMENT.
Make parsing of the SEGMENT event into a GstSegment structure.
Pass a GstSegment structure when making a new SEGMENT event. This allows us to
pass the timing info directly to the next element. No accumulation is needed in
the receiving element, all the info is inside the element.
Remove gst_segment_set_newsegment(): This function as used to accumulate
segments received from upstream, which is now not needed anymore because the
segment event contains the complete timing information.
2011-05-16 11:37:52 +02:00
Wim Taymans
cf4fbc005c query: allow _make_writable on query handlers
Pass a GstQuery ** to the query handlers so that they can make the query
writable before using a setter on it.
Port code to new API.
2011-05-10 18:36:33 +02:00
Wim Taymans
c07b57fc05 segment: remove _full version
Rename the _full versions of the functions to the normal function names.
2011-05-09 17:51:07 +02:00
Sebastian Dröge
5020738a6d elements: Use G_DEFINE_TYPE instead of GST_BOILERPLATE 2011-04-19 11:45:36 +02:00
Wim Taymans
d82c8bd2af memory: port code to new buffer data API 2011-03-28 20:08:45 +02:00