History

Fix a bug where src_callback_read() would hand under varying src_ratio.

Erik de Castro Lopo committed 19 years ago

Commit 2efc6b91 parent c61d92b4 files · +22 −27Browse files

Showing the changes to src (3 of 4 files). Show all

Unified · Split

3 files
  1. src/src_linear.c +4 −4
  2. src/src_sinc.c +3 −11
  3. src/src_zoh.c +5 −12
src/src_linear.c+4−4
@@ -83,8 +83,8 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 82 unmodified lines
8383 if (linear->in_used + linear->channels * input_index > linear->in_count)
8484 break ;
8585
86− if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
87− src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / (linear->out_count - 1) ;
86+ if (linear->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
87+ src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / linear->out_count ;
8888
8989 for (ch = 0 ; ch < linear->channels ; ch++)
9090 { data->data_out [linear->out_gen] = (float) (linear->last_value [ch] + input_index *
@@ -103,8 +103,8 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 12 unmodified lines
103103 /* Main processing loop. */
104104 while (linear->out_gen < linear->out_count && linear->in_used + linear->channels * input_index <= linear->in_count)
105105 {
106− if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
107− src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / (linear->out_count - 1) ;
106+ if (linear->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
107+ src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / linear->out_count ;
108108
109109 if (SRC_DEBUG && linear->in_used < linear->channels && input_index < 1.0)
110110 { printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", linear->in_used, linear->channels, input_index) ;
src/src_sinc.c+3−11
@@ -1,5 +1,5 @@
11 /*
2−** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
2+** Copyright (C) 2002-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
33 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
@@ -307,8 +307,8 @@ sinc_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 301 unmodified lines
307307 break ;
308308 } ;
309309
310− if (fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
311− src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / (filter->out_count - 1) ;
310+ if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
311+ src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
312312
313313 float_increment = filter->index_inc * 1.0 ;
314314 if (src_ratio < 1.0)
@@ -466,11 +466,3 @@ calc_output (SINC_FILTER *filter, increment_t increment, increment_t start_filte · 151 unmodified lines
466466 return (left + right) ;
467467 } /* calc_output */
468468
469−/*
470−** Do not edit or modify anything in this comment block.
471−** The arch-tag line is a file identity tag for the GNU Arch
472−** revision control system.
473−**
474−** arch-tag: db8efe06-2fbd-487e-be8f-bfc01e68c19f
475−*/
476−
src/src_zoh.c+5−12
@@ -1,5 +1,5 @@
11 /*
2−** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
2+** Copyright (C) 2002-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
33 **
44 ** This program is free software; you can redistribute it and/or modify
55 ** it under the terms of the GNU General Public License as published by
@@ -81,8 +81,8 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 75 unmodified lines
8181 if (zoh->in_used + zoh->channels * input_index >= zoh->in_count)
8282 break ;
8383
84− if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
85− src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / (zoh->out_count - 1) ;
84+ if (zoh->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
85+ src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / zoh->out_count ;
8686
8787 for (ch = 0 ; ch < zoh->channels ; ch++)
8888 { data->data_out [zoh->out_gen] = zoh->last_value [ch] ;
@@ -100,8 +100,8 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 11 unmodified lines
100100 /* Main processing loop. */
101101 while (zoh->out_gen < zoh->out_count && zoh->in_used + zoh->channels * input_index <= zoh->in_count)
102102 {
103− if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
104− src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / (zoh->out_count - 1) ;
103+ if (zoh->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
104+ src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / zoh->out_count ;
105105
106106 for (ch = 0 ; ch < zoh->channels ; ch++)
107107 { data->data_out [zoh->out_gen] = data->data_in [zoh->in_used - zoh->channels + ch] ;
@@ -208,11 +208,4 @@ zoh_reset (SRC_PRIVATE *psrc) · 100 unmodified lines
208208
209209 return ;
210210 } /* zoh_reset */
211−/*
212−** Do not edit or modify anything in this comment block.
213−** The arch-tag line is a file identity tag for the GNU Arch
214−** revision control system.
215−**
216−** arch-tag: 808e62f8-2e4a-44a6-840f-180a3e41af01
217−*/
218211

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t