Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed. Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
If a source is created with settings, default values would not be set on
data items that already had values set. The check here was supposed to
be a not equal rather than an equal because you're not supposed to be
able to set a default value of one type on an item that already exists
but is of a different type.
This bug would make it so that if a particular setting was removed,
there would be no default value to fall back on, and it would always be
0 or NULL for all values.
It's likely this bug wasn't encountered until now because before now
there had been no reason to clear or remove settings on most things.
A file rename will automatically replace the old file if an older file
exists, and will do so automatically. Unlinking is unnecessary, and may
have a chance of preventing that move operation from being atomic.
Fixes warning introduced by d7848f3cb7 that pops up in GCC:
warning: comparison of unsigned expression < 0 is always false
[-Wtype-limits]
The proper solution was to use the 64bit integer values with the clamp,
and then convert to a 32bit unsigned integer.
Accessing objects inside obs_datas after obs_data_clear was called on the
parent obs_data causes a NULL dereference.
Reproduce with:
obs_data_t *data = obs_data_create();
obs_data_set_obj(data, "foo", NULL);
obs_data_clear(data);
obs_data_get_obj(data, "foo");
obs_data_create_from_json_file_safe: Attempts to create an obs_data
object from a file, and if that fails and a backup file exists, deletes
the old file and tries to open it again.
obs_data_save_json_safe: Saves json data to a temporary file first,
optionally backs up the target file if the file exists and backup_ext is
valid (otherwise deletes it), and then renames the temporary file to the
target file. This helps reduce the chance of json corruption on save.
Just a little helper function that allows you to create an obs_data_t
object from a json file (rather than having to manually open it each
time and then call obs_data_create_from_json on the file data)
obs_data_apply is used to apply the changes of a source object in to a
destination object. Problem with this however is that if sub-objects
are in use, it currently just copies the pointer of the sub-object,
meaning that the source and destination will both share the same
sub-object via reference. If anything modifies that sub-object data,
it'll modify it for both objects, which was not intended.
Instead of copying the object pointer, create a new copy and then
recursively repeat the process to ensure the data is always completely
separate.
This allows for easier comparison between two obs_data_t and it will make
const char *json1 = obs_data_get_json(data);
obs_data_t *data_ = obs_data_create_from_json(json1);
const char *json2 = obs_data_get_json(data_);
produce the same string in json1 and json2
Typedef pointers are unsafe. If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data. I admit this was a fundamental mistake that must
be corrected.
All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.
This does not break ABI though, which is pretty nice.
It would try to move data from the old pointer even if the pointer was
changed via realloc, which would cause it to copy data from freed
memory. Instead, just get the position of the data and call memmove to
move it up.
On release of obs_data, if the default/autoselect values pointed toward
a sub-object or a sub-array, it would look up the data for the regular
user value. (Palana must have forgot to change these functions around
when adding the default/autoselect functionality)
For the sake of consistency, renamed these two functions to include
_value at the end so they are consistent.
Renamed: To:
-------------------------------------------------------
obs_data_has_default obs_data_has_default_value
obs_data_has_autoselect obs_data_has_autoselect_value
obs_data_item_has_default obs_data_item_has_default_value
obs_data_item_has_autoselect obs_data_item_has_autoselect_value
These are meant to reflect auto-detection configuration changes that
should not be written to the config, for example, frame rate changes
for a camera where the (user-/config-file-)configured frame rate isn't
available but a similar frame rate can be automatically chosen
Default values are now permanently stored in the obs_data_items and
can be accessed via the new get_default functions
Also default values are no longer serialized to JSON to ease transition
to new default values
Microsoft's garbage compiler just doesn't even.. read the names of
enums. It sees an enum and goes "durr, that's an int" without even
properly evaluating it. Just total garbage, as per usual.
Also, rename atomic functions to be consistent with the rest of the
platform/threading functions, and move atomic functions to threading*
files rather than platform* files
- Split input and output audio captures so that they're different
sources. This allows easier handling and enumeration of audio
devices without having to do some sort of string processing.
This way the user interface code can handle this a bit more easily,
and so that it doesn't confuse users either. This should be done for
all audio capture sources for all operating systems. You don't have
to duplicate any code, you just need to create input/output wrapper
functions to designate the audio as input or output before creation.
- Make it detect soundflower and wavtap devices as mac "output" devices
(even though they're actually input) for the mac output capture, and
make it so that users can select a default output capture and
automatically use soundflower or wavtap.
I'm not entirely happy about having to do this, but because mac is
designed this way, this is really the only way to handle it that
makes it easier for users and UI code to deal with.
Note that soundflower and wavtap are still also designated as input
devices, so will still show up in input device enumeration.
- Remove pragma messages because they were kind polluting the other
compiler messages and just getting in the way. In the future we can
just do a grep for TODO to find them.
- Redo list property again, this time using a safer internal array,
rather than requiring sketchy array inputs. Having functions handle
everything behind the scenes is much safer.
- Remove the reference counter debug log code, as it was included
unintentionally in a commit.
Make it so obs_data settings input in to *_update are applied to the
existing settings rather than fully replace the existing settings. That
way you can update with only certain specific settings, leaving other
settings untouched. Of course if you're already using the original
settings pointer in the first place then you've already done that, so
it'll just ignore it because you've already applied them.
There were a *lot* of warnings, managed to remove most of them.
Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
- Add 'set_default' functions to obs-data.*. These functions ensure
that a paramter exists and that the parameter is of a specific type.
If not, it will create or overwrite the value with the default setting
instead.
These functions are meant to be explicitly called before using any of
the 'get' functions. The reason why it was designed this way is to
encourage defaults to be set in a single place/function.
For example, ideal usage is to create one function for your data,
"set_my_defaults(obs_data_t data)", set all the default values within
that function, and then call that function on create/update, that way
all defaults are centralized to a single place.
- Ensure that data passed to sources/encoders/outputs/etc is always
valid, and not a null value.
- While I'm remembering, fix a few defaults of the main program config
file data.