@@ -361,7 +361,7 @@ int process (jack_nframes_t nframes, void *arg) {
361361
362362 delay = snd_pcm_avail ( alsa_handle );
363363
364- delay -= round ( jack_frames_since_cycle_start ( client ) * static_resample_factor );
364+ delay -= round ( jack_frames_since_cycle_start ( client ) / static_resample_factor );
365365 // Do it the hard way.
366366 // this is for compensating xruns etc...
367367
@@ -443,7 +443,7 @@ int process (jack_nframes_t nframes, void *arg) {
443443 if ( current_resample_factor > resample_upper_limit ) current_resample_factor = resample_upper_limit ;
444444
445445 // Now Calculate how many samples we need.
446- rlen = ceil ( ((double )nframes ) * current_resample_factor )+ 2 ;
446+ rlen = ceil ( ((double )nframes ) / current_resample_factor )+ 2 ;
447447 assert ( rlen > 2 );
448448
449449 // Calculate resample_mean so we can init ourselves to saner values.
@@ -518,7 +518,7 @@ latency_cb (jack_latency_callback_mode_t mode, void *arg)
518518 jack_latency_range_t range ;
519519 JSList * node ;
520520
521- range .min = range .max = round (target_delay / static_resample_factor );
521+ range .min = range .max = round (target_delay * static_resample_factor );
522522
523523 if (mode == JackCaptureLatency ) {
524524 for (node = capture_ports ; node ; node = jack_slist_next (node )) {
@@ -758,7 +758,7 @@ int main (int argc, char *argv[]) {
758758
759759 printf ( "selected sample format: %s\n" , formats [format ].name );
760760
761- static_resample_factor = (double ) sample_rate / (double ) jack_sample_rate ;
761+ static_resample_factor = (double ) jack_sample_rate / (double ) sample_rate ;
762762 resample_lower_limit = static_resample_factor * 0.25 ;
763763 resample_upper_limit = static_resample_factor * 4.0 ;
764764 resample_mean = static_resample_factor ;
0 commit comments