ref: 2efc6b93f390bc0e7da02f4cfbd15cb736b156e0
parent: c61d92bd9d3430535443da45d19d37663f25a22d
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Sat Jan 27 14:23:24 EST 2007
Fix a bug where src_callback_read() would hand under varying src_ratio.
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,16 @@
* src/samplerate.c
Refactor checking of supplied src ratio against min and max.
+ * configure.ac
+ Remove -pendantic from CFLAGS and add -std=gnu99.
+
+ * tests/callback_hang_test.c tests/Makefile.am
+ Add new test program and hook it into build.
+
+ * src/src_linear.c src/src_sinc.c src/src_zoh.c
+ Fix a bug where the src_callback_read () function would hang under varying
+ src_ratio.
+
2007-01-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* doc/api.html doc/api_callback.html doc/api_misc.html
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -83,8 +83,8 @@
if (linear->in_used + linear->channels * input_index > linear->in_count)
break ;
- if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
- src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / (linear->out_count - 1) ;
+ if (linear->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+ src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / linear->out_count ;
for (ch = 0 ; ch < linear->channels ; ch++)
{ data->data_out [linear->out_gen] = (float) (linear->last_value [ch] + input_index *
@@ -103,8 +103,8 @@
/* Main processing loop. */
while (linear->out_gen < linear->out_count && linear->in_used + linear->channels * input_index <= linear->in_count)
{
- if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
- src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / (linear->out_count - 1) ;
+ if (linear->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+ src_ratio = psrc->last_ratio + linear->out_gen * (data->src_ratio - psrc->last_ratio) / linear->out_count ;
if (SRC_DEBUG && linear->in_used < linear->channels && input_index < 1.0)
{ printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", linear->in_used, linear->channels, input_index) ;
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2002-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -307,8 +307,8 @@
break ;
} ;
- if (fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
- src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / (filter->out_count - 1) ;
+ if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10)
+ src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ;
float_increment = filter->index_inc * 1.0 ;
if (src_ratio < 1.0)
@@ -465,12 +465,4 @@
return (left + right) ;
} /* calc_output */
-
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: db8efe06-2fbd-487e-be8f-bfc01e68c19f
-*/
--- a/src/src_zoh.c
+++ b/src/src_zoh.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2002-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2002-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -81,8 +81,8 @@
if (zoh->in_used + zoh->channels * input_index >= zoh->in_count)
break ;
- if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
- src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / (zoh->out_count - 1) ;
+ if (zoh->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+ src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / zoh->out_count ;
for (ch = 0 ; ch < zoh->channels ; ch++)
{ data->data_out [zoh->out_gen] = zoh->last_value [ch] ;
@@ -100,8 +100,8 @@
/* Main processing loop. */
while (zoh->out_gen < zoh->out_count && zoh->in_used + zoh->channels * input_index <= zoh->in_count)
{
- if (fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
- src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / (zoh->out_count - 1) ;
+ if (zoh->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+ src_ratio = psrc->last_ratio + zoh->out_gen * (data->src_ratio - psrc->last_ratio) / zoh->out_count ;
for (ch = 0 ; ch < zoh->channels ; ch++)
{ data->data_out [zoh->out_gen] = data->data_in [zoh->in_used - zoh->channels + ch] ;
@@ -208,11 +208,4 @@
return ;
} /* zoh_reset */
-/*
-** Do not edit or modify anything in this comment block.
-** The arch-tag line is a file identity tag for the GNU Arch
-** revision control system.
-**
-** arch-tag: 808e62f8-2e4a-44a6-840f-180a3e41af01
-*/