From 6ee330605c072a42f95104e4a313786feef58cc9 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Wed, 25 Jun 2014 22:39:40 -0400 Subject: [PATCH] *experimental commit that makes sample rate work properly in -nogui mode by leveraging requested audio_rate in case current sample rate is uninitialized --- pd/src/s_audio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pd/src/s_audio.c b/pd/src/s_audio.c index f2da5b818..6489de504 100644 --- a/pd/src/s_audio.c +++ b/pd/src/s_audio.c @@ -516,7 +516,16 @@ int sys_send_dacs(void) t_float sys_getsr(void) { - return (sys_dacsr); + // when starting with -nogui option, it is conceivable that sys_dacsr + // is not initialized even though the audio_rate by this time has + // proper sample rate entered. Hence we check for this here and avoid + // the -nogui nonsense where we have to do various workarounds to make + // sure that audio objects that depend on this call get the proper sr + if (sys_dacsr == 0) + { + sys_dacsr = (t_float)audio_rate; + } + return (sys_dacsr); } int sys_get_outchannels(void) -- GitLab