aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_audiotrack.c
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2013-09-20 17:38:25 +1200
committerMatthew Gregan <[email protected]>2013-09-20 17:38:38 +1200
commit2501ae9cb3e983dbb3fd31a8b144e9270a9db8b1 (patch)
tree9d917dc1f1702913a58b9a4ba224db39bce10ad2 /src/cubeb_audiotrack.c
parent52ef517dbb077949d2562c9943dc7238648bdb93 (diff)
downloadcubeb-2501ae9cb3e983dbb3fd31a8b144e9270a9db8b1.tar.gz
cubeb-2501ae9cb3e983dbb3fd31a8b144e9270a9db8b1.zip
add support for querying the actual stream latency.
(this imports changes from BMO 904617.)
Diffstat (limited to 'src/cubeb_audiotrack.c')
-rw-r--r--src/cubeb_audiotrack.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/cubeb_audiotrack.c b/src/cubeb_audiotrack.c
index 5287381..0df7b03 100644
--- a/src/cubeb_audiotrack.c
+++ b/src/cubeb_audiotrack.c
@@ -5,7 +5,9 @@
* accompanying file LICENSE for details.
*/
+#if !defined(NDEBUG)
#define NDEBUG
+#endif
#include <assert.h>
#include <pthread.h>
#include <stdlib.h>
@@ -424,6 +426,19 @@ audiotrack_stream_get_position(cubeb_stream * stream, uint64_t * position)
return CUBEB_OK;
}
+int
+audiotrack_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
+{
+ assert(stream->instance && latency);
+
+ /* Android returns the latency in ms, we want it in frames. */
+ *latency = stream->context->klass.latency(stream->instance);
+ /* with rate <= 96000, we won't overflow until 44.739 seconds of latency */
+ *latency = (*latency * stream->params.rate) / 1000;
+
+ return 0;
+}
+
static struct cubeb_ops const audiotrack_ops = {
.init = audiotrack_init,
.get_backend_id = audiotrack_get_backend_id,
@@ -433,5 +448,6 @@ static struct cubeb_ops const audiotrack_ops = {
.stream_destroy = audiotrack_stream_destroy,
.stream_start = audiotrack_stream_start,
.stream_stop = audiotrack_stream_stop,
- .stream_get_position = audiotrack_stream_get_position
+ .stream_get_position = audiotrack_stream_get_position,
+ .stream_get_latency = audiotrack_stream_get_latency
};