1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-04 09:11:33 +02:00
Go to file
Thomas Guillem 6c9f07a9ed pulse: calculate the start time from the last date played
stream_latency_cb() is needed to re-calculate the new derrered time (or start
late in the worst case scenario) when the audio device latency changes.

This callback called stream_start() with the first played system date. The
problem is that the delta calculated from stream_start was always late. Using
the last system date seems more logical. Indeed, the delta need to be
calculated from values using the same reference point (and vlc_pa_get_latency()
is calculated from the amount of buffers played).

This issue could be easily reproduced when the first played date was more than
100ms in the future, by using --audio-desync 100 for example.

This issue was not visible in most cases, because the deferred time is small by
default (10ms) and because the stream_latency_cb is often triggered after this
time.

Here are some logs to illustrate this (I added logs that print the played block
pts, the delay since the first play and when the stream_latency_cb is called).

 * Logs without this patch when running vlc with "--audio-desync 100":

Play @110959, first play since 0us
[0000617000008d50] pulse audio output warning: cannot synchronize start
[0000617000008d50] pulse audio output warning: deferring start (110903 us)
Play @142466, first play since 493us
[0000617000008d50] pulse audio output warning: deferring start (110460 us)
Play @174193, first play since 766us
[0000617000008d50] pulse audio output warning: deferring start (110188 us)
Play @205943, first play since 1016us
[0000617000008d50] pulse audio output warning: deferring start (109937 us)
Play @237698, first play since 1261us
[0000617000008d50] pulse audio output warning: deferring start (109692 us)
Play @269435, first play since 1524us
[0000617000008d50] pulse audio output warning: deferring start (109430 us)
Play @301150, first play since 1809us
[0000617000008d50] pulse audio output warning: deferring start (109144 us)
Play @332900, first play since 2059us
[0000617000008d50] pulse audio output warning: deferring start (108895 us)
Play @364648, first play since 2311us
[0000617000008d50] pulse audio output warning: deferring start (108643 us)
Play @396354, first play since 2605us
[0000617000008d50] pulse audio output warning: deferring start (108349 us)
Play @428076, first play since 2883us
[0000617000008d50] pulse audio output warning: deferring start (108069 us)
Play @459788, first play since 3171us
[0000617000008d50] pulse audio output warning: deferring start (107783 us)
Play @491531, first play since 3428us
[0000617000008d50] pulse audio output warning: deferring start (107526 us)
Play @523276, first play since 3683us
[0000617000008d50] pulse audio output warning: deferring start (107271 us)
Play @555026, first play since 3933us
[0000617000008d50] pulse audio output warning: deferring start (107020 us)
stream_latency_cb
[0000617000008d50] pulse audio output warning: starting late (-396346 us)
starting since: 27318
[0000617000008d50] pulse audio output warning: started
[0000617000008d50] main audio output warning: playback too early (-78075): down-sampling

 * Logs with this patch when running vlc with "--audio-desync 100":

Play @110978, first play since 0us
[000055e7c506d030] pulse audio output warning: cannot synchronize start
[000055e7c506d030] pulse audio output warning: deferring start (110952 us)
Play @142708, first play since 270us
[000055e7c506d030] pulse audio output warning: deferring start (110699 us)
Play @174601, first play since 377us
[000055e7c506d030] pulse audio output warning: deferring start (110597 us)
Play @206446, first play since 532us
[000055e7c506d030] pulse audio output warning: deferring start (110443 us)
Play @238302, first play since 676us
[000055e7c506d030] pulse audio output warning: deferring start (110298 us)
Play @270173, first play since 805us
[000055e7c506d030] pulse audio output warning: deferring start (110151 us)
Play @302008, first play since 970us
[000055e7c506d030] pulse audio output warning: deferring start (110005 us)
Play @333914, first play since 1064us
[000055e7c506d030] pulse audio output warning: deferring start (109911 us)
Play @365818, first play since 1160us
[000055e7c506d030] pulse audio output warning: deferring start (109814 us)
Play @397712, first play since 1266us
[000055e7c506d030] pulse audio output warning: deferring start (109708 us)
Play @429588, first play since 1390us
[000055e7c506d030] pulse audio output warning: deferring start (109584 us)
Play @461489, first play since 1489us
[000055e7c506d030] pulse audio output warning: deferring start (109485 us)
Play @493351, first play since 1627us
[000055e7c506d030] pulse audio output warning: deferring start (109347 us)
Play @525261, first play since 1717us
[000055e7c506d030] pulse audio output warning: deferring start (109257 us)
Play @557173, first play since 1805us
[000055e7c506d030] pulse audio output warning: deferring start (109169 us)
stream_latency_cb
[000055e7c506d030] pulse audio output warning: deferring start (74793 us)
Play @555762, first play since 35216us
[000055e7c506d030] pulse audio output warning: deferring start (75748 us)
Play @587642, first play since 35336us
[000055e7c506d030] pulse audio output warning: deferring start (75637 us)
Play @619520, first play since 35458us
[000055e7c506d030] pulse audio output warning: deferring start (75516 us)
Play @651428, first play since 35550us
[000055e7c506d030] pulse audio output warning: deferring start (75425 us)
Play @683305, first play since 35673us
[000055e7c506d030] pulse audio output warning: deferring start (75302 us)
Play @715187, first play since 35791us
[000055e7c506d030] pulse audio output warning: deferring start (75183 us)
Play @747067, first play since 35911us
[000055e7c506d030] pulse audio output warning: deferring start (75063 us)
Play @778930, first play since 36048us
[000055e7c506d030] pulse audio output warning: deferring start (74926 us)
stream_latency_cb
[000055e7c506d030] pulse audio output warning: deferring start (34708 us)
[000055e7c506d030] pulse audio output warning: starting deferred
starting since: 79393
[000055e7c506d030] pulse audio output warning: started

You can see, with this patch, that the resampler is not triggered anymore and
that the stream really start after 100ms (79393 + pulse latency).

In both case, audio and video have the same delay, but in the first case,
the core had to correct it (by playing silence or with the resampler).
2019-01-23 15:31:58 +01:00
autotools Fix .gitignore 2017-11-07 19:04:24 +02:00
bin remove the $Id$ in the source code 2019-01-17 12:21:18 +01:00
compat compat: remove qsort_r 2019-01-22 18:55:32 +01:00
contrib contrib: iconv: Rework the ANDROID_API check to not use bc 2019-01-23 11:05:16 +01:00
doc libvlc: rename libvlc_video_set_opengl_callbacks() to libvlc_video_set_output_callbacks() 2019-01-16 13:02:34 +01:00
extras contrib/extras: force uid/gid during tarball extractions 2019-01-14 10:16:59 +01:00
include medialibrary: Fix TOCTOU when accesing mrls 2019-01-23 11:05:16 +01:00
lib libvlc: return false if setting the vout callback fails 2019-01-18 11:10:24 +01:00
m4 m4: fix false negative working iconv test 2017-11-14 18:59:50 +02:00
modules pulse: calculate the start time from the last date played 2019-01-23 15:31:58 +01:00
po dlna: add a DLNA stream out 2019-01-10 17:14:00 +01:00
share youtube.lua: update live stream support to website changes 2019-01-19 03:07:38 +01:00
src player: fix invalid arguments when using OSD 2019-01-23 13:23:32 +01:00
test remove the $Id$ in the source code 2019-01-17 12:21:18 +01:00
.gitignore gitignore: Be more lax with the build folders 2015-10-09 14:19:25 +02:00
.mailmap mailmap: unify my addresses 2018-09-24 22:19:05 +03:00
AUTHORS AUTHORS: Add Doney den Ouden 2018-02-10 13:47:12 +01:00
bootstrap bootstrap: fail hard if flex or bison are missing and needed 2017-12-03 14:57:21 +02:00
configure.ac compat: remove qsort_r 2019-01-22 18:55:32 +01:00
COPYING COPYING.*: Use full versions of licenses. 2012-02-14 17:40:06 +04:00
COPYING.LIB COPYING.*: Use full versions of licenses. 2012-02-14 17:40:06 +04:00
INSTALL Update GCC version 2016-09-20 13:03:20 +03:00
make-alias Take program prefix and suffix into account in the make-alias script. 2008-05-26 00:11:33 +02:00
Makefile.am demux: add mock module 2018-10-18 13:12:22 +02:00
NEWS dlna: add a DLNA stream out 2019-01-10 17:14:00 +01:00
PLAYER_TODO.txt core: add player API 2018-11-15 17:09:32 +01:00
README README: Updated the links. 2018-02-03 16:48:31 +01:00
THANKS THANKS: Updated a few copyright dates 2017-02-01 22:02:59 +01:00

README for the VLC media player
===============================

VLC is a popular libre and open source media player and multimedia engine,
used by a large number of individuals, professionals, companies and
institutions. Using open source technologies and libraries, VLC has been
ported to most computing platforms, including GNU/Linux, Windows, Mac OS X,
BSD, iOS and Android.
VLC can play most multimedia files, discs, streams, allows playback from
devices, and is able to convert to or stream in various formats.
The VideoLAN project was started at the university École Centrale Paris who
relicensed VLC under the GPLv2 license in February 2001. Since then, VLC has
been downloaded close to one billion times.

Links:
======

The VLC web site  . . . . . http://www.videolan.org/
Support . . . . . . . . . . http://www.videolan.org/support/
Forums  . . . . . . . . . . https://forum.videolan.org/
Wiki  . . . . . . . . . . . https://wiki.videolan.org/
The Developers site . . . . https://wiki.videolan.org/Developers_Corner
VLC hacking guide . . . . . https://wiki.videolan.org/Hacker_Guide
Bugtracker  . . . . . . . . https://trac.videolan.org/vlc/
The VideoLAN web site . . . http://www.videolan.org/

Source Code Content:
===================
ABOUT-NLS          - Notes on the Free Translation Project.
AUTHORS            - VLC authors.
COPYING            - The GPL license.
COPYING.LIB        - The LGPL license.
INSTALL            - Installation and building instructions.
NEWS               - Important modifications between the releases.
README             - This file.
THANKS             - VLC contributors.

bin/               - VLC binaries.
bindings/          - libVLC bindings to other languages.
compat/            - compatibility library for operating systems missing
                     essential functionalities.
contrib/           - Facilities for retrieving external libraries and building
                     them for systems that don't have the right versions.
doc/               - Miscellaneous documentation.
extras/analyser    - Code analyser and editor specific files.
extras/buildsystem - different buildsystems specific files.
extras/misc        - Files that don't fit in the other extras/ categories.
extras/package     - VLC packaging specific files such as spec files.
extras/tools/      - Facilities for retrieving external building tools needed
                     for systems that don't have the right versions.
include/           - Header files.
lib/               - libVLC source code.
modules/           - VLC plugins and modules. Most of the code is here.
po/                - VLC translations.
share/             - Common Resources files.
src/               - libvlccore source code.
test/              - testing system.