mirror of https://github.com/mpv-player/mpv
f974382ca0
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`. |
||
---|---|---|
.. | ||
ao.c | ||
ao.h | ||
ao_alsa.c | ||
ao_audiotrack.c | ||
ao_audiounit.m | ||
ao_avfoundation.m | ||
ao_coreaudio.c | ||
ao_coreaudio_chmap.c | ||
ao_coreaudio_chmap.h | ||
ao_coreaudio_exclusive.c | ||
ao_coreaudio_properties.c | ||
ao_coreaudio_properties.h | ||
ao_coreaudio_utils.c | ||
ao_coreaudio_utils.h | ||
ao_jack.c | ||
ao_lavc.c | ||
ao_null.c | ||
ao_openal.c | ||
ao_opensles.c | ||
ao_oss.c | ||
ao_pcm.c | ||
ao_pipewire.c | ||
ao_pulse.c | ||
ao_sdl.c | ||
ao_sndio.c | ||
ao_wasapi.c | ||
ao_wasapi.h | ||
ao_wasapi_changenotify.c | ||
ao_wasapi_utils.c | ||
buffer.c | ||
internal.h |