Commit Graph

197 Commits (1effaca2261615fc607814ab4189ff1f20ad714f)

Author SHA1 Message Date
jp9000 d78d0072a0 libobs/util: Add functions to inhibit sleep
These fucntions prevent the computer from going to sleep, hibernating,
or starting up a screen saver.

On linux, it will also attempt to use DBus to prevent gnome/kde/etc
sleep, but it's not necessarily required in order to compile the
library.  Otherwise, it will simply call "xdg-screensaver reset" once
every 30 seconds to reset the screensaver timer.
2015-09-12 22:08:05 -07:00
Palana b2714fa353 libobs/util: Restore original code point
This was broken in cd222f8ce0 which had a
horrible commit message that makes replicating the issue impossible if
there weren't others who reported similar visual studio issues when
using a Japanese locale
2015-09-08 11:36:19 +02:00
jp9000 46101b6d5b libobs: Fix various string format warnings
GCC 5.1+ seems to be more aggressive about spotting potentially
non-matching printf format specifiers.
2015-08-30 23:41:09 -07:00
jp9000 f29431d8db libobs/util: Add config_save_safe function
This safely saves a configuration file, optionally with a backup.
2015-08-21 17:42:24 -07:00
jp9000 3a77ac3516 libobs/util: Add os_quick_write_utf8_file_safe
This helper function saves to a temporary file first, (optionally) backs
up the original file, then renames the temporary file to the actual file
name.  This helps reduce the chance of file corruption under various
circumstances (such as shutdown or crash while the file is being written
to disk).
2015-08-21 17:31:23 -07:00
jp9000 cd222f8ce0 libobs/util: Fix character encoding issue
Manually specifies the UTF-8 character codes used by the file rather
than relying on the compiler to determine what the codes are manually.
I was getting compile errors due to the fact that my current code page
is not at the default code page; so visual c++ tried to use my current
code page rather than UTF-8 and it would cause an error on the file.
2015-08-19 11:56:17 -07:00
Palana 13b2469d61 libobs/util: Extend profiler csv export data
The id and parent_id fields should now allow better recovery of the
actual call trees, though they aren't compatible between different data
dumps in a single profiler session anymore; for that reason the new
fields name_id and parent_name_id are introduced, they hold the old id
and parent_id values respectively
2015-08-13 11:57:42 +02:00
Palana 91ea844333 libobs/util: Add compressed profiler snapshot saving 2015-08-12 15:30:30 +02:00
Palana d9cf5c668b libobs/util: Add profiler 2015-08-12 15:30:28 +02:00
jp9000 0fb79a4733 libobs: Use get_win_ver (not GetVersionEx) 2015-08-01 14:51:22 -07:00
jp9000 ef332ab8b6 libobs: Add function to get the windows version
Microsoft basically deprecated GetVersion/GetVersionEx, so now you have
to query the file version of kernel32.dll in order to get the actual
windows version.  Because of the steps involved in getting the windows
version are fairly complicated, this is an exported libobs helper
function that can be used to get the windows version if needed.
(Microsoft does have its own set of helper functions for this but the
API feels a bit..  awkward, and you can't actually get the real windows
version with them)
2015-08-01 14:51:21 -07:00
Palana 95e19cb7ba libobs/util: Reduce allocations in dstr_vcatf 2015-07-19 06:30:35 +02:00
Palana 14b27a4cc7 libobs/util: Add format string diagnostics for dstr_(cat|print)f 2015-07-19 06:30:34 +02:00
jp9000 d7d44a92ff libobs/util: Load win. module deps from same dir
Certain plugins/modules that are loaded on windows may be dependent on
libraries that are located in the same directory as the module in
question.  This makes is so that LoadLibrary will also search for
dependent libraries for that module in the module's directory.
2015-07-16 13:33:34 -07:00
jp9000 5c0f4546ea libobs/util: Add functions to get/set the cwd
Adds functions to get or set the current working directory.
2015-07-16 01:32:16 -07:00
jp9000 5d33c777c2 libobs/util: Add macro to specify arch. bits 2015-07-16 01:32:13 -07:00
Palana 231dfbd975 libobs/util: Make os_sleepto_ns more accurate on windows 2015-07-09 02:42:38 +02:00
jp9000 847b3df322 libobs/util: Add os_mkdirs
Recursively creates a directory structure if one or more directories in
the path structure don't exist
2015-07-08 10:00:33 -07:00
jp9000 bf37258469 libobs/util: Allow ability to get base config path
This allows you to for example, get your base home directory or base
%appdata% directory.
2015-07-08 09:21:18 -07:00
Carl Fürstenberg ba02e065fe libobs: Add XDG config directory support
Adding XDG Base Directory Specification support for config dir

http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

Closes jp9000/obs-studio#348
2015-07-08 09:10:53 -07:00
Carl Fürstenberg cf8c096f2e libobs: Set sane write permissions on directories
Prevent setting global writable permissions on newly created
directories.
2015-07-08 08:11:14 -07:00
lemmi 0cdc53c0f0 libobs/util: Make pthread_setname_np glibc only
Fixes an issue with certain distributions that don't use glibc
(particularly musl)

Closes jp9000/obs-studio#441
2015-07-06 19:45:22 -07:00
jp9000 6bf2be407b libobs/util: Add config_remove_value function 2015-07-03 09:57:51 -07:00
jp9000 5bcaa7b590 libobs/util: Do not add empty config file values
This allows config file values to defer to their defaults instead of
being null.
2015-07-02 17:18:43 -07:00
jp9000 625ecda3dc libobs/util: Add ConfigFile::Swap function
Allows swapping the internal data of two ConfigFile objects.
2015-07-02 17:18:34 -07:00
jp9000 09b78b12de libobs/util: Add os_copyfile function
Adds a function to copy a file.  On unix-based systems, manually copies
the data with fopen/fread/fwrite/fclose.
2015-07-02 17:18:27 -07:00
jp9000 216baaf799 libobs/util: Add os_rmdir function
Adds a function to remove a directory.
2015-07-02 17:18:23 -07:00
jp9000 50f4793c99 libobs/util: Add os_rename function
Allows moving/renaming of files.
2015-07-02 17:18:15 -07:00
jp9000 6587b18d59 libobs: Add return code to process pipe destroy 2015-06-21 22:34:44 -07:00
jp9000 43956388b2 libobs: Fix bug with process piping
The size parameter is the size of the elements, not the size of the
data.  The size parameter should be 1, and the elements should be the
number of bytes.

The reason why I'm making this change is because the fread/fwrite would
fail when the parameters were swapped.
2015-06-21 22:34:43 -07:00
Palana a907d74903 util: Add os_atomic_compare_swap_long 2015-05-07 01:57:14 +02:00
jp9000 bf1ca59965 util: Add dstr functions to make upper/lower 2015-05-07 01:57:14 +02:00
Palana ae19eec2c6 util: Improve handling of config values with linebreaks 2015-05-07 01:55:12 +02:00
Jim ee284a56ac Merge pull request #424 from fryshorts/bsd-build-fixes
BSD build fixes
2015-05-05 04:46:16 -07:00
fryshorts d998c16724 libobs: Remove unused include
Remove unused include as it is not available on FreeBSD and was
therefore causing a build error.
2015-05-04 21:08:17 +02:00
Kris Moore 5803d921ae libobs: Fix thread naming on FreeBSD
Add the relevant header file needed on FreeBSD and utilize yet another
ifdef to call pthread_set_name_np as the function name differs from
those on the other platforms.
2015-05-04 21:08:17 +02:00
GoaLitiuM 2ab4c430e0 libobs: Define snprintf only for Visual Studios prior VS2015
This change is purely cosmetic one. _snprintf is still defined in 2015,
but Microsoft may change this in the future.
2015-05-04 19:33:55 +03:00
Palana 17ff1d94e6 util: Calculate buffer size for dstr_vprintf (C99) 2015-04-23 23:49:06 +02:00
jp9000 d44d3b1f0a libobs: Use locale-independent double conversion
Prevents issues on specific locales, especially where decimal points are
represented by commas rather than periods.
2015-03-22 19:18:07 -07:00
jp9000 001bfb4a6d libobs: Use nullptr instead of NULL 2015-03-21 16:34:46 -07:00
jp9000 644ac130f8 libobs: Only allow ComQIPtr on windows
ComPtr can be used for things like the DeckLink API, but ComQIPtr has
windows-specific compiler features, so can't be used outside of windows.
2015-03-21 16:34:46 -07:00
jp9000 a05ed355f5 libobs: Fix 64bit -> 32bit conversion warnings 2015-02-10 19:31:25 -08:00
jp9000 e26dec916e libobs: Use windows wide <-> UTF8 conversion
If on windows, use the windows UTF conversion functions due to the fact
that the existing utf code is meant for 32bit wide characters, while the
windows conversion functions will properly handle 16bit wide characters.
2015-02-09 03:49:16 -08:00
jp9000 0c30dca526 libobs: Update to latest version of ComPtr.hpp 2015-02-09 03:49:15 -08:00
jp9000 5dfecab15c Fix windows printf format warnings (from mingw) 2015-02-09 03:49:14 -08:00
jp9000 0c1d121ff2 Remove various unused variables
Unused variables detected by mingw
2015-02-09 03:49:13 -08:00
martell a83e74dc1c Disable SEH for mingw-w64
The SEH implementation is not quite working properly in mingw-w64, so
disable it for the time being.
2015-02-09 03:47:27 -08:00
martell 23d39ea5a8 libobs: threading-windows mingw-w64 support
Enable support for mingw-w64 in threading-windows.c
2015-02-09 03:41:44 -08:00
martell 079d15d518 libobs: mingw-w64 threading-posix
Enable support for mingw-w64 in threading-posix.c
2015-02-09 03:41:43 -08:00
jp9000 82320a9ca7 (API Change) Make os_get_config_path safer to use
Changed:
  char *os_get_config_path(const char *name);

To:
  int os_get_config_path(char *dst, size_t size, const char *name);

Also added:
  char *os_get_config_path_ptr(const char *name);

I don't like this function returning an allocation by default.
Similarly to what was done with the wide character conversion functions,
this function now operates on an array argument, and if you really want
to just get a pointer for convenience, you use the *_ptr version of the
function that clearly indicates that it's returning an allocation.
2015-01-15 23:44:38 -08:00