1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-04 21:27:58 +00:00
mpv/audio/out
wm4 b83bdd1d17 audio: merge pull/push ring buffer glue code
This is preparation to further cleanups (and eventually actual
improvements) of the audio output code.

AOs are split into two classes: pull and push. Pull AOs let an audio
callback of the native audio API read from a ring buffer. Push AOs
expose a function that works similar to write(), and for which we start
a "feeder" thread. It seems making this split was beneficial, because of
the different data flow, and emulating the one or other in the AOs
directly would have created code duplication (all the "pull" AOs had
their own ring buffer implementation before it was cleaned up).
Unfortunately, both types had completely separate implementations (in
pull.c and push.c). The idea was that little can be shared anyway. But
that's very annoying now, because I want to change the API between AO
and player.

This commit attempts to merge them. I've moved everything from push.c to
pull.c, the trivial entrypoints from ao.c to pull.c, and attempted to
reconcile the differences. It's a mess, but at least there's only one
ring buffer within the AO code now. Everything should work mostly the
same. Pull AOs now always copy the audio data under a lock; before this
commit, all ring buffer access was lock-free (except for the decoder
wakeup callback, which acquired a mutex). In theory, this is "bad", and
people obsessed with lock-free stuff will hate me, but in practice
probably won't matter. The planned change will probably remove this
copying-under-lock again, but who knows when this will happen.

One change for the push AOs now makes it drop audio, where before only a
warning was logged. This is only in case of AOs or drivers which exhibit
unexpected (and now unsupported) behavior.

This is a risky change. Although it's completely trivial conceptually,
there are too many special cases. In addition, I barely tested it, and
I've messed with it in a half-motivated state over a longer time, barely
making any progress, and finishing it under a rush when I already should
have been asleep. Most things seem to work, and I made superficial tests
with alsa, sdl, and encode mode. This should cover most things, but
there are a lot of tricky things that received no coverage. All this
text means you should be prepared to roll back to an older commit and
report your problem.
2020-05-25 01:54:37 +02:00
..
ao_alsa.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_audiotrack.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_audiounit.m ao/audiounit: include AVAudioSession buffer in latency calc 2019-04-05 10:29:44 +07:00
ao_coreaudio_chmap.c
ao_coreaudio_chmap.h
ao_coreaudio_exclusive.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_coreaudio_properties.c ao_coreaudio: change license to LGPL 2017-05-08 13:57:40 +02:00
ao_coreaudio_properties.h ao_coreaudio: change license to LGPL 2017-05-08 13:57:40 +02:00
ao_coreaudio_utils.c ao/audiounit: improve a/v sync 2019-04-05 10:29:44 +07:00
ao_coreaudio_utils.h ao/audiounit: improve a/v sync 2019-04-05 10:29:44 +07:00
ao_coreaudio.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_jack.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_lavc.c encode: fix occasional init crash due to initialization order issues 2020-03-22 21:08:44 +01:00
ao_null.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_openal.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_opensles.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_pcm.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_pulse.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
ao_sdl.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01: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/out: rip out old unused app/softvolume reporting 2019-10-11 21:05:11 +02:00
ao_wasapi.h ao_wasapi: reorganize wasapi.h 2017-08-07 14:33:03 -07:00
ao.c audio: merge pull/push ring buffer glue code 2020-05-25 01:54:37 +02:00
ao.h player: consider audio buffer if AO driver does not report underruns 2020-02-13 01:32:58 +01:00
buffer.c audio: merge pull/push ring buffer glue code 2020-05-25 01:54:37 +02:00
internal.h audio: merge pull/push ring buffer glue code 2020-05-25 01:54:37 +02:00