From 1f2ad7a490f3e2b39358cf7416e9c7a8580dd0bd Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sun, 5 Jul 2026 16:34:11 +0200 Subject: [PATCH 1/2] Simplify CalculateFrameShift() --- src/common/pa_process.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/common/pa_process.c b/src/common/pa_process.c index 29fca64fa..c162ce7f5 100644 --- a/src/common/pa_process.c +++ b/src/common/pa_process.c @@ -56,34 +56,18 @@ #define PA_MIN_( a, b ) ( ((a)<(b)) ? (a) : (b) ) -/* greatest common divisor - PGCD in French */ +/* greatest common divisor */ static unsigned long GCD( unsigned long a, unsigned long b ) { return (b==0) ? a : GCD( b, a%b); } -/* least common multiple - PPCM in French */ -static unsigned long LCM( unsigned long a, unsigned long b ) -{ - return (a*b) / GCD(a,b); -} - -#define PA_MAX_( a, b ) (((a) > (b)) ? (a) : (b)) - static unsigned long CalculateFrameShift( unsigned long M, unsigned long N ) { - unsigned long result = 0; - unsigned long i; - unsigned long lcm; - assert( M > 0 ); assert( N > 0 ); - - lcm = LCM( M, N ); - for( i = M; i < lcm; i += M ) - result = PA_MAX_( result, i % N ); - - return result; + /* https://lac2026.sciencesconf.org/722511 */ + return N - GCD( M, N ); } From 77def5d173a66cb81a043701d80985f0583b2900 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sun, 12 Jul 2026 17:45:38 +0200 Subject: [PATCH 2/2] Add full bibliographic reference --- src/common/pa_process.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/pa_process.c b/src/common/pa_process.c index c162ce7f5..92f0b31ad 100644 --- a/src/common/pa_process.c +++ b/src/common/pa_process.c @@ -66,7 +66,11 @@ static unsigned long CalculateFrameShift( unsigned long M, unsigned long N ) { assert( M > 0 ); assert( N > 0 ); - /* https://lac2026.sciencesconf.org/722511 */ + /* + The minimum required delay is calculated according to: + M. Rath & M. Geier, "Minimum required delay for realtime block size adaptation in digital audio signal processing", + Linux Audio Conference 2026; https://lac2026.sciencesconf.org/722511 + */ return N - GCD( M, N ); }