stream: fix writable size when no timing info received

Always report that we can write a buffer, even when we have
not yet received timing info. Fixes stalled spotify.

Fixes #238
This commit is contained in:
Wim Taymans 2020-05-11 11:27:15 +02:00
parent 653ae96b20
commit df8ad59e37

View file

@ -1335,14 +1335,15 @@ size_t pa_stream_writable_size(PA_CONST pa_stream *s)
PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD,
PA_ERR_BADSTATE, (size_t) -1);
if (!s->have_time)
return 0;
i = &s->timing_info;
if (s->have_time) {
clock_gettime(CLOCK_MONOTONIC, &ts);
now = SPA_TIMESPEC_TO_USEC(&ts);
elapsed = pa_usec_to_bytes(now - SPA_TIMEVAL_TO_USEC(&i->timestamp), &s->sample_spec);
} else {
elapsed = 0;
}
queued = i->write_index - SPA_MIN(i->read_index, i->write_index);
queued -= SPA_MIN(queued, elapsed);