0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
Commit Graph

313 Commits

Author SHA1 Message Date
jp9000
526d390adb libobs: Reduce unnecessary logging (info -> debug)
(Note: This commit also modifies coreaudio-encoder, win-capture, and
win-mf modules)

This reduces logging to the user's log file.  Most of the things
specified are not useful for examining log files, and make reading log
files more painful.

The things that are useful to log should be up to the front-end to
implement.  The core and core plugins should have minimal mandatory
logging.
2016-08-05 18:59:32 -07:00
jp9000
a9caa99c5b libobs: Fix source active/show incrementing/decrementing
The active_refs and show_refs variable would only increment/decrement
their children if their values were 1 and 0, which means that in the
case of scenes within scenes, sub-sources of scenes within scenes would
end up having the wrong ref values.
2016-07-02 14:13:17 -07:00
jp9000
643823505c libobs: Fix obs_source_duplicate on scenes
Scenes have special duplication handling, so make it internally call
obs_scene_duplicate instead.
2016-07-01 15:20:27 -07:00
jp9000
5cc59256e7 libobs: Fix 'set but unused' warnings 2016-06-22 14:10:43 -07:00
jp9000
b5df4537a9 libobs: Fix null pointer dereference w/ null private sources 2016-06-11 12:27:05 -07:00
jp9000
fb1ff173f9 libobs: Fix crash with 4:2:0 async source resolutions
When using GPU conversion for 4:2:0 frames on async video sources, it
would create a texture bigger than necessary and try to copy too much
data from the frame, resulting in a crash.
2016-06-06 23:46:56 -07:00
jp9000
cb9ce7547d libobs: Fix bug activating/showing transitions in a tree
When a transition is a sub-source of another source, it would not call
the transition's active source enum function, meaning that any sources
the transition had would not increment their active/showing refs (it
would only be called when activating the transition directly before).
That would result in negative/invalid active/showing refs on its
sub-sources, causing them to become permanently active/inactive and/or
permanently showing/hidden.
2016-05-26 08:13:21 -07:00
jp9000
2741624fbe libobs: Log when a filter is added/removed from a source 2016-05-04 20:29:26 -07:00
jp9000
ff99ba7818 libobs: Allow filter processing function to return false
(Note: this commit also modifies the obs-filters and test-input modules)

Changes the obs_source_process_filter_begin return type so that it
returns true/false to indicate that filter processing should or should
not continue (for example if the filter is bypassed or if there's some
other sort of issue that causes the filtering to fail)
2016-04-22 10:18:12 -07:00
Richard Stanway
bc231eda75
libobs: Fix a race condition when initializing audio sources
The source shouldn't be inserted into obs->data.first_audio_source until it's
fully initialized, or other threads will access source->control and
dereference an uninitialized pointer.
2016-04-13 18:39:24 +02:00
Richard Stanway
a73b09c74e
libobs: Remove various dead code found by static analysis
Detected by Coverity Scan (CID 92178, 92171)
2016-04-13 02:43:11 +02:00
jp9000
2274b57926 libobs: Mark filters as private (band-aid fix)
This patch fixes a specific crash where if the user named a filter the
same name as an input source that already existed in the system, scene
item loading code could find the filter with the same name instead of
the source, and mistakenly use it as the scene item's source directly.
This would cause a crash when trying to render that filter as a regular
source.

Marking filters as private is a temporary and simple workaround to the
solution.  Filters are currently not meant to be found via the main
enumeration/search functions, which is a design flaw (lack of
consistency).  In future major API revisions of libobs, filters should
be reworked to act as sources, with the sources they filter as
sub-sources ideally.

Additionally, the concept of "private context objects" and "primary
lists of context objects" in the back-end should probably also be
removed, allowing the font-end (or optional separate API layers) to
control all primary lists of obs context objects.  These minor issues
that occur ultimately stem from API design flaws which need to be
corrected.
2016-04-09 18:12:50 -07:00
jp9000
f23974ab64 libobs: Fix possible crash with filters
This crash happened when a filter was mistakenly used as a regular
source due to an unrelated bug in filter code and scene loading code.
The filter and the source it belongs to both had the same names, and the
source loading code found the filter and mistakenly used it as the
source instead of the actual source with the same name.
2016-04-09 18:12:49 -07:00
jpk
c3629eacb5 libobs: Add Y800 color format support
(Note: Also modified the obs-ffmpeg plugin module)

Allows the ability for frame data to pass 8-bit grayscale images (Y800
color format).

Closes jp9000/obs-studio#515
2016-03-24 03:33:35 -07:00
jp9000
07c644c581 libobs: Add deinterlacing API functions
Adds deinterlacing API functions.  Both standard and 2x variants are
supported.  Deinterlacing is set via obs_source_set_deinterlace_mode and
obs_source_set_deinterlace_field_order.

This was implemented in to the core itself because deinterlacing should
happen before effect filters are processed, but after async filters are
processed.  If this were added as a filter, there is the possibility
that a different filter is processed before deinterlacing, which could
mess with the result.  It was also a bit easier to implement this way
due to the fact that that deinterlacing may need to have access to the
previous async frame.

Effects were split in to separate files to reduce load time (especially
for yadif shaders which take a significant amount of time to compile).
2016-03-21 21:22:32 -07:00
jp9000
11d9a8f3e4 libobs: Rename async_convert_texrender to async_texrender 2016-03-21 21:22:31 -07:00
jp9000
9a86a10f91 libobs: Update async textures via function parameters
Instead of just updating the async texture variables directly in the
source, allow the ability to pass the async texture variables via
function parameters to allow the ability to parse more than one frame to
more than one texture.

This code is primarily intended to be used to upload/convert the
"previous" async frame for the deinterlacer (if necessary).
2016-03-21 21:22:31 -07:00
jp9000
12cdaec1a7 libobs: Move frame-related functions to obs-internal.h
Allows access in other source files (particularly the deinterlacer)
2016-03-21 21:22:30 -07:00
John Bradley
310f390e1e libobs: Allow filters to specify technique 2016-03-21 21:22:27 -07:00
jp9000
9e15e3d8fd libobs: Remove need for DrawMatrix technique in effects
(Note: This commit also modifies obs-filters and text-freetype2)

This simplifies writing of effects.  DrawMatrix is no longer necessary
because there are no sources that require drawing with a color matrix
other than async sources, and async sources are automatically processed
and don't defer their initial render stage to filters.
2016-03-21 21:22:26 -07:00
jp9000
d069302b2e libobs: Add function to get obs object type 2016-02-27 02:49:03 -08:00
jp9000
a64f7dd649 libobs: Fix an issue that would cause audio stuttering
Under certain circumstances, the timing_adjust variable would cause line
1161 to continually trigger over and over again.  The "loop detection"
code incorrectly made it so that any timestamp that was just simply
below the expected value would be seen as a jump.  After that, the
timing_adjust variable would be set for the frame again, and then the
audio would see it as a jump again after that, and those two things
would continue endlessly.  This would cause stuttering particularly with
certain devices (particularly elgato/lgp/hdpvr) where the audio/video
data are decoded and sent at varying/different/unpredictable times.

To fix this issue, it should not detect values below as jumps, but
instead should only do it for values that exceed the MAX_TS_VAR (maximum
timestamp variance) value.
2016-02-21 11:04:34 -08:00
jp9000
fa8ae473cf libobs: Fix bug where source audio could stop outputting
If obs_source::audio_ts is set to 0 (such as by discard_if_stopped in
obs-audio.c), but the push_back variable in the source_output_audio_data
function in obs-source.c was being set to true (meaning it's within the
seamless audio smoothing threshold), it would cause it to never reset
the obs_source::audio_ts value, and thus all audio data from the source
would become perpetually ignored by the audio subsystem until there was
finally some sort of timestamp jump that caused it to call
source_output_audio_place, and thus reset obs_source::audio_ts.

obs_source::audio_ts is only reset in source_output_audio_place, not in
source_output_audio_push_back, so the most simple solution is to just
call source_output_audio_push_back is obs_source::audio_ts is 0.
2016-02-04 01:36:13 -08:00
jp9000
b86fdae4a8 libobs: Don't clear audio on ts jump (seamless loops)
There's technically no need to clear the audio data here, nor is there
any need to try to trick the timestamp in to a different position.  It
can simple just reset the audio timing.

Prevents a possible case where audio data might be deleted when it's not
necessary to delete any.
2016-02-03 11:29:09 -08:00
jp9000
d2f2783b44 libobs: Always reset last audio buf size when it changes
This variable is used to detect whether audio has stopped -- if audio
stops, it detects that no new data is coming in, and resets the audio
position so that it eliminates the chance of causing the audio buffering
to go haywire if audio starts up again.  However, this variable was not
being reset every time the value changes, which it should.
2016-01-31 14:08:37 -08:00
jp9000
971728a1a7 libobs: Fix variable being access outside of a mutex
audio_input_buf should never be accessed outside of audio_buf_mutex.
2016-01-31 00:54:55 -08:00
jp9000
d43d59ca8a libobs: Remove seamless audio loop handling
The seamless audio looping code would erroneously trigger for things
that weren't loops, causing the audio data to continually push back and
ignore timestamps, thus going out of sync.

There does need to be loop handling code, but due to the fact that other
things may need to trigger this code, it's best just to clear the audio
data and start from a fresh sync point.  Unfortunately for the case of
loops, this means the window in which audio data loops and video frames
loop need to be muted.
2016-01-31 00:54:54 -08:00
jp9000
eae1328a4f libobs: Always return audio as pending if not an audio source
This is an additional method/helper that prevents composite sources from
treating non-audio sources as audio sources.
2016-01-31 00:54:53 -08:00
jp9000
6f98bd9fed libobs: Use calldata with stack for simple signals
Makes signals use stack memory rather than allocate memory each time.
Most likely a completely insignificant and pointless optimization.
2016-01-26 11:49:56 -08:00
jp9000
ce0a189228 libobs: Fix audio issues with async video/audio looping
This fixes an age-old issue where audio samples could be lost or audio
could temporarily go out of sync in the case of looping videos.  When
audio/video data is looping, there's a window between when the audio
data resets its timestamp value and when the video data resets its
timestamp value.  This method simply pushes back the audio data while in
that window and does not modify sync, and when it detects that its out
of the loop window it simply forces a resync of the audio data in the
circular buffer.

This ensures that minimal audio data is lost in the loop process, and
minimizes the likelihood of any sort of sync issues associated with
looping.
2016-01-26 11:49:54 -08:00
jp9000
41fa9c1bdb libobs: Don't include sync offsets in TS smoothing
Apply user sync offset *after* timestamp smoothing, not before.
Prevents small or gradual sync offsets from not being properly applied.
2016-01-26 11:49:54 -08:00
jp9000
1089564b57 libobs: Apply resampler offset to system audio TS
Instead of applying the resampler offset right away (to each audio
packet), apply the resampler offset when the timestamps are converted to
system timestamps.  This fixes an issue where if audio timestamps reset
to 0 (for whatever reason), the offset would cause the timestamp to go
in to the negative.
2016-01-26 11:49:53 -08:00
jp9000
9661ba8142 libobs: Add obs_source_duplicate function
Allows full duplication of sources (with exception of sources that are
marked with the OBS_SOURCE_DO_NOT_DUPLICATE output capability flag)
2016-01-26 11:49:51 -08:00
jp9000
56dc605497 libobs: Add obs_is_source_configurable function
Mostly only used for transitions with the intention of automatically
creating transitions which don't require configuration, returns whether
the source has any properties or not (whether it's configurable)
2016-01-26 11:49:49 -08:00
jp9000
3371ff59c9 libobs: Add *_create_private functions
Allows creation of private/unlisted sources/outputs/services/encoders
2016-01-26 11:49:48 -08:00
jp9000
bccd3b0b0a libobs: Allow "private" contexts
The intention of this is to allow sources/outputs/etc to be created
without being visible to the UI or save/load functions.
2016-01-26 11:49:47 -08:00
jp9000
669da7ba36 libobs: Do not use signals with audio capture/controls
(Note: This commit also modifies UI)

Instead of using signals, use designated callback lists for audio
capture and audio control helpers.  Signals aren't suitable here due to
the fact that signals aren't meant for things that happen every frame or
things that happen every time audio/video is received.  Also prevents
audio from being allocated every time these functions are called due to
the calldata structure.
2016-01-26 11:49:47 -08:00
jp9000
6839ff7686 libobs: Implement transition sources
Transition sources are implemented by registering a source type as
OBS_SOURCE_TYPE_TRANSITION.  They're automatically marked as video
composite sources, and video_render/audio_render callbacks must be set
when registering the source.  get_width and get_height callbacks are
unused for these types of sources, as transitions automatically handle
width/height behind the scenes with the transition settings.

In the video_render callback, the helper function
obs_transition_video_render is used to assist in automatically
processing and rendering the audio.  A render callback is passed to the
function, which in turn passes to/from textures that are automatically
rendered in the back-end.

Similarly, in the audio_render callback, the helper function
obs_transition_audio_render is used to assist in automatically
processing and rendering the audio.  Two mix callbacks are used to
handle how the source/destination sources are mixed together.  To ensure
the best possible quality, audio processing is per-sample.

Transitions can be set to automatically resize, or they can be set to
have a fixed size.  Sources within transitions can be made to scale to
the transition size (with or without aspect ratio), or to not scale
unless they're bigger than the transition.  They can have a specific
alignment within the transition, or they just default to top-left.
These features are implemented for the purpose of extending transitions
to also act as "switch" sources later, where you can switch to/from two
different sources using the transition animation.

Planned (but not yet implemented and lower priority) features:

- "Switch" transitions which allow the ability to switch back and forth
  between two sources with a transitioning animation without discarding
  the references

- Easing options to allow the option to transition with a bezier or
  custom curve

- Manual transitioning to allow the front-end/user to manually control
  the transition offset
2016-01-26 11:49:45 -08:00
jp9000
5098f68db0 libobs: Move obs_source_dosignal to obs-internal.h
Allows using it in multiple source files
2016-01-26 11:49:40 -08:00
jp9000
b0104fcee0 (API Change) libobs: Remove source_type param from functions
(Note: test and UI are also modified by this commit)

API Changed (removed "enum obs_source_type type" parameter):
-------------------------
obs_source_get_display_name
obs_source_create
obs_get_source_output_flags
obs_get_source_defaults
obs_get_source_properties

Removes the "type" parameter from these functions.  The "type" parameter
really doesn't serve much of a purpose being a parameter in any of these
cases, the type is just to indicate what it's used for.
2016-01-26 11:49:37 -08:00
jp9000
c1dd156db8 libobs: Implement new audio subsystem
The new audio subsystem fixes two issues:

- First Primary issue it fixes is the ability for parent sources to
  intercept the audio of child sources, and do custom processing on
  them.  The main reason for this was the ability to do custom
  cross-fading in transitions, but it's also useful for things such as
  side-chain effects, applying audio effects to entire scenes, applying
  scene-specific audio filters on sub-sources, and other such
  possibilities.

- The secondary issue that needed fixing was audio buffering.
  Previously, audio buffering was always a fixed buffer size, so it
  would always have exactly a certain number of milliseconds of audio
  buffering (and thus output delay).  Instead, it now dynamically
  increases audio buffering only as necessary, minimizing output delay,
  and removing the need for users to have to worry about an audio
  buffering setting.

The new design makes it so that audio from the leaves of the scene graph
flow to the root nodes, and can be intercepted by parent sources.  Each
audio source handles its own buffering, and each audio tick a specific
number of audio frames are popped from the front of the circular buffer
on each audio source.  Composite sources (such as scenes) can access the
audio for child sources and do custom processing or mixing on that
audio.  Composite sources use the audio_render callback of sources to do
synchronous or deferred audio processing per audio tick.  Things like
scenes now mix audio from their sub-sources.
2016-01-26 11:49:34 -08:00
jp9000
ddfd89a673 libobs: Implement composite sources (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

Adds a "composite" source type which is used for sources that composite
one or more sub-sources.  The audio_render callback is called for
composite sources to allow those types of sources to do custom
processing of the audio of its sub-sources.
2016-01-26 11:49:33 -08:00
jp9000
a5c9350be5 libobs: Remove "presentation volume" and "base volume" (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

These variables are considered obsolete and will no longer be needed.
2016-01-26 11:49:32 -08:00
jp9000
73ec5906b7 libobs: Add function that checks whether source is muted (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)
2016-01-26 11:49:32 -08:00
jp9000
27438a5156 libobs/media-io: Remove 'volume' from audio_data (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

This variable is somewhat redundant.  Volume is already known/accessible
to front-ends.
2016-01-26 11:49:31 -08:00
jp9000
bc0b85cb79 libobs: Store circular audio buffer on source itself (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

Removes audio lines and stores the circular buffer for the audio on the
source itself.
2016-01-26 11:49:30 -08:00
jp9000
f73bbe6746 libobs: Store source audio mixers in obs_source (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

The mixers that a source was assigned to were originally stored in the
audio line.  This will store it in the sources themselves instead.
2016-01-26 11:49:29 -08:00
jp9000
ed8998e403 libobs: Do recursive height/width calls on non-filters
Originally this was programmed to call the recursive height/width
functions if the source type was an input with the intention of not
calling it on filters, but instead of doing that just program it to do
just that: only call the recursive height/width functions if it's not a
filter.
2016-01-23 07:17:47 -08:00
jp9000
8f7d8d05b2 libobs: Add sample_rate param to conv_frames_to_time
Prevents from having to query the base audio subsystem for the sample
rate each time the function is called
2015-12-22 06:18:21 -08:00
jp9000
96d9bf794c libobs: Store linked list of audio sources
Useful for going traversing the list of audio sources (particularly for
the new audio subsystem)
2015-12-22 06:18:20 -08:00