mpv/audio/out
nanahi 51e01e9772 ao_wasapi: fix player core lockup when avoiding premature buffer fills
6863eefc3d handled this situation by using
an atomic variable to express the state for which the wakeup is caused
by AO control, and the dispatch queue is only processed at this state.
However, this can cause permanent lockup of the player core when the
following happens:

- AO control sets the thread state to WASAPI_THREAD_DISPATCH, and
  sets the wakeup handle.
- WASAPI thread reads the WASAPI_THREAD_DISPATCH state and processes
  the dispatch queue.
- Another AO control happens. A dispatch item is enqueued, and the
  state stays at WASAPI_THREAD_DISPATCH.
- WASAPI thread resets the thread state to WASAPI_THREAD_FEED since
  the state has not changed.
- WaitForSingleObject() returns in the WASAPI thread, sees this state,
  and does not process the dispatch queue.
- The player core locks permanently because it is waiting for the dispatch
  to be processed.

This has been experimentally verified on a system under high contention:
The easiest way to trigger this lockup is to continuously hold down "i",
which rapidly issues AO get volume/mute controls.

To properly handle this, use separate handles for system and user wakeup
requests. Only feed audio when woke up by system and only process the
dispatch queue when woke up by user.

Fixes: 6863eefc3d
2024-04-27 00:59:09 +02:00
..
ao.c ao_avfoundation: initial avfoundation ao support 2024-03-29 13:46:59 +01:00
ao.h audio: drain ao before setting pause 2023-08-11 22:28:50 +00:00
ao_alsa.c ao_alsa: fix snd_config memory leak 2024-03-30 10:09:37 +01:00
ao_audiotrack.c ao: rename playthread to ao_thread 2024-04-10 19:00:22 +02:00
ao_audiounit.m ao: convert all timing code to nanoseconds 2023-10-16 15:38:59 +00:00
ao_avfoundation.m ao_avfoundation: support set_pause 2024-04-03 23:40:05 +02:00
ao_coreaudio.c ao_coreaudio: add a comment for ignoring returned sample count 2024-04-20 00:12:16 +02:00
ao_coreaudio_chmap.c ao/avfoundation: optimise preprocessors for included coreaudio code 2024-04-20 00:44:46 +02:00
ao_coreaudio_chmap.h ao/avfoundation: optimise preprocessors for included coreaudio code 2024-04-20 00:44:46 +02:00
ao_coreaudio_exclusive.c various: use static assertions where appropriate 2024-03-17 20:04:04 +01:00
ao_coreaudio_properties.c various: fix typos 2022-04-25 09:07:18 -04:00
ao_coreaudio_properties.h ao/avfoundation: optimise preprocessors for included coreaudio code 2024-04-20 00:44:46 +02:00
ao_coreaudio_utils.c ao/avfoundation: optimise preprocessors for included coreaudio code 2024-04-20 00:44:46 +02:00
ao_coreaudio_utils.h ao/avfoundation: optimise preprocessors for included coreaudio code 2024-04-20 00:44:46 +02:00
ao_jack.c various: sort some standard headers 2023-10-20 21:31:09 +02:00
ao_lavc.c ao_lavc: fix warning: ISO C forbids forward references to 'enum' types 2024-03-19 08:58:18 +01:00
ao_null.c ao_null: fix reset() implementation 2024-01-12 20:36:04 +01:00
ao_openal.c options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
ao_opensles.c ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
ao_oss.c various: use thread safe mp_strerror() 2024-03-19 19:30:27 +01:00
ao_pcm.c options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
ao_pipewire.c ao_pipewire: fix delay calculation 2024-04-05 17:22:17 +02:00
ao_pulse.c ao: rename playthread to ao_thread 2024-04-10 19:00:22 +02:00
ao_sdl.c ao: convert all timing code to nanoseconds 2023-10-16 15:38:59 +00:00
ao_sndio.c ao: rename playthread to ao_thread 2024-04-10 19:00:22 +02:00
ao_wasapi.c ao_wasapi: fix player core lockup when avoiding premature buffer fills 2024-04-27 00:59:09 +02:00
ao_wasapi.h ao_wasapi: fix player core lockup when avoiding premature buffer fills 2024-04-27 00:59:09 +02: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: set 0 buffer duration on initialization for shared mode 2024-04-19 02:28:23 +02:00
buffer.c ao: rename playthread to ao_thread 2024-04-10 19:00:22 +02:00
internal.h ao: rename playthread to ao_thread 2024-04-10 19:00:22 +02:00