mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-05 03:01:53 -04:00
pulse-server: avoid division by 0 in delay calculation
When we are not yet negotiated and the rate is not yet stored in the stream sample spec, use a 0 delay instead of dividing by 0.
This commit is contained in:
parent
d05905f871
commit
707e5e2643
1 changed files with 6 additions and 2 deletions
|
|
@ -2231,7 +2231,9 @@ static int do_get_playback_latency(struct client *client, uint32_t command, uint
|
|||
if (stream == NULL || stream->type != STREAM_TYPE_PLAYBACK)
|
||||
return -ENOENT;
|
||||
|
||||
delay = stream->delay.buffered * SPA_USEC_PER_SEC / stream->ss.rate;
|
||||
delay = 0;
|
||||
if (stream->ss.rate > 0)
|
||||
delay += stream->delay.buffered * SPA_USEC_PER_SEC / stream->ss.rate;
|
||||
if (stream->delay.rate.denom > 0)
|
||||
delay += stream->delay.delay * SPA_USEC_PER_SEC *
|
||||
stream->delay.rate.num / stream->delay.rate.denom;
|
||||
|
|
@ -2288,7 +2290,9 @@ static int do_get_record_latency(struct client *client, uint32_t command, uint32
|
|||
if (stream == NULL || stream->type != STREAM_TYPE_RECORD)
|
||||
return -ENOENT;
|
||||
|
||||
delay = stream->delay.buffered * SPA_USEC_PER_SEC / stream->ss.rate;
|
||||
delay = 0;
|
||||
if (stream->ss.rate > 0)
|
||||
delay += stream->delay.buffered * SPA_USEC_PER_SEC / stream->ss.rate;
|
||||
if (stream->delay.rate.denom > 0)
|
||||
delay += stream->delay.delay * SPA_USEC_PER_SEC *
|
||||
stream->delay.rate.num / stream->delay.rate.denom;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue