Commit Graph

3673 Commits (57d580f8a9ecc7adb0513d278a18738b75657113)

Author SHA1 Message Date
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 adcbf9311b UI: Remove "audio buffering time" (skip)
(Note: This commit breaks libobs compilation.  Skip if bisecting)
2016-01-26 11:49:30 -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 2591f24594 win-capture: Add game capture fix for darkest dungeon
Darkest dungeon uses an unusual technique for drawing its frames: a
fixed 1920x1080 frame buffer used in place of the backbuffer, which is
then stretched to fit the size of the screen (whether the screen is
bigger or smaller than the actual texture).

The custom frame would cause glReadBuffer to initially fail with an
error.  When this happens, their custom frame buffer is in use, so all
that needs to be done is simply reset the capture and force the current
output size to 1920x1080 while that custom frame is in use.

They presumably did this in order to ensure the game looks the same at
any resolution.  Instead of having to use power-of-two sprites and
mipmaps for every single game sprite and stretch/skew each of them
(which would risk the final output "not looking quite right" at
different resolutions), they simply use non-pow-2 sprites with no
mipmaps and render them all on to one texture of a fixed size and then
stretch that final output texture.  That ensures that the actual
composite of the game still looks the same at any resolution, while
reducing texture memory by not requiring each sprite to use a
power-of-two texture and mipmaps.
2016-01-26 11:49:28 -08:00
jp9000 7f0f3d25c9 obs-ffmpeg: Remove overly verbose FFmpeg logging
For the time being, FFmpeg logging is disabled due to the fact that it
can just output way too much data.
2016-01-26 11:49:27 -08:00
jp9000 22885713b0 obs-ffmpeg: Add "restart when active" media source property
Adds the option of making the media file restart when the source becomes
active (such as switching to a scene with it).

Due to lack of libff features to start/stop/pause/seek media files,
currently this just destroys the demuxer and recreates it.  Ideally,
libff should have some functions to allow a more optimal means of doing
those things.
2016-01-26 11:49:26 -08:00
jp9000 419d6b1a22 obs-ffmpeg: Refactor media source properties
Reactors a bit of code related to starting up FFmpeg and makes it so the
initial view for the media source's properties displays the most
commonly desired settings.

Instead of the media source properties showing the URL mode by default
along with a whole bunch of properties that are confusing to most users,
starts on file mode and changes defaults to be a bit more sensible
related to file input.

Also, as a temporary measure for fixing color format issues (some video
files would display their color information incorrectly), forced format
conversion is now enabled by default, and has been moved to advanced
settings.  Ideally, the actual bug causing color format issues in either
media-io or libff should be fixed at some point.
2016-01-26 11:49:26 -08:00
jp9000 df4f0c4142 obs-ffmpeg: Fix media source file filter
When browsing for a file, it would also just use *.* for the file
filter, which is a pain to use.  This has been changed to use a
reasonable file filter related to common video/audio files so you don't
have to wade through non-media files just to select a media file.  A
filter to show all files is still available as well.
2016-01-26 11:49:25 -08:00
jp9000 c2f796660d deps/libff: Make libff use default frame discard method 2016-01-26 11:49:24 -08:00
jp9000 bd6ffd76d0 obs-filters: Make mask filter use gs_image_t helper
Prevents it from loading the entire image in the graphics thread, and
allows for animated gifs in the filter (not that anyone would ever do
that.  ..right?)
2016-01-26 11:49:24 -08:00
jp9000 4f782f2415 obs-filters: Make mask/blend image center w/aspect by default
Fixes what is arguably the most annoying feature of the mask/blend
filter, the fact that the image always stretches to the entire source.
It now centers and preserves aspect ratio by default, with an option to
make it stretch and discard aspect ratio to make it operate as it did
before.
2016-01-26 11:49:23 -08:00
jp9000 423f5ea1fc image-source: Use gs_image_file (adds animated gif support) 2016-01-26 11:49:22 -08:00
jp9000 ebadd359c0 image-source: Have images not unload by default
Images continually loading/unloading every time transitioning occurs
adds a lot of unnecessary transition lag.  The user can always change
this value manually and/or use scene collections, so change the default
setting to make it not unload/reload by default feels a bit more safe.
2016-01-26 11:49:21 -08:00
jp9000 756fec3503 linux-capture: Clear x events when exiting handler
This is probably not necessary but might fix an issue where errors pass
through to other parts of the program, possibly causing the crash on
exit related to the xcomposite capture.
2016-01-26 11:49:21 -08:00
Lucian Poston c392164f03 linux-capture: Log warning when unable to query windows
Checks whether window manager supports ewmh. Logs warning if ewmh is not
supported.

Closes jp9000/obs-studio#488
2016-01-26 11:49:20 -08:00
bla f32f65bb1f UI: Don't create sources popup menu if no scenes
Closes jp9000/obs-studio#499
2016-01-26 11:48:53 -08:00
jp9000 832043fc7f UI: Disable OSX V-Sync when program is open
OSX has an annoying feature called "BeamSync", which on later versions
of OSX is always on.  For whatever reason, Apple devs decided to force
this feature to always be on, so applications must always render with
v-sync regardless of what they set their swap interval to.

This issue would cause syncing to the vertical refresh for each
additional active display, and wouldn't allow rendering above the
current refresh rate.  This caused major rendering stalls and prevented
video frame timing from being accurate.

This fixes the issue by using an undocumented set of functions to
disable BeamSync.  Note that because this is an undocumented method of
working around the issue, its existence cannot be guaranteed.  If the
functions no longer exist for whatever reason, it will safely do
nothing.
2016-01-25 17:44:41 -08:00
jp9000 c072ba55b2 UI: Hide renderer/adapter when not on windows
Also hide adapter list if not using Direct3D.
2016-01-25 17:29:11 -08:00
jp9000 22f7e6a82d UI: Move Renderer/Adapter to advanced
These really are advanced options that users shouldn't need to change
normally, so moving them to advanced makes sense, and keeps them away
from users who don't know what they're doing.
2016-01-25 17:29:11 -08:00
jp9000 9e4761347d UI: Fix a case where output res. stays invalid
If the base resolution is set to an invalid resolution, it would cause
the output resolution to automatically change to an invalid resolution.
After the invalid resolution was set for the output resolution, it would
stay at that invalid resolution.

This fixes it so it always tries to find the output resolution closest
to what was last actually set or actually edited.
2016-01-25 17:29:10 -08:00
jp9000 9b5ac1fbd2 UI: Fix preview right-click menu getting wrong source
When right-clicking items in the preview window and getting context
menus for them, it would often make the wrong scene item be associated
with the context menu because of the fact that it was using
QListWidget::currentItem instead of querying the actual selected list.

You must query the actual selection list via QListWidget::selectedItems
because QListWidget::currentItem does not work properly for
multi-selection list widgets.
2016-01-25 17:29:10 -08:00
jp9000 e5fc4dbbcd UI: Warn if high resource usage when encoding
Shows a warning stating that encoding is stalling, and shows the number
and percentage of frames that were skipped due to encoding.
2016-01-25 17:29:10 -08:00
jp9000 3749436cd5 UI: Fix "invalid" audio devices in audio settings
If a global audio device is disconnected or for whatever reason is no
longer available when audio settings is opened, it will erroneously
select index 0 of the combo box ("Disabled") by default because it can't
find it in the combo box.  This fixes that issue by making it insert an
item in to the combo box specifying that the previously available audio
device is no longer available, and properly preserving the user's
settings.
2016-01-25 17:29:10 -08:00
jp9000 bbbdd4442c UI: Add options to enable/disable stream confirm dialogs
Some streamers would accidentally hit start/stop streaming, which on
certain services would send out mass emails to all their followers.
This just adds options to general settings to optionally enable dialogs
that confirm whether to actually start/stop streaming when the button is
clicked.
2016-01-25 17:29:10 -08:00
jp9000 213d8ce154 UI: Add "Always On Top" option to file menu 2016-01-25 17:29:10 -08:00
jp9000 9991f6a7ec UI: Fix advanced audio properties duplication bug
Because of the patch that removed the "user sources list" in libobs
(70fec7ae8), obs_enum_sources will now enumerate the global audio
sources, where it didn't before.  In the advanced audio properties
dialog, before the patch I had to use code to manually include them, but
I neglected to remove that code when I made that patch, so it would
cause them to be added more than once.  This just removes that code.
2016-01-25 17:29:10 -08:00
jp9000 6da742ba02 UI: Fix bug where default scene would not be added to list 2016-01-25 17:29:10 -08:00
jp9000 db48e3471e UI: Add GetCurrentSceneSource inline function 2016-01-25 17:29:10 -08:00
jp9000 b8547aa811 UI: Add menu button (split button) class
When you assign a menu to a normal QPushButton, it becomes a button that
only allows you to have a menu.  This class lets you click the button
and have a menu at the same time.
2016-01-25 17:29:10 -08:00
jp9000 370761ba29 UI: Add helper to delete layout and layout contents 2016-01-25 17:29:09 -08:00
jp9000 6262abc2c8 UI: Resize main preview on the widget's resize signal
Fixes a bug where the preview's size calculations wouldn't update if the
widget itself was resizes but the window wasn't resized.
2016-01-25 17:29:09 -08:00
jp9000 d7d5e55d2c UI: Add splitter to main window
Allows adjusting the size of the bottom section of the main window
2016-01-25 17:29:09 -08:00
jp9000 9cded466dc libobs-opengl: Disable v-sync when drawing on linux
Prevents glXSwapBuffers from stalling.  It would have to stall and wait
for the next frame for each and every single additional swap chain.
2016-01-25 17:29:09 -08:00
jp9000 aa48c6e9bc deps/glad: Add support for glSwapIntervalMESA
Just in case glSwapIntervalEXT and glSwapIntervalSGI aren't available
for whatever reason.  This entire patch is most likely completely
redundant on modern mesa drivers.
2016-01-25 17:29:09 -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