1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00
mpv/audio/out
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
..
ao_alsa.c ao_alsa: handle -EPIPE XRUNs from snd_pcm_status 2020-11-09 16:12:49 +01:00
ao_audiotrack.c ao_audiotrack: change buffer sizing logic 2021-10-21 17:20:51 +02:00
ao_audiounit.m Revert "ao/audiounit: include AVAudioSession buffer in latency calc" 2022-11-07 18:45:55 +02:00
ao_coreaudio_chmap.c audio/out: add AudioUnit output driver for iOS 2016-11-01 16:25:40 +01:00
ao_coreaudio_chmap.h audio/out: add AudioUnit output driver for iOS 2016-11-01 16:25:40 +01:00
ao_coreaudio_exclusive.c audio: redo internal AO API 2020-06-01 01:08:16 +02:00
ao_coreaudio_properties.c various: fix typos 2022-04-25 09:07:18 -04:00
ao_coreaudio_properties.h ao_coreaudio: change license to LGPL 2017-05-08 13:57:40 +02:00
ao_coreaudio_utils.c ao_coreaudio: use device's nominal sample rate for latency properties 2022-12-10 18:15:46 +02:00
ao_coreaudio_utils.h ao_coreaudio: specify UTF-8 as text encoding for CFString conversions 2022-10-29 00:00:09 +03:00
ao_coreaudio.c ao_coreaudio: use AudioUnitReset as ao_driver.reset to prevent long restart 2023-01-02 19:45:54 +01:00
ao_jack.c audio: redo internal AO API 2020-06-01 01:08:16 +02:00
ao_lavc.c ao_lavc: switch to AVChannelLayout when available 2022-06-12 21:05:59 +03:00
ao_null.c audio: fix inefficient behavior with ao_alsa, remove period_size field 2020-08-29 16:27:56 +02:00
ao_openal.c ao_openal: enable AL_SOFT_direct_channels_remix extension by default 2021-11-29 11:27:39 +01:00
ao_opensles.c ao_opensles: add guards for sample rate to use 2021-11-19 14:27:52 +01:00
ao_oss.c ao_oss: define PATH_DEV_MIXER as it is an internal define 2021-11-10 17:08:16 +01:00
ao_pcm.c audio: redo internal AO API 2020-06-01 01:08:16 +02:00
ao_pipewire.c Revert "ao_pipewire: deactivate stream at end of playback" 2022-12-19 15:54:42 -08:00
ao_pulse.c ao/pulse: fix incorrect state reported after reset 2021-04-29 17:06:29 +02:00
ao_sdl.c audio: redo internal AO API 2020-06-01 01:08:16 +02:00
ao_sndio.c various: remove trailing whitespace 2022-05-14 14:51:34 +00:00
ao_wasapi_changenotify.c ao_wasapi_changenotify: use %ls instead of %S for wchar_t 2017-04-20 07:38:03 +02:00
ao_wasapi_utils.c ao_wasapi: try mix format except for chmap 2020-03-19 20:39:44 +02:00
ao_wasapi.c audio: redo internal AO API 2020-06-01 01:08:16 +02:00
ao_wasapi.h ao_wasapi: reorganize wasapi.h 2017-08-07 14:33:03 -07:00
ao.c ao: promote ao_pipewire 2022-10-24 11:09:34 -07:00
ao.h audio: try to use playback AO as hotplug AO first 2022-09-11 20:24:42 -07:00
buffer.c audio: reset pull AO at end of file 2022-12-22 15:14:08 -08:00
internal.h ao: remove unused field 2020-08-31 20:23:44 +02:00