mpv/audio/out
Misaki Kasumi f974382ca0 ao_pipewire: fix delay calculation
A figure from pipewire documentation:

```
           stream time domain           graph time domain
         /-----------------------\/-----------------------------\

 queue     +-+ +-+  +-----------+                 +--------+
 ---->     | | | |->| converter | ->   graph  ->  | kernel | -> speaker
 <----     +-+ +-+  +-----------+                 +--------+
 dequeue   buffers                \-------------------/\--------/
                                     graph              internal
                                    latency             latency
         \--------/\-------------/\-----------------------------/
           queued      buffered            delay
```

We calculate `end_time` in the following steps:

1. get current timestamp in mpv
```
int64_t end_time = mp_time_ns();
```

2. add duration of samples to enqueue
```
end_time += MP_TIME_S_TO_NS(nframes) / ao->samplerate;
```

3. add delay of the pipewire graph
```
end_time += MP_TIME_S_TO_NS(time.delay) * time.rate.num / time.rate.denom;
```

4. add duration of queued and buffered samples.
```
end_time += MP_TIME_S_TO_NS(time.queued) / ao->samplerate;
end_time += MP_TIME_S_TO_NS(time.buffered) / ao->samplerate;
```
New in this commit. `time.queued` is usually zero as `SPA_PARAM_BUFFERS_buffers`
is default to 1; however it is not always.
`time.buffered` is non-zero if there is a resampler involved.

5. add elapsed duration from when `time` is captured
```
end_time -= pw_stream_get_nsec(p->stream) - time.now;
```
New in this commit. `time` is captured at `time.now`.
From then, time has passed so we need to exclude the elapsed time,
by calculating the diff of `pw_stream_get_nsec()` and `time.now`.
2024-04-05 17:22:17 +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 various: fix -Wold-style-declaration warning 2024-03-19 08:58:18 +01: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: register hotplug_cb in normal init() as well 2024-04-03 23:43:24 +02:00
ao_coreaudio_chmap.c ao_avfoundation: initial avfoundation ao support 2024-03-29 13:46:59 +01:00
ao_coreaudio_chmap.h ao_avfoundation: initial avfoundation ao support 2024-03-29 13:46:59 +01:00
ao_coreaudio_exclusive.c various: use static assertions where appropriate 2024-03-17 20:04:04 +01:00
ao_coreaudio_properties.c
ao_coreaudio_properties.h ao_avfoundation: initial avfoundation ao support 2024-03-29 13:46:59 +01:00
ao_coreaudio_utils.c ao_avfoundation: initial avfoundation ao support 2024-03-29 13:46:59 +01:00
ao_coreaudio_utils.h ao_avfoundation: initial avfoundation ao support 2024-03-29 13:46:59 +01: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_pulse: reenable latency hacks by default 2024-03-24 09:58:41 +01:00
ao_sdl.c ao: convert all timing code to nanoseconds 2023-10-16 15:38:59 +00:00
ao_sndio.c ao_sndio: add missing config.h include 2024-02-07 14:44:52 +00:00
ao_wasapi.c ao_wasapi: support set_pause 2024-04-03 23:40:05 +02:00
ao_wasapi.h ao_wasapi: support set_pause 2024-04-03 23:40:05 +02:00
ao_wasapi_changenotify.c
ao_wasapi_utils.c various: use correct PATH_MAX for win32 2023-12-27 22:55:56 +01:00
buffer.c ao: set_pause for pull based ao 2024-04-03 23:40:05 +02:00
internal.h ao: set_pause for pull based ao 2024-04-03 23:40:05 +02:00