Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libobs/util: Add buffered file serializer #10671

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/sphinx/reference-libobs-util-serializers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,44 @@ File Output Serializer Functions
.. function:: void file_output_serializer_free(struct serializer *s)

Frees the file output serializer and saves the file.

---------------------

Buffered File Output Serializer
===============================

Provides a buffered file serializer that writes data asynchronously to prevent stalls due to slow disk I/O.

Writes will only block when the buffer is full.

The buffer and chunk size are configurable with the defaults being 256 MiB and 1 MiB respectively.

.. versionadded:: 30.2

.. code:: cpp

#include <util/buffered-file-serializer.h>


Buffered File Output Serializer Functions
-----------------------------------------

.. function:: bool buffered_file_serializer_init_defaults(struct serializer *s, const char *path)

Initializes a buffered file output serializer with default buffer and chunk sizes.

:return: *true* if file created successfully, *false* otherwise

---------------------

.. function:: bool buffered_file_serializer_init(struct serializer *s, const char *path, size_t max_bufsize, size_t chunk_size)

Initialize buffered writer with specified buffer and chunk sizes. Setting either to `0` will use the default value.

:return: *true* if file created successfully, *false* otherwise

---------------------

.. function:: void buffered_file_serializer_free(struct serializer *s)

Frees the file output serializer and saves the file. Will block until I/O thread completes outstanding writes.
2 changes: 2 additions & 0 deletions libobs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ target_sources(
util/bitstream.h
util/bmem.c
util/bmem.h
util/buffered-file-serializer.c
util/buffered-file-serializer.h
util/c99defs.h
util/cf-lexer.c
util/cf-lexer.h
Expand Down
Loading
Loading