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