Commit Graph

3378 Commits (d2f2783b446a26b7bedab65db46fc5f7b1c30f5e)

Author SHA1 Message Date
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 6407707a04 UI: Ensure the output res. is modified along with base 2016-01-31 00:55:05 -08:00
jp9000 3ca327fd76 UI: Resize program view if resolution settings changed 2016-01-31 00:55:04 -08:00
jp9000 e93aeaef31 libobs: Fix potential crash when transitioning
Sometimes the A and B sources of a transition would a large difference
in their timestamps, and the calculation of where to start the audio
data for one of the sources could be above the tick size, which could
cause a crash.
2016-01-31 00:55:03 -08:00
jp9000 4b15880231 libobs: Discard remainder audio if source audio stopped
If the circular audio buffer of the source has data remaining that's
less than the audio frame tick count (1024 frames), it would just leave
that audio data on the source without discarding it.  However, this
could cause audio buffering to increase unnecessarily under certain
circumstances (when the next audio timestamp is within the timestamp
jump window), so it would append data to that circular buffer despite
the audio stopping that long ago, causing audio buffering to have to
increase to compensate.

Instead, just discard pending audio if it hasn't been written to.  In
other words, if the audio has stopped and there's insufficient audio
left to continue processing.
2016-01-31 00:55:02 -08:00
jp9000 9aa18d3de5 libobs: Ensure paired encoders start up at the same time
With the new audio subsystem, audio buffering is minimal at all times.
However, when the audio buffering is too small or non-existent, it would
cause the audio encoders to start with a timestamp that was actually
higher than the first video frame timestamp.  Video would have some
inherent buffering/delay, but then audio could return and encode almost
immediately.  This created a possible window of empty time between the
first encoded video packet and the first encoded audio packet, where as
audio buffering would cause the first audio packet's timestamp to always
be way before the first video packet's timestamp.  It would then
incorrectly assume the two starting points were in sync.

So instead of assuming the audio data is always first, this patch makes
video wait for audio data comes in, and conversely buffers audio data
until video comes in, and tries to find a starting point within that
video data instead, ensuring a synced starting point whether audio
buffering is active or not.
2016-01-31 00:55:01 -08:00
jp9000 a7067906f3 libobs: Try to pair video with one multi-track encoders
When starting a multi-track output, attempt to pair the video encoder
with one of the audio encoders to ensure that the video and audio
encoders start as close together in time as possible.  This ensures the
best possible audio/video syncing point when using multi-track audio
output.
2016-01-31 00:55:00 -08:00
jp9000 b0d88f7c1f libobs: Start audio tracks before starting video tracks
When using multi-track audio, encoders cannot be paired like they can
when only using a single audio track with video, so it has to choose the
best point in the interleaved buffer as the "starting point", and if the
encoders start up at different times, it has to prune that data and wait
to start the output on the next video keyframe.  When the audio encoders
started up, there was the case where the encoders would take some time
to load, and it would cause the pruning code to wait for the next
keyframe to ensure startup syncing.

Starting the audio encoders before starting the video encoder should
reduce the possibility of that happening in a multi-track scenario.
2016-01-31 00:54:59 -08:00
jp9000 be717dbb2c libobs: Consider multi-track audio when pruning packets
In a multi-track scenario it was not taking in to consideration the
possibility of secondary audio tracks, which could have caused desync on
some of the audio tracks.
2016-01-31 00:54:58 -08:00
jp9000 ec7faee32c libobs: Add find_first_packet_type_idx
Gets the index of the first interleaved packet of a given/type and audio
index
2016-01-31 00:54:57 -08:00
jp9000 48a3230b07 UI: Fix a wrong label alignment in settings window 2016-01-31 00:54:56 -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 3988c6d4b6 libobs: Always render active audio sources when possible
Fixes an issue where audio data would not be popped if they were not
activated/presenting.  This would cause the audio subsystem to
needlessly buffer when they were reactivated again.  Rendering all audio
sources (excuding composite/filter sources) helps ensure that audio data
is always popped and not left to pile up.
2016-01-31 00:54:51 -08:00
jp9000 9e17328392 UI: Fix Delete shortcut for scenes/sources listboxes
When the new UI was put in, the action shortcuts were unintentionally
removed from the list boxes.
2016-01-31 00:54:50 -08:00
Jim cc2007f120 Merge pull request #501 from boombatower/gcc48
UI: Fix GCC 4.8 compilation issue
2016-01-29 12:32:49 -08:00
boombatower 8593c4bacd UI: Fix GCC 4.8 compilation issue
Apparently using QPointer container for the QObject being given to the
connect function makes it so it can't find the actual function to use.
I'm guessing this is incomplete functionality or a bug that existed in
GCC 4.8.  Doesn't happen in 4.9+.
2016-01-29 14:09:13 -06:00
jp9000 514b59c78f libobs: Update version to 0.13.0 2016-01-27 15:48:35 -08:00
jp9000 959b6610c4 win-dshow: Update libdshowcapture to 0.5.7 2016-01-27 15:19:37 -08:00
jp9000 c431e0434c win-dshow: Pass proper range value to frame
The "full_range" member variable of the video frame was being passed
"false" each time even though it may not necessarily be set to partial
range
2016-01-27 15:07:15 -08:00
jp9000 544953c870 UI: Implement transitions and preview/program mode
Implements transitions, and introduces "Studio Mode" which allows live
editing of the same or different scenes while preserving what's
currently being displayed.

Studio Mode offers a number of new features:
  - The ability to edit different scenes or the same scene without
    modifying what's currently being displayed (of course)

  - The ability to set up "quick transitions" with a desired transition
    and duration that can be assigned hotkeys

  - The option to create full copies of all sources in the program scene
    to allow editing of source properties of the same scene live without
    modifying the output, or (by default) just use references.  (Note
    however that certain sources cannot be duplicated, such as capture
    sources, media sources, and device sources)

  - Swap Mode (enabled by default) which swaps the program scene with
    the preview scene when a transition completes

Currently, only non-configurable transitions (transitions without
properties) are listed, and the only transitions available as of this
writing are fade and cut.  In future versions more transitions will be
added, such as swipe, stingers, and many other various sort of
transitions, and the UI will support being able to add/configure/remove
those sort of configurable transitions.
2016-01-26 11:49:56 -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 91ebb5c5e0 libobs: Add comment warning about scene mutex lock ordering
A comment that serves as a reminder to anyone who might need to edit the
scene code.  If the graphics mutex must be locked, it must be locked
first before entering the scene mutexes, or outside of the scene
mutexes.
2016-01-26 11:49:55 -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 a61933dd8e (API Change) libobs: Add 'type' to obs_scene_duplicate
(Note: This commit also modifies the UI)

Allows the ability to duplicate sources fully copied, and/or have the
scene and its duplicates be private sources
2016-01-26 11:49:52 -08:00
jp9000 6824910f5d libobs: Add obs_scene_create_private function
Creates a scene marked as a private source
2016-01-26 11:49:52 -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 cd97ce2a17 libobs: Add source output flag OBS_SOURCE_DO_NOT_DUPLICATE
Certain types of sources (display captures, game captures, audio
device captures, video device captures) should not be duplicated.  This
capability flag hints that the source prefers references over full
duplication.
2016-01-26 11:49:50 -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 a4e0cd71b8 libobs: Refactor obs_get_source_by_name
Changes it to use obs_context_by_name
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 46bb2622c4 obs-transitions: Implement cut transition 2016-01-26 11:49:46 -08:00
jp9000 4b781c7b04 obs-transitions: Implement fade transition
A basic fade transition that fades to/from a source via a simple cross
fade.
2016-01-26 11:49:45 -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 c1227b3434 libobs: Remove 'get_transition_volume' callback
This callback will no longer be used, instead transitions will modify
the audio data directly.
2016-01-26 11:49:44 -08:00
jp9000 da2f9f732e libobs: Do not require get_width/height for filters/transitions 2016-01-26 11:49:43 -08:00
jp9000 03df6b2ceb libobs: Warn/ignore if transitions use get_width/get_height
These functions aren't used with transition sources, and will be
ignored.
2016-01-26 11:49:43 -08:00
jp9000 c28cfa556b libobs: Mark transitions as video/custom draw 2016-01-26 11:49:42 -08:00
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