1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-22 07:46:55 +00:00
mpv/audio/out
wm4 e440352313 audio/out/pull: avoid deadlock if audio callback stops
If the audio callback suddenly stops, and the AO provides no "reset"
callback, then reset() could deadlock by waiting on the audio callback
forever.

The waiting was needed to enter a consistent state, where the audio
callback guarantees it won't access the ringbuffer. This in turn is
needed because mp_ring_reset() is not concurrency-safe.

This active waiting is unavoidable. But the way it was implemented, the
audio callback had to call ao_read_data() at least once when reset() is
called. Fix this by making ao_read_data() set a flag upon entering and
leaving, which basically turns p->state into some sort of spinlock.

The audio callback actually never needs to spin, because there are only
2 states: playing audio, or playing silence. This might be a bit
surprising, because usually atomic_compare_exchange_strong() requires a
retry-loop idiom for correct operation.

This commit is needed because ao_wasapi can (or will in the future)
randomly stop the audio callback in certain corner cases. Then the
player would hang forever in reset().
2014-11-09 15:23:40 +01:00
..
ao_alsa.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_coreaudio_exclusive.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_coreaudio_properties.c ao_coreaudio: move to new log API 2013-08-01 20:32:49 +02:00
ao_coreaudio_properties.h ao_coreaudio: report hardware latency to ao_read_data 2014-07-03 20:05:15 +02:00
ao_coreaudio_utils.c coreaudio: only list output devices 2014-10-28 14:11:50 +01:00
ao_coreaudio_utils.h coreaudio: use the new device selection API 2014-10-12 12:22:17 +02:00
ao_coreaudio.c coreaudio: redirect IEC61937 to coreaudio_exclusive 2014-10-23 09:16:39 +02:00
ao_dsound.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_jack.c audio/out/pull: remove race conditions 2014-05-29 02:24:17 +02:00
ao_lavc.c Move compat/ and bstr/ directory contents somewhere else 2014-08-29 12:31:52 +02:00
ao_null.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_openal.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_oss.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_pcm.c audio: cleanup spdif format definitions 2014-09-23 23:11:54 +02:00
ao_portaudio.c ao_portaudio: implement device listing 2014-10-13 16:43:05 +02:00
ao_pulse.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_rsound.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_sdl.c Add some missing "const"s 2014-10-10 13:44:08 +02:00
ao_sndio.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
ao_wasapi_utils.c ao_wasapi: implement device listing 2014-10-13 18:21:45 +02:00
ao_wasapi_utils.h ao_wasapi: implement device listing 2014-10-13 18:21:45 +02:00
ao_wasapi.c ao_wasapi: implement device listing 2014-10-13 18:21:45 +02:00
ao_wasapi.h Move compat/ and bstr/ directory contents somewhere else 2014-08-29 12:31:52 +02:00
ao.c audio/out: make ao_request_reload() idempotent 2014-11-09 09:58:44 +01:00
ao.h audio/out: make ao_request_reload() idempotent 2014-11-09 09:58:44 +01:00
internal.h audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00
pull.c audio/out/pull: avoid deadlock if audio callback stops 2014-11-09 15:23:40 +01:00
push.c audio/out: consistently use double return type for get_delay 2014-11-09 11:45:04 +01:00