| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As far as I can tell PulseAudio introduced a bug in 16.0
where if a stream is (un)paused too often the reported latency
will momentarily spike by 3000% or more. Apparently in certain cases
just pausing once and waiting can also cause this.
Save the remaining users of PA the trouble of debugging the various
obscure issues that can arise from this (desync is a harmless example)
by enabling the latency hack code again.
ref: <https://github.com/mpv-player/mpv/issues/12057>
<https://github.com/mpv-player/mpv/issues/10333>
|
| |
|
| |
|
|
|
|
| |
warning: `static' is not at beginning of declaration
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 39f7f83 changed ao_driver.reset to use AudioUnitReset instead of
AudioOutputUnitStop. The problem with calling AudioOutputUnitStop was
that AudioOutputUnitStart takes a significant amount of time after a
stop when a wireless audio device is being used. This resulted in
lagging that was noticeable to users during seeking and short
pause/resume cycles. Switching to AudioUnitReset eliminated this
lagging.
However with the switch to AudioUnitReset the macOS daemon coreaudiod
continued to consume CPU time and did not release a powerd assertion
that it created on behalf of mpv, preventing macOS from sleeping.
This commit will change ao_coreaudio.reset to call AudioOutputUnitStop
after a delay if playback has not resumed. This preserves the faster
restart of playback for seeking and short pause/resume cycles and avoids
preventing sleep and needless CPU consumption.
Fixes #11617
The code changes were authored by @orion1vi and @lhc70000.
Co-authored-by: Collider LI <lhc199652@gmail.com>
|
|
|
|
|
| |
'name' was in fact unused when reading fields or methods, so it can be merged with 'method'.
Also changed the type of 'mandatory' to bool.
|
| |
|
|
|
|
|
|
| |
- split mapping from field struct
- mark field struct static
- define list of classes to reduce more repetitive code
|
| |
|
| |
|
|
|
|
|
| |
rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to
make naming consistent.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, the softvol gain control attempts to clip floating point ao
formats within -1 and +1. However, this is "optimized out" at unity gain,
where no clipping is applied. This results in inconsistent behavior when
the source audio is already out of -1 and +1 range, where a gain of 0.99
results in clipping, but not at exactly 1.
Since a big advantage of floating point audio data is that they do not
lose information through out-of-range data because the ao sink can apply
suitable negative gain to prevent clipping before converting them to
integer formats, clipping should not be performed on these data.
Fix this by removing the existing clipping behavior. It now results in
a simple multiplication, which faciliates compiler auto-vectorization
of this operation over audio data.
|
|
|
|
| |
This was done for `AOCONTROL_SET_VOLUME` but not `AOCONTROL_GET_VOLUME`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, running AO control wakes up the WASAPI renderer thread in the
`WASAPI_THREAD_FEED` state, where `thread_feed` will be called. However,
it seems that in recent Windows versions (tested on Windows 10 build
19044.3930 and Windows 11 build 22631.3007) we can't know if it is safe
to feed more audio data in event-driven exclusive mode:
- `IAudioClient_GetCurrentPadding` always returns `bufferFrameCount`,
even if *NO* data has ever been written. This means we don't know how
much free space we have that is available for writing. This is not the
case in shared mode, where the return value correctly reflects the
size of data waiting to be processed. As a sidenote, MS did not
document the precise definition of the return value for an
event-driven, exclusive stream [1].
- `IAudioRenderClient_GetBuffer` never fails. We can call it for 10
times in a roll, each time requesting an entire buffer (the unit at
which data is exchanged in exclusive mode using event-driven
buffering; there are 2 such buffers) and get a successful return code
everytime. In shared mode, we get `AUDCLNT_E_BUFFER_TOO_LARGE` if we
request a buffer larger than that currently available.
As a result, `thread_feed` will always write `bufferFrameCount` frames
of audio in exclusive mode. There will therefore be glitches each time
`thread_control` is called due to the subsequent `thread_feed`
overwriting frames yet to be processed. Also, an irreversible error is
accumulated to `sample_count` as long as there is no AO reset, leading
to eventual, unbounded A/V desync.
As a fix to the issue, add a dedicated state for dispatch queue
processing so that `thread_feed` is only called when signaled by the OS.
The buffer checks in `thread_feed` that use `GetCurrentPadding` in
exclusive mode are kept in case there are older versions where the two
APIs behave differently.
Closes #12615.
[1] https://learn.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclient-iaudioclient-getcurrentpadding
|
|
|
|
|
| |
change all mentions and variations of OSX, OS X, MacOSX, MacOS X, etc
consistent. use the official naming macOS.
|
| |
|
|
|
|
|
|
| |
Interpreting data in the wrong sample format has unpredictable results
and may damage hardware and hurt users.
Instead error out.
|
| |
|
|
|
|
|
|
|
|
|
| |
As mentioned in [0] the suffix "_locked" would have been the appropriate
naming in line with similar uses inside mpv.
See `mp_abort_recheck_locked()`, `mp_abort_trigger_locked()`,
`retrigger_locked()`, `wakeup_locked()`...
[0] https://github.com/mpv-player/mpv/pull/12811#discussion_r1477518525
|
|
|
|
|
|
|
|
| |
Stopping output implies that it can't be paused anymore.
This is consistent with the documented API in internal.h as well
as the behavior of other AOs.
resolves #13267
|
|
|
|
|
|
|
|
| |
In commit c09245cdf2491211f3e0bfe47f28cc0e0a2e05c8
long-path support was enabled for mpv without actually
making sure that there was no code left that used the
old limit (260 Unicode chars) for buffer sizes.
This commit fixes all but one case.
|
|
|
|
|
| |
Add ifndefs to define only when needed and remove some already defined
ones in mingw.
|
|
|
|
|
|
|
| |
While CEA-861 defines MP2 as 0x5 and MP3 as 0x4, the GUIDs defined in
ksmedia.h are in reverse order.
See: https://github.com/MicrosoftDocs/windows-driver-docs/pull/3742
|
| |
|
|
|
|
|
|
|
|
| |
- Don't define _GNU_SOURCE on Windows, no need
- Define WIN32_LEAN_AND_MEAN to strip some unneded headers from
windows.h
- Define NOMINMAX and _USE_MATH_DEFINES as they are common for Windows
headers
|
| |
|
|
|
|
|
|
| |
We prefer to fail fast rather than degrade in unpredictable ways.
The example in sub/ is particularly egregious because the code just
skips the work it's meant to do when an allocation fails.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PR #12747 missed updating a variable declaration in
`ca_change_physical_format_sync`, which ultimately leads to the thread
crashing. The problem reproduces consistently on AS Macs (I don't have
an Intel Mac to test on anymore), and produces stack traces like the
following:
```
Thread 3 Crashed:: mpv
0 libsystem_kernel.dylib 0x18cebd11c __pthread_kill + 8
1 libsystem_pthread.dylib 0x18cef4cc0 pthread_kill + 288
2 libsystem_c.dylib 0x18ce04ad4 __abort + 136
3 libsystem_c.dylib 0x18cdf56c4 __stack_chk_fail + 96
4 mpv 0x1026b66d0 ca_change_physical_format_sync + 420
5 mpv 0x1026b3b70 init + 1052
6 mpv 0x1025c5afc ao_init + 332
7 mpv 0x1025c5bec ao_init + 572
8 mpv 0x1025c5830 ao_init_best + 1228
9 mpv 0x102622fac fill_audio_out_buffers + 1820
10 mpv 0x1026450d0 run_playloop + 132
11 mpv 0x10263f958 play_current_file + 5116
12 mpv 0x10263e4e8 mp_play_files + 452
13 mpv 0x102641308 mpv_main + 128
14 mpv 0x10269f520 playback_thread + 40
15 libsystem_pthread.dylib 0x18cef5034 _pthread_start + 136
16 libsystem_pthread.dylib 0x18ceefe3c thread_start + 8
```
Note that non-exclusive output seems to be unaffected. To reproduce
this problem (and/or test this fix), pass `--audio-exclusive=yes` to
mpv.
|
| |
|
|
|
|
|
|
| |
Fixes busy wait, because in practice inf would be casted to 0.
Fixes: 174df99
|
|
|
|
|
| |
Not all callers of read_buffer() require the buffer to be padded with
silence.
|
| |
|
| |
|
|
|
|
| |
Avoid blocking the process callback as it runs with realtime privileges.
|
|
|
|
|
| |
This behaves similar to ao_read_data() but does not block and may return
partial data.
|
| |
|
|
|
|
|
| |
Change the resulting buffer sizes to match the actual amount of samples
read, and set a flag in case no samples were read at all.
|
|
|
|
|
|
|
|
| |
I'd like some names to be more descriptive, but to work with 15 chars
limit we have to make some sacrifice.
Also because of the limit, remove the `mpv/` prefix and prioritize
actuall thread name.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
It was found that this causes issues with at least ao_coreaudio,
essentially revealing a way bigger issue:
Some AOs don't check for 0 and/or have no way to deal with short writes.
Someone will have to figure out a fix later but get rid of the direct
cause for now.
This reverts commit ae908a70cecebb2cac8354a3b4d8967af847bd3e.
|
|
|
|
|
|
|
| |
ao_read_data() is used by pull AOs potentially from threads managed by
external libraries. These threads can be sensitive to blocking.
For example the pipewire ao is using a realtime thread for the
callbacks.
|
|
|
|
|
|
|
|
|
|
|
|
| |
since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.
some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.
hopefully nothing breaks. if it does, the style guide is to blame.
|
|
|
|
|
|
|
| |
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.
also add missing config.h includes on some files.
|
|
|
|
|
|
|
| |
Pull AOs work off of a callback that relies on mpv's internal timer. So
like with the related video changes, convert all of these to nanoseconds
instead. In many cases, the underlying audio API does actually provide
nanosecond resolution as well.
|
|
|
|
|
|
|
| |
There's a lot of wild 1e6, 1000, etc. lying around in the code. A macro
is much easier to read and understand at a glance. Add some helpers for
this. We don't need to convert everything now but there's some simple
things that can be done so they are included in this commit.
|
|
|
|
|
|
|
|
|
|
|
| |
Linux and macOS already use nanosecond resolution for their sleep
functions. It was just being converted from microseconds before. Since
we have mp_time_ns now, go ahead and bump the precision here. The timer
for windows uses some timeBeginPeriod thing which I'm not sure what it
does really but whatever just convert the units to ms like they were
doing before. There's really no reason to keep the mp_sleep_us helper
around. A multiplication by 1000 is trivial and underlying OS clocks
have nanosecond precision.
|
|
|
|
|
| |
Those changes will alow to change vsync base to more precise time base.
In general there is no reason to truncate values returned by system.
|
| |
|
|
|
|
|
|
| |
This is the most supported in standard layout, if we request more it
tends to fallback to stereo instead. Also channels mask is 32-bit and it
can get truncated.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the
options still possibly do something but they have a deprecation
message. Most of these are old and have no real usage. The only
potentially controversial ones are the removal of --oaffset and
--ovoffset which were deprecated years ago and seemingly have no real
replacement. There's a cryptic message about --audio-delay but who
knows. The less encoding mode code we have, the better so just chuck
it.
|
|
|
|
|
|
|
| |
This is why you don't merge three year old contributions
without checking that they're even applicable anymore.
This reverts commit 5a94c86029a2d0e5452c07a7c12d2a6981f607df.
|
|
|
|
|
|
|
|
| |
The idea behind period_size is that it's the minimum amount of data
that your audio subsystem wants to fetch.
For PulseAudio, this is given by the minreq buffer attribute, which
is in bytes for all channels. Hence the divisions.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change sets the device_buffer member of the ao struct for
the JACK ao to whatever value we read during init.
While JACK allows changing the audio buffer size on-the-fly
(you can do this for example through DBus), having it somehow
reconfigure the entire audio buffer logic of mpv that depends
on device_buffer in some way when that happens only leads to
audio dropout and weird code. device_buffer's role is mostly for
prebuffer from what I understand, which means that simply setting
it to its current value in the init function is fine.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Atmos, DTS-HD, etc.) over HDMI
In addition to the patch, appropriate additions to the mpv.conf file
will of course be needed for this to work. For example on my system:
audio-device=oss//dev/dsp4
audio-spdif=ac3,dts,dts-hd,eac3,truehd
This has been tested using recent FreeBSD-13.1-stable, using external
surround processors (both a Trinnov Altitude 16 and an LG OLED that
supports Dolby Atmos, and connected with HDMI to an NVidia RTX 2070).
Author and tester: David G Lawrence <dg1007@dglawrence.com>
|
|
|
|
|
|
|
|
|
| |
There's an edge cause with gapless audio and pausing. Since, gapless
audio works by sending an EOF immediately, it's possible to pause on the
next file before audio actually finishes playing and thus the sound gets
cut off. The fix is to simply just always do an ao_drain if the ao is
about to set a pause on EOF and we still have audio playing.
Fixes #8898.
|
|
|
|
| |
Since recent commits this should work 100% as well as s16.
|
| |
|
|
|
|
| |
maybe this is good for something, who knows
|
|
|
|
|
|
|
|
| |
The difference this makes is that the OS API will notice
when we underrun (as opposed to being fed silence).
Other AOs mostly seem to not do this because they've committed
to filling a buffer of a certain size no matter what, but I have
not observed any ill effects for AudioTrack in my testing.
|
| |
|
|
|
|
|
|
| |
This looks like a pretty bad bug but only became a problem
with the last commit that allows rates like 22.5kHz to pass through
directly instead of being resampled.
|
|
|
|
|
| |
Resampling when the driver says it isn't outputting more than
a certain rate anyway makes sense, the inverse does not.
|