mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
simple: Take locally buffered data into account in pa_simple_get_latency()
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=81075
This commit is contained in:
parent
c187441ff9
commit
c0bda6a7ab
1 changed files with 18 additions and 3 deletions
|
|
@ -454,17 +454,32 @@ unlock_and_fail:
|
|||
|
||||
pa_usec_t pa_simple_get_latency(pa_simple *p, int *rerror) {
|
||||
pa_usec_t t;
|
||||
int negative;
|
||||
|
||||
pa_assert(p);
|
||||
|
||||
pa_threaded_mainloop_lock(p->mainloop);
|
||||
|
||||
for (;;) {
|
||||
int negative;
|
||||
|
||||
CHECK_DEAD_GOTO(p, rerror, unlock_and_fail);
|
||||
|
||||
if (pa_stream_get_latency(p->stream, &t, &negative) >= 0)
|
||||
if (pa_stream_get_latency(p->stream, &t, &negative) >= 0) {
|
||||
pa_usec_t extra = 0;
|
||||
|
||||
if (p->direction == PA_STREAM_RECORD)
|
||||
extra = pa_bytes_to_usec(p->read_length, pa_stream_get_sample_spec(p->stream));
|
||||
|
||||
if (negative) {
|
||||
if (extra > t)
|
||||
t = extra - t;
|
||||
else
|
||||
t = 0;
|
||||
} else
|
||||
t += extra;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
CHECK_SUCCESS_GOTO(p, rerror, pa_context_errno(p->context) == PA_ERR_NODATA, unlock_and_fail);
|
||||
|
||||
|
|
@ -474,7 +489,7 @@ pa_usec_t pa_simple_get_latency(pa_simple *p, int *rerror) {
|
|||
|
||||
pa_threaded_mainloop_unlock(p->mainloop);
|
||||
|
||||
return negative ? 0 : t;
|
||||
return t;
|
||||
|
||||
unlock_and_fail:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue