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

35 Commits

Author SHA1 Message Date
jpark37
7af886581d libobs/audio-monitoring: Add WASAPI init helper
audio_monitor_init_wasapi will be used for reconnect logic.
2021-10-10 19:22:35 -07:00
jpark37
63ffae7d74 libobs/audio-monitoring: Remove unnecessary device 2021-10-10 19:22:35 -07:00
jpark37
b005e6748e libobs/audio-monitoring: Fix mutex leak
Use SRWLOCK for simplicity. Does not need to be destroyed.
2021-10-10 19:22:35 -07:00
Hector Martin
a5d08e347e linux-pulseaudio: fix race conditions
PulseAudio code needs to be called with the PA lock held. This chiefly
fixes multiple races during stream shutdown:

* If the functions are called without the lock held, deferred event
  handling races end up with PA infinite looping on the mainloop, or
  asserting, or other badness, as the reentrant calls cause data
  structure corruption on the PA side.
* If we don't reset our callbacks, PA might call us even after we
  request stream disconnection (since the stream actually getting fully
  shut down is asynchronous), and then we dereference NULL pointers from
  our userdata etc. PA will keep its data structures alive until necessary
  via reference counting, but not ours.

The lock around pa_stream_begin_write doesn't result from any issues I
experienced, but it looks correct; PA doesn't say anywhere that that
function is thread-safe.
2020-12-12 12:05:12 -08:00
Hans Petter Selasky
0e4ea14ba1 libobs: Implement and use better scaling function for 64-bit integers
As os_gettime_ns() gets large the current scaling methods, mostly by casting
to uint64_t, may lead to numerical overflows. Sweep the code and use
util_mul_div64() where applicable.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>
2020-04-05 20:27:28 +02:00
Clayton Groeneveld
6a7260783e audio-monitoring: Fix Pulse Audio crash 2020-01-18 10:46:56 -06:00
luz.paz
d124e6402c docs/sphinx: Fix various typos
(This modifies UI, libobs, deps/obs-scripting, various cmake files)

Found using:
`codespell -q 3 -S *.ini,./UI/data/locale,./deps/w32-pthreads -L aci,dur,iff,mut,numer,uint`
2019-10-14 17:19:38 -07:00
jp9000
d6f9ff0406 Revert "libobs/audio-monitoring: Don't init until used"
This reverts commit 22aa66a6eb.

Apparently, starting audio on the fly like this can introduce latency in
to the audio playback, so for now revert it.  It was a bit of a
precautionary thing rather than an actual fix anyway, so it probably
wasn't all that necessary to begin with.
2019-10-11 23:34:27 -07:00
jp9000
254947eaa0 libobs/audio-monitoring: Add error logging
Helps diagnose issues if the user is unable to initialize audio
monitoring for whatever reason.
2019-10-10 02:04:59 -07:00
jp9000
22aa66a6eb libobs/audio-monitoring: Don't init until used
This prevents audio monitoring from actually initializing unless audio
is actually played back through the source.  This prevents many browser
sources from initializing audio monitoring all at once needlessly if
audio is not being rerouted to OBS.
2019-10-10 02:04:58 -07:00
jp9000
f53df7da64 clang-format: Apply formatting
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.
2019-06-23 23:49:10 -07:00
Clayton Groeneveld
d1be93ae69 UI, libobs, text-freetype2: Add missing pragma once in header files 2019-04-01 02:48:28 -05:00
Marvin Scholz
649fa7651b libobs/audio-monitoring: Use libobs CFString utils 2018-09-16 22:41:01 +02:00
Shaolin
226d4cadf5 libobs: Remove VLA in pulse monitoring backend 2018-09-03 17:39:49 -03:00
Luke Yelavich
f29a4a8145 libobs: Copy the device uid string for mac audio monitor 2018-07-21 09:14:12 +10:00
Luke Yelavich
5c066ed48f libobs: Pass address of cf_uid rather than the contents of cf_uid 2018-07-21 09:14:12 +10:00
Luke Yelavich
002696e795 libobs: Rework checking Mac audio device capabilities
As of commit 2eb5a22, CoreAudio devices that use one device handle for
both input and output can no longer be used for audio monitoring. This
commit fixes that.

Tested with the built-in output, a Magewell XI100DUSB-HDMI which is
input only, and a MOTU UltraLite audio interface, which shows as
output/input capable.
2018-07-21 09:14:12 +10:00
Daniel Lopez
4cebbcc23b libobs: Fix compilation issue on case-sensitive filesystems
When using a macOS running on a case-sensitive filesystem, the project
build fails due to AudioToolBox/AudioQueue.h not being found.
The correct path is AudioToolbox/AudioQueue.h. Since macOS comes with a
case-insensitive filesystem by default, this is a rare ocurrence
among developers who change it to be case-sensitive.
2018-06-08 19:06:23 -05:00
Daniel Lopez
ceac83e499 libobs: Add check for cf_uid pointer free
This little change skips returning true immediately when a call to
CoreAudio fails. Instead, it uses similar behavior as further 3 calls
below this change, just checking for unfreed pointers before also
returning true.
2018-06-08 19:05:23 -05:00
Daniel Lopez
2eb5a2288a libobs: Fix Monitoring devices showing input devices
This bug fix is to show output devices in the Advanced Audio
Settings configuration, where currently on macOS it shows erroneously
input devices.
2018-06-08 19:03:53 -05:00
jp9000
4b54bde426 cmake, libobs, win-capture: Fix VS2017 warnings 2018-03-12 16:16:38 -07:00
Jim
77643cce1e
Merge pull request #1139 from takev/pulseaudio-surround-selection
linux-pulseaudio: Surround speaker map
2018-01-19 16:14:04 -08:00
Tjienta Vara
48a8e750bb linux-pulseaudio: Surround speaker map
When using more than two channels, the channel map of pulse-audio is incorrect.

Add an API for getting a speaker map based on OBS speaker layout. Then use the
speaker map when connecting to a pulse-audio device, for both source and
monitor output.
2018-01-17 13:05:04 +01:00
Tjienta Vara
8f6d048817 linux-pulseaudio: Default sample format float32le
This pull request changes the fallback sample format for pulse-audio
to from PA_SAMPLE_S16LE to PA_SAMPLE_FLOAT32LE.

The pulseaudio plugin can handle the following sample format:
* PA_SAMPlE_U8
* PA_SAMPLE_S16LE
* PA_SAMPLE_S32LE
* PA_SAMPLE_FLOAT32LE

When an audio device advertises itself as another format, the pulseaudio-plugin
will ask pulse audio to convert to the fallback sample format.

The fallback PA_SAMPLE_S16LE is not ideal when your audio interface advertises
as PA_SAMPLE_S24LE since the conversion will lose precision.
With PA_SAMPLE_FLOAT32LE there is no precision loss and it is also equals OBS's
internal format.
2018-01-08 19:31:09 +01:00
Shaolin
9de1ffe32b libobs: Fix pulseaudio monitor playback stuttering 2018-01-07 19:27:58 -02:00
pkviet
67e48ecc2c libobs/media-io: Replace quad with 4.0
(also obs, deps/media-playback, libobs/audio-monitoring, decklink,
linux-alsa, linux-pulseaudio, mac-capture, obs-ffmpeg, win-dshow,
win-wasapi)

Default channel layout for 4 channels is 4.0 in FFmpeg.
Replacing quad with 4.0 will improve compatibility since FFmpeg has
better support of its default channel layouts.
2018-01-05 09:48:52 -08:00
pkviet
fb580535c9 libobs/media-io: Clean surround API
(also modifies obs-ffmpeg, audio-monitoring, win-wasapi, decklink,
obs-outputs)

Removes speaker layouts which are not exposed in UI.  The speaker
layouts selectable by users in the UI are the most common ones.  It is
not necessary to keep other layouts.  (This basically removes
5POINT1_SURROUND, 7POINT1_SURROUND, SURROUND =3.0).
2018-01-05 09:47:59 -08:00
pkviet
bbac3280c1 libobs: Add surround sound audio support
(This commit also modifies the following modules: UI,
deps/media-playback, coreaudio-encoder, decklink, linux-alsa,
linux-pulseaudio, mac-capture, obs-ffmpeg, obs-filters, obs-libfdk,
obs-outputs, win-dshow, and win-wasapi)

Adds surround sound audio support to the core, core plugins, and user
interface.

Compatible streaming services: Twitch, FB 360 live
Compatible protocols: rtmp / mpeg-ts tcp udp
Compatible file formats: mkv mp4 ts  (others untested)
Compatible codecs: ffmpeg aac, fdk_aac, CoreAudio aac,
		   opus, vorbis, pcm (others untested).
Tested streaming servers: wowza, nginx
	 HLS, mpeg-dash : surround passthrough
Html5 players tested with live surround:
	 videojs, mediaelement, viblast (hls+dash), hls.js
Decklink: on win32, swap channels order for 5.1 7.1
         (due to different channel mapping on wav, mpeg, ffmpeg)
Audio filters: surround working.
Monitoring: surround working (win macOs linux (pulse-audio)).
VST:	 stereo plugins keep in general only the first two channels.
	 surround plugins should work (e.g. mcfx does).
OS: win, macOs, linux (alsa, pulse-audio).
Misc: larger audio bitrates unlocked to accommodate more channels
NB: mf-aac only supports mono and stereo + 5.1 on win 10
         (not implemented due to lack of usefulness)

Closes jp9000/obs-studio#968
2017-11-26 03:41:53 -08:00
jp9000
b54f70ef8d libobs: Add async video/audio decoupling functions
Decoupling the audio from the video causes the audio to be played right
when it's received rather than attempt to sync up to the video frames.
This is useful with certain async sources/devices when the audio/video
timestamps are not reliable.

Naturally because it plays audio right when it's received, this should
only be used when the async source is operating in unbuffered mode,
otherwise the video frame timing will be out of sync by the amount of
buffering the video currently has.
2017-10-10 06:45:34 -07:00
Shaolin
b6042d91ea libobs: Add Pulseaudio audio monitoring support
Checks if the system has Pulseaudio and enables support via the
HAVE_PULSEAUDIO flag.

Closes jp9000/obs-studio#940
2017-09-12 03:37:54 -07:00
Richard Stanway
9e95b2eb6f
Various: Don't use boolean bitfields
Using bitfields causes less optimized code generation and the memory
savings are minimal as none of the objects are instantiated enough
times to be worth it.

See https://blogs.msdn.microsoft.com/oldnewthing/20081126-00/?p=20073
2017-05-10 23:28:46 +02:00
Shaolin
e006d961a4 audio-monitoring: Add ability to monitor Outputs
(Note: This commits also modifies the linux-pulseaudio, mac-capture, and
win-wasapi plugins)

Do not prevent the targeted output device from being monitored if the
selected monitor output device is a different one.

Closes jp9000/obs-studio#872
2017-04-05 18:58:08 -07:00
jp9000
65ffb8800c libobs: Apply sync offset to win32 audio monitoring 2017-03-05 14:29:59 -08:00
jp9000
528325578f libobs: Fix audio monitoring delaying perpetually
On windows, when a source has only audio (no video) yet is marked as
capable of both video and audio, it would be programmed to expect a
video frame to synchronize with.  This fixes that potential issue by
detecting whether any video is actually playing or not.
2017-02-21 10:59:02 -08:00
jp9000
d2934eca7e libobs: Implement audio monitoring
Adds functions to turn on audio monitoring to allow the user to hear
playback of an audio source over the user's speaker.  It can be set to
turn off monitoring and only output to stream, or it can be set to
output only to monitoring, or it can be set to both.

On windows, audio monitoring uses WASAPI.  Windows also is capable of
syncing the audio to the video according to when the video frame itself
was played.

On mac, it uses AudioQueue.

On linux, it's not currently implemented and won't do anything (to be
implemented).
2017-02-06 11:44:02 -08:00