0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00
mpv/audio
Li Chang 39f7f83351 ao_coreaudio: use AudioUnitReset as ao_driver.reset to prevent long restart
[motivation]
Seeking on MacOS appears to be lagged when users connect
to wireless audio output (airpods for example).

This commit attempts to fix mpv-player/mpv#10270

[observation]
1. When using other media player (VLC to be exact) simultaneously,
the lagging on seek disappear. We could guess that the AudioDevice
is on some sort of "warm-up" state.

See mpv-player/mpv#9243 for detailed description.

2. `AudioOutputUnitStart` takes significant longer time after each seek
or pause/play when using wireless output devices compares to wired devices.

[rationale]
After investigate codes in ao_coreaudio.c, it appears that the the `stop`
function was used as `ao_driver.reset` function. Therefore every seek
and pause would call `AudioOutputUnitStop`.

It turns out that `ao_driver.reset` function is used in `ao_reset`.
And `ao_reset` function is used to clean up the state of current `ao`
so I think `AudioUnitReset` is more proper than `AudioOutputUnitStop`
under this semantics.

Since ao_coreaudio use pull base mechanism, audio playback behaviors
upon pause/seek could be handled by callback function
(streaming silence when paused) so there is no need to stop AudioUnit when resetting.
Therefore using `AudioUnitReset` as `ao_driver.reset` looks proper.

Additionally, after using proper reset, the AudioUnit that represents
hardware I/O devices doesn't need to be restart everytime seek/pause actions happen.
Restarting wireless devices simply takes longer in MacOS which is
the root cause of lagging observed by users when they seek or pause/play media.

[method]
Use `AudioUnitReset` for ao_driver.reset.
2023-01-02 19:45:54 +01:00
..
decode ffmpeg: update to handle deprecation of av_init_packet 2022-12-03 14:44:18 -08:00
filter af_scaletempo2: fix crash when the number of channels increases 2022-09-23 18:15:00 +02:00
out ao_coreaudio: use AudioUnitReset as ao_driver.reset to prevent long restart 2023-01-02 19:45:54 +01:00
aframe.c ad_lavc: strip non-normalized floats 2022-09-02 01:27:31 +02:00
aframe.h ad_lavc: strip non-normalized floats 2022-09-02 01:27:31 +02:00
chmap_avchannel.c audio: add AVChannelLayout helpers to convert from/to mp_chmap 2022-06-12 21:05:59 +03:00
chmap_avchannel.h audio: add AVChannelLayout helpers to convert from/to mp_chmap 2022-06-12 21:05:59 +03:00
chmap_sel.c audio: use --audio-channels=auto behavior, except on ALSA 2016-08-04 20:49:20 +02:00
chmap_sel.h audio: use --audio-channels=auto behavior, except on ALSA 2016-08-04 20:49:20 +02:00
chmap.c audio/chmap: add mp_iterate_builtin_layouts 2022-06-15 21:19:10 +03:00
chmap.h audio/chmap: add mp_iterate_builtin_layouts 2022-06-15 21:19:10 +03:00
fmt-conversion.c audio: add support for AV_SAMPLE_FMT_S64* 2019-09-27 21:21:34 +02:00
fmt-conversion.h audio/fmt-conversion: change license to LGPL 2017-05-05 07:25:55 +02:00
format.c audio/format: fix Type 'struct entry' has incompatible definitions in different translation units 2022-10-23 14:57:24 +02:00
format.h audio: add support for AV_SAMPLE_FMT_S64* 2019-09-27 21:21:34 +02:00