---
name: "roar_vs_latency"
section: "3"
platform: "linux"
package: "libroar-dev"
version: "1.0~beta12-4"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/roar_vs_latency"
---

# roar\_vs\_latency(3)

Get stream position information

## NAME

roar\_vs\_position, roar\_vs\_latency, roar\_vs\_latency2 - Get stream position information

## SYNOPSIS

\#include \<roaraudio.h\>

ssize\_t roar\_vs\_position(roar\_vs\_t \* vss, int backend, int \* error);

roar\_mus\_t roar\_vs\_latency(roar\_vs\_t \* vss, int backend, int \* error);

roar\_mus\_t roar\_vs\_latency2(roar\_vs\_t \* vss, int backend, int wait, int \* error);

## DESCRIPTION

**roar\_vs\_position()** returns the current server site position of the stream plus the current offset for the selected backend.

**roar\_vs\_latency()** returns the latency between the client site stream position and the server site position plus the latency by the backend.

Use of roar\_vs\_latency() is not recommended as it requires the codec to use a true constant bit rate.

**roar\_vs\_latency2()** is perfectly equivalent to roar\_vs\_latency() expect that it takes the additional parameter wait. The wait parameter may have the values ROAR\_VS\_WAIT, ROAR\_VS\_NOWAIT and ROAR\_VS\_ASYNC. If it is ROAR\_VS\_WAIT the function does the same as roar\_vs\_latency(). If the parameter is ROAR\_VS\_NOWAIT roar\_vs\_latency2() will return interpolated data based on old data collected by calls to roar\_vs\_latency(), roar\_vs\_latency2() or roar\_vs\_position(). ROAR\_VS\_ASYNC is used to trigger asyncron updates to this internal state. Asyncron operations need to be enabled before they can be used. See [**roar\_vs\_ctl**(3)](/roar_vs_ctl/3.md).

Calling these functions too often will result in bad performance and incorrect data (pool interval smaller than server response time). Polling up to 20 times per second shoudn't be a problem.

## PARAMETERS

- **vss**

  The VS object to be used.

- **backend**

  The backend used for correction. This can be a stream ID of the stream to use as backend or one of the special values defined by the constants ROAR\_VS\_BACKEND\_\*. ROAR\_VS\_BACKEND\_NONE is used to ask for no correction. ROAR\_VS\_BACKEND\_DEFAULT is used to ask for the default correction. This should be used in all common cases. ROAR\_VS\_BACKEND\_FIRST is used to ask for correction based on the first primary stream on the same mixer.

- **wait**

  Tells the API if the call should wait or not. Must be ROAR\_VS\_WAIT, ROAR\_VS\_NOWAIT or ROAR\_VS\_ASYNC.

- **error**

  This is a pointer to a integer used to store the error value in case of error. This can be NULL if not used but it is very recommended to use this error value to report good error messages to the user.

## RETURN VALUE

roar\_vs\_position() returns the stream position on success and -1 on error. Stream position is the current position of the stream in units of samples (not frames!).

roar\_vs\_latency() returns the stream latency on success and zero on error. However zero is a valid value. In case of error **error** is set to the error. In case of no error but zero latency **error** is cleared (set to ROAR\_ERROR\_NONE). Latency is retruned in mu-seconds (1/10^-6s).

## EXAMPLES

FIXME

## SEE ALSO

[**roarvs**(7)](/roarvs/7.md), [**libroar**(7)](/libroar/7.md), [**RoarAudio**(7)](/RoarAudio/7.md).
