From e99714edfcde2ec88535f668b22c368114d10eaf Mon Sep 17 00:00:00 2001 From: armaan Date: Tue, 15 Jul 2025 23:54:21 +0530 Subject: [PATCH] double precision interface for the caller to calculate frames consumed while using the callback API --- include/samplerate.h | 8 ++++++++ src/samplerate.c | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/include/samplerate.h b/include/samplerate.h index a3d5ae1a..1bdab131 100644 --- a/include/samplerate.h +++ b/include/samplerate.h @@ -71,6 +71,14 @@ SRC_STATE* src_clone (SRC_STATE* orig, int *error) ; SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data) ; + +/** + * Double-precision getters: Fractional used-frame + * tracking while using the callback API. + */ +double src_get_last_position(SRC_STATE* state); +double src_get_saved_frames(SRC_STATE* state); + /* ** Cleanup all internal allocations. ** Always returns NULL. diff --git a/src/samplerate.c b/src/samplerate.c index 6a51f279..c76a70ef 100644 --- a/src/samplerate.c +++ b/src/samplerate.c @@ -72,6 +72,15 @@ src_callback_new (src_callback_t func, int converter_type, int channels, int *er return state ; } /* src_callback_new */ + +double src_get_last_postion(SRC_STATE* state) { + return state->last_position; +} + +double src_get_saved_frames(SRC_STATE* state) { + return state->saved_frames; +} + SRC_STATE * src_delete (SRC_STATE *state) {