Commit graph

1129 commits

Author SHA1 Message Date
jp9000 2a4ac3dc21 libobs: Improve module register warnings
Fixes some typos and specifies the function that's being called
2016-01-26 11:49:42 -08:00
jp9000 234cb5802f libobs: Release scene items outside of scene mutexes
Prevents a mutual lock with the scene mutex and graphics mutex.  In
libobs/obs-video.c, the graphics mutex could be locked first, then the
scene mutexes second, while in the UI thread, the scene mutexes could be
locked first, then when a scene item is being destroyed, a source could
be destroyed, and sometimes sources would lock the graphics mutex
second.

A possible additional solution is to defer source destroys to the video
thread.
2016-01-26 11:49:41 -08:00
jp9000 ed10b1ab57 libobs: Allow add_alignment to be used by other source files 2016-01-26 11:49:40 -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 6f053b89bd libobs: Mark transition sources as composite
Transition sources are always considered composite sources, as they have
child sources.
2016-01-26 11:49:39 -08:00
jp9000 84251055fa libobs: Add function to enumerate all source types 2016-01-26 11:49:38 -08:00
jp9000 e68331e988 libobs: Add source type OBS_SOURCE_TYPE_SCENE
Helps identify a scene without having to compare its type name to
"scene".
2016-01-26 11:49:38 -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 20db7649aa libobs/media-io: Reset audio array for each input
The audio data would get overwritten and become invalid if there was
more than one input
2016-01-26 11:49:36 -08:00
jp9000 3c68196c5c libobs: Buffer scene item visibility actions
This buffers scene item visibility actions so that if
obs_sceneitem_set_visible to true or false, that it will ensure that the
action is mapped to the exact sample point time in which
obs_sceneitem_set_visible is called.  Mapping to the exact sample point
isn't necessary, but it's a nice thing to have.
2016-01-26 11:49:36 -08:00
jp9000 247a42c2a1 libobs: Make scenes mix audio of sub-sources
Mark scenes as composite sources and use audio_render to mix and output
the audio of their sub-sources.
2016-01-26 11:49:35 -08:00
jp9000 40d6f986e6 libobs: Split scene mutex to improve performance
Splits the scene mutex in to an audio/video mutex to allow video/audio
thread to use the same data at the same time without locking on each
other.
2016-01-26 11:49:34 -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 ee1842d1f5 libobs/media-io: Remove audio lines (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)

Uses a callback and allows the caller to mix audio.  Additionally,
allows the callback to return audio later, allowing it to buffer as much
as it needs.
2016-01-26 11:49:28 -08:00
jp9000 726163aa29 libobs: Report lost frame count due to rendering lag
This has been missing for a bit too long, and should make it
easier/faster to diagnose issues users might be having.
2016-01-25 17:29:09 -08:00
jp9000 23f4d17d41 libobs/media-io: Fix bug (skipped frames including lagged frames)
The skipped frame count (dropped frames due to encoding being
overloaded) would erroneously include lagged frames (dropped frames due
to render stalls).  This will make diagnosing actual issues a user might
be having a bit easier.
2016-01-25 17:29:09 -08:00
jp9000 65eb3c0815 libobs: Fix potential output audio/video sync bug
Problem:

When an output is started with encoders that have already been started
by another output, and it starts in between the window in between where
the first audio packets start coming in and where the first video packet
comes in, the output would get audio packets with timestamps potentially
much later than the first video frame when the first video frame finally
comes in.  The audio/video encoders will almost always have a differing
delay.

Solution:

Detect that starting window, and if within that starting window, wait
for a new keyframe from video instead of trying to sync up video.

Additional Notes:

In these cases where an output starts with already-active encoders, this
patch also reduces the potential sync offset between the first video
frame and the first audio frame.  Before, it would sync the first video
frame with the first audio frames right after that, but now it syncs
with the closest audio frame in the interleaved array, which halves the
potential sync difference between the first video frame and the first
audio frame of already-active encoders.  (So now the potential sync
difference is roughly 11.6 milliseconds at 44.1khz audio, where it was
23.2 before)
2016-01-25 17:29:09 -08:00
jp9000 c4657da2f1 libobs: Subtract packet dts_usec with first packet offset
Ensures that the packet dts_usec vals which are generated for
syncing/interleaving use the proper offset relative to where they're
supposed to be starting from.  The negative DTS of a first video packet
could potentially have been applied twice due to this.
2016-01-25 17:29:09 -08:00
jp9000 346ddd502f libobs: Fix potential race condition
Fixes potential race conditions when two threads are trying to
initialize/start/stop the same encoders at the same time.
2016-01-25 17:29:09 -08:00
jp9000 92bbb8e8b1 libobs/callback: Allow ability to use calldata_t with stack
Allows the ability to use fixed stack memory to construct a calldata_t
structure rather than having to allocate each time.  This is fine to do
for certain signals where the calldata never goes above a specific size.
If by some chance the size is insufficient, it will output a log
message.
2016-01-25 17:29:08 -08:00
jp9000 9c5f95d823 libobs: Add function to get current video time (in nanosec)
Allows getting the timestamp for the video frame currently being
rendered.
2016-01-25 17:29:08 -08:00
jp9000 13890a46e6 libobs/graphics: Add gs_image_file_* functions (w/animated gifs)
These functions allow animated gifs and management of image files.  Uses
libnsgif to load animated gifs.
2016-01-25 17:29:08 -08:00
jp9000 9f63554e69 libobs: Add gs_create_texture_file_data function
Allows loading the file to memory first so the graphics subsystem
doesn't necessarily have to be locked when loading image files.
2016-01-23 07:17:48 -08:00
jp9000 b0ca6eaf50 libobs: Make obs_source_save and obs_source_load internal
There shouldn't be any need to call these functions manually.  These
functions are called automatically by obs_save_sources and
obs_load_sources.
2016-01-23 07:17:47 -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 bdd7577a1a libobs: Always have a transparent blank texture available
Allows transitions to be able to return a blank texture to transitions
if a transition is transitioning from/to a NULL source.
2016-01-23 07:17:46 -08:00
jp9000 46feac7f8f libobs/graphics: Allow gs_render_sprite use without texture
Allows gs_render_sprite to be used without a texture as long as cx/cy
are set.  There's no reason why it shouldn't be able to do this.
2016-01-23 07:17:45 -08:00
jp9000 38f368aa80 libobs/util: Make all atomic funcs inline and use intrinsics
Needless function calls here for what should be intrinsic calls
2016-01-23 07:17:44 -08:00
jp9000 ac63bd819c libobs: Move windows headers to WIN32 section in cmake file
These were in the APPLE section by mistake
2016-01-23 07:17:43 -08:00
jp9000 4543cd168d libobs/util: Add long load/store atomic funcs 2015-12-28 05:49:55 -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
jp9000 a702d88c25 libobs: Don't track active transitions
This was originally used for calculating audio volume if transitions
were active, but transitions won't work that way so tracking the active
transitions is no longer needed.
2015-12-22 06:18:19 -08:00
jp9000 fc057f6d88 libobs/media-io: Add funcs to convert between nanoseconds/frames
Uses 128bit integer math to prevent overflow
2015-12-22 06:18:18 -08:00
jp9000 9f9a4bc3f3 libobs/util: Add uint128 structure/functions
Allows some limited 128bit integer math functions, primarily for the
sake of performing calculations on nanosecond-based intervals of time
2015-12-22 06:18:17 -08:00
jp9000 7a81d3d6d7 libobs/util: Add circlebuf pop_back/peek_back functions 2015-12-22 06:18:16 -08:00
jp9000 c2168cf9e8 libobs/util: Don't perform calculation until data checked 2015-12-22 06:18:15 -08:00
jp9000 c6914fda45 libobs/util: Add circlebuf_push_front function 2015-12-22 06:18:14 -08:00
jp9000 5be855e852 libobs: Make scene item visibility activate/deactivate
Before if a source was set to invisible it would still be considered
active.  This changes it so that the source is deactivated when the
source is invisible to reduce needless resource usage or capturing.
2015-12-22 05:49:03 -08:00
jp9000 c8f4fbe42b (API Change) libobs: Rename funcs relating to active child sources
Renames:
----------------------------------------
obs_source_add_child
obs_source_remove_child
obs_source_enum_sources
obs_source_enum_tree
obs_source_info::enum_sources

To:
----------------------------------------
obs_source_add_active_child
obs_source_remove_active_child
obs_source_enum_active_sources
obs_source_enum_active_tree
obs_source_info::enum_active_sources

These functions/callbacks had misleading names: they originally implied
any child sources, when they actually meant active child sources that
are being used to render video or audio.  It's important that the
function names represent their actual purpose.
2015-12-22 05:49:02 -08:00
Palana 684b43ccfa libobs: Move previously ineffective NULL checks 2015-12-22 05:49:02 -08:00
Palana ec86bdaa09 libobs: Add obs_save_sources_filtered (skip)
(Note: This commit breaks UI compilation.  Skip if bisecting)

Adds a means of saving specific sources that the front-end chooses,
rather than being forced to use the now-removed "user list".
2015-12-22 05:48:59 -08:00
jp9000 70fec7ae8e (API Change) libobs: Remove "User sources list" (skip)
(Note: This commit breaks UI compilation.  Skip if bisecting)

API Removed:
------------------------
obs_add_source

API Changed:
------------------------
obs_source_remove: Now just marks/signals a source for removal

The concept of "user sources" is flawed: it was something that the
front-end was forced to deal with if it wanted to automate source
saving/loading, and often it had to code around it.  That's not how
saving/loading should work, a front-end should be allowed to manage
lists of sources in the way it explicitly chooses, and it should be able
to choose which sources it wants to save/load.
2015-12-22 05:48:43 -08:00
jp9000 59f0ba0c8a libobs: Add load/save signals for sources
These signals are meant to replace the add/remove signals.
2015-12-22 05:36:22 -08:00