From 6b42954b47bf97161cab0ae08e0eca7653bc9085 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 30 Nov 2019 21:31:50 -0600 Subject: [PATCH] Add LiGetPendingAudioDuration() function --- src/AudioStream.c | 4 ++++ src/Limelight.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AudioStream.c b/src/AudioStream.c index 88b7836..90cfdfa 100644 --- a/src/AudioStream.c +++ b/src/AudioStream.c @@ -408,3 +408,7 @@ int startAudioStream(void* audioContext, int arFlags) { int LiGetPendingAudioFrames(void) { return LbqGetItemCount(&packetQueue); } + +int LiGetPendingAudioDuration(void) { + return LiGetPendingAudioFrames() * AudioPacketDuration; +} \ No newline at end of file diff --git a/src/Limelight.h b/src/Limelight.h index 91d2025..4b9d811 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -454,9 +454,15 @@ int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, un int LiGetPendingVideoFrames(void); // Returns the number of queued audio frames ready for delivery. Only relevant -// if CAPABILITY_DIRECT_SUBMIT is not set for the audio renderer. +// if CAPABILITY_DIRECT_SUBMIT is not set for the audio renderer. For most uses, +// LiGetPendingAudioDuration() is probably a better option than this function. int LiGetPendingAudioFrames(void); +// Similar to LiGetPendingAudioFrames() except it returns the pending audio in +// milliseconds rather than frames, which allows callers to be agnostic of the +// negotiated audio frame duration. +int LiGetPendingAudioDuration(void); + #ifdef __cplusplus } #endif