shithub: libsamplerate

Download patch

ref: 7f461a3cdc62393c84bbad03e7514e597fb89689
parent: 183610fcad977f4fead56178cf731a2e1c581e65
author: evpobr <[email protected]>
date: Sun Oct 25 07:17:59 EDT 2020

Refactor SRC_STATE

Rename SRC_PRIVATE_tag to SRC_STATE_tag, now SRC_STATE is typedef of
exsiting struct.

--- a/src/common.h
+++ b/src/common.h
@@ -98,7 +98,7 @@
 	SRC_ERR_MAX_ERROR
 } ;
 
-typedef struct SRC_PRIVATE_tag
+struct SRC_STATE_tag
 {	double	last_ratio, last_position ;
 
 	int		error ;
@@ -111,16 +111,16 @@
 	void	*private_data ;
 
 	/* Varispeed process function. */
-	int		(*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
+	int		(*vari_process) (SRC_STATE *state, SRC_DATA *data) ;
 
 	/* Constant speed process function. */
-	int		(*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
+	int		(*const_process) (SRC_STATE *state, SRC_DATA *data) ;
 
 	/* State reset. */
-	void	(*reset) (struct SRC_PRIVATE_tag *psrc) ;
+	void	(*reset) (SRC_STATE *state) ;
 
 	/* State clone. */
-	int		(*copy) (struct SRC_PRIVATE_tag *from, struct SRC_PRIVATE_tag *to) ;
+	int		(*copy) (SRC_STATE *from, SRC_STATE *to) ;
 
 	/* Data specific to SRC_MODE_CALLBACK. */
 	src_callback_t	callback_func ;
@@ -127,25 +127,25 @@
 	void			*user_callback_data ;
 	long			saved_frames ;
 	const float		*saved_data ;
-} SRC_PRIVATE ;
+} ;
 
 /* In src_sinc.c */
 const char* sinc_get_name (int src_enum) ;
 const char* sinc_get_description (int src_enum) ;
 
-int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
+int sinc_set_converter (SRC_STATE *state, int src_enum) ;
 
 /* In src_linear.c */
 const char* linear_get_name (int src_enum) ;
 const char* linear_get_description (int src_enum) ;
 
-int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
+int linear_set_converter (SRC_STATE *state, int src_enum) ;
 
 /* In src_zoh.c */
 const char* zoh_get_name (int src_enum) ;
 const char* zoh_get_description (int src_enum) ;
 
-int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
+int zoh_set_converter (SRC_STATE *state, int src_enum) ;
 
 /*----------------------------------------------------------
 **	Common static inline functions.
--- a/src/samplerate.c
+++ b/src/samplerate.c
@@ -16,13 +16,12 @@
 #include	"samplerate.h"
 #include	"common.h"
 
-static int psrc_set_converter (SRC_PRIVATE	*psrc, int converter_type) ;
+static int psrc_set_converter (SRC_STATE *state, int converter_type) ;
 
 
 SRC_STATE *
 src_new (int converter_type, int channels, int *error)
-{	SRC_PRIVATE	*psrc ;
-
+{
 	if (error)
 		*error = SRC_ERR_NO_ERROR ;
 
@@ -32,58 +31,59 @@
 		return NULL ;
 		} ;
 
-	if ((psrc = ZERO_ALLOC (SRC_PRIVATE, sizeof (*psrc))) == NULL)
+	SRC_STATE *state = ZERO_ALLOC (SRC_STATE, sizeof (SRC_STATE)) ;
+	if (state == NULL)
 	{	if (error)
 			*error = SRC_ERR_MALLOC_FAILED ;
 		return NULL ;
 		} ;
 
-	psrc->channels = channels ;
-	psrc->mode = SRC_MODE_PROCESS ;
+	state->channels = channels ;
+	state->mode = SRC_MODE_PROCESS ;
 
-	if (psrc_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR)
+	if (psrc_set_converter (state, converter_type) != SRC_ERR_NO_ERROR)
 	{	if (error)
 			*error = SRC_ERR_BAD_CONVERTER ;
-		free (psrc) ;
-		psrc = NULL ;
+		free (state) ;
+		state = NULL ;
 		} ;
 
-	src_reset ((SRC_STATE*) psrc) ;
+	src_reset (state) ;
 
-	return (SRC_STATE*) psrc ;
+	return state ;
 } /* src_new */
 
 SRC_STATE*
 src_clone (SRC_STATE* orig, int *error)
 {
-	SRC_PRIVATE	*psrc ;
+	SRC_STATE *state ;
 	int copy_error ;
 
 	if (error)
 		*error = SRC_ERR_NO_ERROR ;
 
-	if ((psrc = ZERO_ALLOC (SRC_PRIVATE, sizeof (*psrc))) == NULL)
+	if ((state = ZERO_ALLOC (SRC_STATE, sizeof (SRC_STATE))) ==  NULL)
 	{	if (error)
 			*error = SRC_ERR_MALLOC_FAILED ;
 		return NULL ;
 		} ;
 
-	SRC_PRIVATE *orig_priv = (SRC_PRIVATE*) orig ;
-	memcpy (psrc, orig_priv, sizeof (SRC_PRIVATE)) ;
+	SRC_STATE *orig_state = orig ;
+	memcpy (state, orig_state, sizeof (SRC_STATE)) ;
 
-	if ((copy_error = orig_priv->copy (orig_priv, psrc)) != SRC_ERR_NO_ERROR)
+	if ((copy_error = orig_state->copy (orig_state, state)) != SRC_ERR_NO_ERROR)
 	{	if (error)
 			*error = copy_error ;
-		free (psrc) ;
-		psrc = NULL ;
+		free (state) ;
+		state = NULL ;
 		} ;
 
-	return (SRC_STATE*) psrc ;
+	return state ;
 }
 
 SRC_STATE*
 src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data)
-{	SRC_STATE	*src_state ;
+{	SRC_STATE	*state ;
 
 	if (func == NULL)
 	{	if (error)
@@ -94,28 +94,26 @@
 	if (error != NULL)
 		*error = 0 ;
 
-	if ((src_state = src_new (converter_type, channels, error)) == NULL)
+	if ((state = src_new (converter_type, channels, error)) == NULL)
 		return NULL ;
 
-	src_reset (src_state) ;
+	src_reset (state) ;
 
-	((SRC_PRIVATE*) src_state)->mode = SRC_MODE_CALLBACK ;
-	((SRC_PRIVATE*) src_state)->callback_func = func ;
-	((SRC_PRIVATE*) src_state)->user_callback_data = cb_data ;
+	state->mode = SRC_MODE_CALLBACK ;
+	state->callback_func = func ;
+	state->user_callback_data = cb_data ;
 
-	return src_state ;
+	return state ;
 } /* src_callback_new */
 
 SRC_STATE *
 src_delete (SRC_STATE *state)
-{	SRC_PRIVATE *psrc ;
-
-	psrc = (SRC_PRIVATE*) state ;
-	if (psrc)
-	{	if (psrc->private_data)
-			free (psrc->private_data) ;
-		memset (psrc, 0, sizeof (SRC_PRIVATE)) ;
-		free (psrc) ;
+{
+	if (state)
+	{	if (state->private_data)
+			free (state->private_data) ;
+		memset (state, 0, sizeof (SRC_STATE)) ;
+		free (state) ;
 		} ;
 
 	return NULL ;
@@ -123,17 +121,15 @@
 
 int
 src_process (SRC_STATE *state, SRC_DATA *data)
-{	SRC_PRIVATE *psrc ;
+{
 	int error ;
 
-	psrc = (SRC_PRIVATE*) state ;
-
-	if (psrc == NULL)
+	if (state == NULL)
 		return SRC_ERR_BAD_STATE ;
-	if (psrc->vari_process == NULL || psrc->const_process == NULL)
+	if (state->vari_process == NULL || state->const_process == NULL)
 		return SRC_ERR_BAD_PROC_PTR ;
 
-	if (psrc->mode != SRC_MODE_PROCESS)
+	if (state->mode != SRC_MODE_PROCESS)
 		return SRC_ERR_BAD_MODE ;
 
 	/* Check for valid SRC_DATA first. */
@@ -155,13 +151,13 @@
 		data->output_frames = 0 ;
 
 	if (data->data_in < data->data_out)
-	{	if (data->data_in + data->input_frames * psrc->channels > data->data_out)
+	{	if (data->data_in + data->input_frames * state->channels > data->data_out)
 		{	/*-printf ("\n\ndata_in: %p    data_out: %p\n",
 				(void*) (data->data_in + data->input_frames * psrc->channels), (void*) data->data_out) ;-*/
 			return SRC_ERR_DATA_OVERLAP ;
 			} ;
 		}
-	else if (data->data_out + data->output_frames * psrc->channels > data->data_in)
+	else if (data->data_out + data->output_frames * state->channels > data->data_in)
 	{	/*-printf ("\n\ndata_in : %p   ouput frames: %ld    data_out: %p\n", (void*) data->data_in, data->output_frames, (void*) data->data_out) ;
 
 		printf ("data_out: %p (%p)    data_in: %p\n", (void*) data->data_out,
@@ -174,14 +170,14 @@
 	data->output_frames_gen = 0 ;
 
 	/* Special case for when last_ratio has not been set. */
-	if (psrc->last_ratio < (1.0 / SRC_MAX_RATIO))
-		psrc->last_ratio = data->src_ratio ;
+	if (state->last_ratio < (1.0 / SRC_MAX_RATIO))
+		state->last_ratio = data->src_ratio ;
 
 	/* Now process. */
-	if (fabs (psrc->last_ratio - data->src_ratio) < 1e-15)
-		error = psrc->const_process (psrc, data) ;
+	if (fabs (state->last_ratio - data->src_ratio) < 1e-15)
+		error = state->const_process (state, data) ;
 	else
-		error = psrc->vari_process (psrc, data) ;
+		error = state->vari_process (state, data) ;
 
 	return error ;
 } /* src_process */
@@ -188,7 +184,7 @@
 
 long
 src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data)
-{	SRC_PRIVATE	*psrc ;
+{
 	SRC_DATA	src_data ;
 
 	long	output_frames_gen ;
@@ -200,15 +196,13 @@
 	if (frames <= 0)
 		return 0 ;
 
-	psrc = (SRC_PRIVATE*) state ;
-
-	if (psrc->mode != SRC_MODE_CALLBACK)
-	{	psrc->error = SRC_ERR_BAD_MODE ;
+	if (state->mode != SRC_MODE_CALLBACK)
+	{	state->error = SRC_ERR_BAD_MODE ;
 		return 0 ;
 		} ;
 
-	if (psrc->callback_func == NULL)
-	{	psrc->error = SRC_ERR_NULL_CALLBACK ;
+	if (state->callback_func == NULL)
+	{	state->error = SRC_ERR_NULL_CALLBACK ;
 		return 0 ;
 		} ;
 
@@ -216,7 +210,7 @@
 
 	/* Check src_ratio is in range. */
 	if (is_bad_src_ratio (src_ratio))
-	{	psrc->error = SRC_ERR_BAD_SRC_RATIO ;
+	{	state->error = SRC_ERR_BAD_SRC_RATIO ;
 		return 0 ;
 		} ;
 
@@ -225,8 +219,8 @@
 	src_data.data_out = data ;
 	src_data.output_frames = frames ;
 
-	src_data.data_in = psrc->saved_data ;
-	src_data.input_frames = psrc->saved_frames ;
+	src_data.data_in = state->saved_data ;
+	src_data.input_frames = state->saved_frames ;
 
 	output_frames_gen = 0 ;
 	while (output_frames_gen < frames)
@@ -238,7 +232,7 @@
 		if (src_data.input_frames == 0)
 		{	float *ptr = dummy ;
 
-			src_data.input_frames = psrc->callback_func (psrc->user_callback_data, &ptr) ;
+			src_data.input_frames = state->callback_func (state->user_callback_data, &ptr) ;
 			src_data.data_in = ptr ;
 
 			if (src_data.input_frames == 0)
@@ -250,17 +244,17 @@
 		** to SRC_MODE_PROCESS first and when we return set it back to
 		** SRC_MODE_CALLBACK.
 		*/
-		psrc->mode = SRC_MODE_PROCESS ;
+		state->mode = SRC_MODE_PROCESS ;
 		error = src_process (state, &src_data) ;
-		psrc->mode = SRC_MODE_CALLBACK ;
+		state->mode = SRC_MODE_CALLBACK ;
 
 		if (error != 0)
 			break ;
 
-		src_data.data_in += src_data.input_frames_used * psrc->channels ;
+		src_data.data_in += src_data.input_frames_used * state->channels ;
 		src_data.input_frames -= src_data.input_frames_used ;
 
-		src_data.data_out += src_data.output_frames_gen * psrc->channels ;
+		src_data.data_out += src_data.output_frames_gen * state->channels ;
 		src_data.output_frames -= src_data.output_frames_gen ;
 
 		output_frames_gen += src_data.output_frames_gen ;
@@ -269,11 +263,11 @@
 			break ;
 		} ;
 
-	psrc->saved_data = src_data.data_in ;
-	psrc->saved_frames = src_data.input_frames ;
+	state->saved_data = src_data.data_in ;
+	state->saved_frames = src_data.input_frames ;
 
 	if (error != 0)
-	{	psrc->error = error ;
+	{	state->error = error ;
 		return 0 ;
 		} ;
 
@@ -285,19 +279,16 @@
 
 int
 src_set_ratio (SRC_STATE *state, double new_ratio)
-{	SRC_PRIVATE *psrc ;
-
-	psrc = (SRC_PRIVATE*) state ;
-
-	if (psrc == NULL)
+{
+	if (state == NULL)
 		return SRC_ERR_BAD_STATE ;
-	if (psrc->vari_process == NULL || psrc->const_process == NULL)
+	if (state->vari_process == NULL || state->const_process == NULL)
 		return SRC_ERR_BAD_PROC_PTR ;
 
 	if (is_bad_src_ratio (new_ratio))
 		return SRC_ERR_BAD_SRC_RATIO ;
 
-	psrc->last_ratio = new_ratio ;
+	state->last_ratio = new_ratio ;
 
 	return SRC_ERR_NO_ERROR ;
 } /* src_set_ratio */
@@ -304,35 +295,31 @@
 
 int
 src_get_channels (SRC_STATE *state)
-{	SRC_PRIVATE *psrc ;
-
-	psrc = (SRC_PRIVATE*) state ;
-
-	if (psrc == NULL)
+{
+	if (state == NULL)
 		return -SRC_ERR_BAD_STATE ;
-	if (psrc->vari_process == NULL || psrc->const_process == NULL)
+	if (state->vari_process == NULL || state->const_process == NULL)
 		return -SRC_ERR_BAD_PROC_PTR ;
 
-	return psrc->channels ;
+	return state->channels ;
 } /* src_get_channels */
 
 int
 src_reset (SRC_STATE *state)
-{	SRC_PRIVATE *psrc ;
-
-	if ((psrc = (SRC_PRIVATE*) state) == NULL)
+{
+	if (state == NULL)
 		return SRC_ERR_BAD_STATE ;
 
-	if (psrc->reset != NULL)
-		psrc->reset (psrc) ;
+	if (state->reset != NULL)
+		state->reset (state) ;
 
-	psrc->last_position = 0.0 ;
-	psrc->last_ratio = 0.0 ;
+	state->last_position = 0.0 ;
+	state->last_ratio = 0.0 ;
 
-	psrc->saved_data = NULL ;
-	psrc->saved_frames = 0 ;
+	state->saved_data = NULL ;
+	state->saved_frames = 0 ;
 
-	psrc->error = SRC_ERR_NO_ERROR ;
+	state->error = SRC_ERR_NO_ERROR ;
 
 	return SRC_ERR_NO_ERROR ;
 } /* src_reset */
@@ -394,7 +381,7 @@
 int
 src_error (SRC_STATE *state)
 {	if (state)
-		return ((SRC_PRIVATE*) state)->error ;
+		return state->error ;
 	return SRC_ERR_NO_ERROR ;
 } /* src_error */
 
@@ -547,15 +534,15 @@
 */
 
 static int
-psrc_set_converter (SRC_PRIVATE	*psrc, int converter_type)
+psrc_set_converter (SRC_STATE	*state, int converter_type)
 {
-	if (sinc_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
+	if (sinc_set_converter (state, converter_type) == SRC_ERR_NO_ERROR)
 		return SRC_ERR_NO_ERROR ;
 
-	if (zoh_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
+	if (zoh_set_converter (state, converter_type) == SRC_ERR_NO_ERROR)
 		return SRC_ERR_NO_ERROR ;
 
-	if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
+	if (linear_set_converter (state, converter_type) == SRC_ERR_NO_ERROR)
 		return SRC_ERR_NO_ERROR ;
 
 	return SRC_ERR_BAD_CONVERTER ;
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -14,9 +14,9 @@
 #include "src_config.h"
 #include "common.h"
 
-static int linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
-static void linear_reset (SRC_PRIVATE *psrc) ;
-static int linear_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) ;
+static int linear_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static void linear_reset (SRC_STATE *state) ;
+static int linear_copy (SRC_STATE *from, SRC_STATE *to) ;
 
 /*========================================================================================
 */
@@ -38,7 +38,7 @@
 */
 
 static int
-linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+linear_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	LINEAR_DATA *priv ;
 	double		src_ratio, input_index, rem ;
 	int			ch ;
@@ -46,10 +46,10 @@
 	if (data->input_frames <= 0)
 		return SRC_ERR_NO_ERROR ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	priv = (LINEAR_DATA*) psrc->private_data ;
+	priv = (LINEAR_DATA*) state->private_data ;
 
 	if (priv->reset)
 	{	/* If we have just been reset, set the last_value data. */
@@ -62,12 +62,12 @@
 	priv->out_count = data->output_frames * priv->channels ;
 	priv->in_used = priv->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	/* Calculate samples before first sample in input array. */
 	while (input_index < 1.0 && priv->out_gen < priv->out_count)
@@ -75,8 +75,8 @@
 		if (priv->in_used + priv->channels * (1.0 + input_index) >= priv->in_count)
 			break ;
 
-		if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
-			src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
+		if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+			src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
 
 		for (ch = 0 ; ch < priv->channels ; ch++)
 		{	data->data_out [priv->out_gen] = (float) (priv->last_value [ch] + input_index *
@@ -95,8 +95,8 @@
 	/* Main processing loop. */
 	while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index < priv->in_count)
 	{
-		if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
-			src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
+		if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+			src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
 
 		if (SRC_DEBUG && priv->in_used < priv->channels && input_index < 1.0)
 		{	printf ("Whoops!!!!   in_used : %ld     channels : %d     input_index : %f\n", priv->in_used, priv->channels, input_index) ;
@@ -122,7 +122,7 @@
 		priv->in_used = priv->in_count ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	if (priv->in_used > 0)
 		for (ch = 0 ; ch < priv->channels ; ch++)
@@ -129,7 +129,7 @@
 			priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = priv->in_used / priv->channels ;
 	data->output_frames_gen = priv->out_gen / priv->channels ;
@@ -159,20 +159,20 @@
 } /* linear_get_descrition */
 
 int
-linear_set_converter (SRC_PRIVATE *psrc, int src_enum)
+linear_set_converter (SRC_STATE *state, int src_enum)
 {	LINEAR_DATA *priv = NULL ;
 
 	if (src_enum != SRC_LINEAR)
 		return SRC_ERR_BAD_CONVERTER ;
 
-	if (psrc->private_data != NULL)
-	{	free (psrc->private_data) ;
-		psrc->private_data = NULL ;
+	if (state->private_data != NULL)
+	{	free (state->private_data) ;
+		state->private_data = NULL ;
 		} ;
 
-	if (psrc->private_data == NULL)
-	{	priv = ZERO_ALLOC (LINEAR_DATA, sizeof (*priv) + psrc->channels * sizeof (float)) ;
-		psrc->private_data = priv ;
+	if (state->private_data == NULL)
+	{	priv = ZERO_ALLOC (LINEAR_DATA, sizeof (*priv) + state->channels * sizeof (float)) ;
+		state->private_data = priv ;
 		} ;
 
 	if (priv == NULL)
@@ -179,14 +179,14 @@
 		return SRC_ERR_MALLOC_FAILED ;
 
 	priv->linear_magic_marker = LINEAR_MAGIC_MARKER ;
-	priv->channels = psrc->channels ;
+	priv->channels = state->channels ;
 
-	psrc->const_process = linear_vari_process ;
-	psrc->vari_process = linear_vari_process ;
-	psrc->reset = linear_reset ;
-	psrc->copy = linear_copy ;
+	state->const_process = linear_vari_process ;
+	state->vari_process = linear_vari_process ;
+	state->reset = linear_reset ;
+	state->copy = linear_copy ;
 
-	linear_reset (psrc) ;
+	linear_reset (state) ;
 
 	return SRC_ERR_NO_ERROR ;
 } /* linear_set_converter */
@@ -195,14 +195,14 @@
 */
 
 static void
-linear_reset (SRC_PRIVATE *psrc)
+linear_reset (SRC_STATE *state)
 {	LINEAR_DATA *priv = NULL ;
 
-	priv = (LINEAR_DATA*) psrc->private_data ;
+	priv = (LINEAR_DATA*) state->private_data ;
 	if (priv == NULL)
 		return ;
 
-	priv->channels = psrc->channels ;
+	priv->channels = state->channels ;
 	priv->reset = 1 ;
 	memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ;
 
@@ -210,7 +210,7 @@
 } /* linear_reset */
 
 static int
-linear_copy (SRC_PRIVATE *from, SRC_PRIVATE *to)
+linear_copy (SRC_STATE *from, SRC_STATE *to)
 {
 	if (from->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -58,16 +58,16 @@
 	float	buffer [] ;
 } SINC_FILTER ;
 
-static int sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
-static int sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
-static int sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
-static int sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
-static int sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
+static int sinc_multichan_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static int sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static int sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static int sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static int sinc_mono_vari_process (SRC_STATE *state, SRC_DATA *data) ;
 
 static int prepare_data (SINC_FILTER *filter, SRC_DATA *data, int half_filter_chan_len) WARN_UNUSED ;
 
-static void sinc_reset (SRC_PRIVATE *psrc) ;
-static int sinc_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) ;
+static void sinc_reset (SRC_STATE *state) ;
+static int sinc_copy (SRC_STATE *from, SRC_STATE *to) ;
 
 static inline increment_t
 double_to_fp (double x)
@@ -143,7 +143,7 @@
 } /* sinc_get_descrition */
 
 int
-sinc_set_converter (SRC_PRIVATE *psrc, int src_enum)
+sinc_set_converter (SRC_STATE *state, int src_enum)
 {	SINC_FILTER *filter, temp_filter ;
 	increment_t count ;
 	uint32_t bits ;
@@ -152,43 +152,43 @@
 	if (SHIFT_BITS >= sizeof (increment_t) * 8 - 1)
 		return SRC_ERR_SHIFT_BITS ;
 
-	if (psrc->private_data != NULL)
-	{	free (psrc->private_data) ;
-		psrc->private_data = NULL ;
+	if (state->private_data != NULL)
+	{	free (state->private_data) ;
+		state->private_data = NULL ;
 		} ;
 
 	memset (&temp_filter, 0, sizeof (temp_filter)) ;
 
 	temp_filter.sinc_magic_marker = SINC_MAGIC_MARKER ;
-	temp_filter.channels = psrc->channels ;
+	temp_filter.channels = state->channels ;
 
-	if (psrc->channels > ARRAY_LEN (temp_filter.left_calc))
+	if (state->channels > ARRAY_LEN (temp_filter.left_calc))
 		return SRC_ERR_BAD_CHANNEL_COUNT ;
-	else if (psrc->channels == 1)
-	{	psrc->const_process = sinc_mono_vari_process ;
-		psrc->vari_process = sinc_mono_vari_process ;
+	else if (state->channels == 1)
+	{	state->const_process = sinc_mono_vari_process ;
+		state->vari_process = sinc_mono_vari_process ;
 		}
 	else
-	if (psrc->channels == 2)
-	{	psrc->const_process = sinc_stereo_vari_process ;
-		psrc->vari_process = sinc_stereo_vari_process ;
+	if (state->channels == 2)
+	{	state->const_process = sinc_stereo_vari_process ;
+		state->vari_process = sinc_stereo_vari_process ;
 		}
 	else
-	if (psrc->channels == 4)
-	{	psrc->const_process = sinc_quad_vari_process ;
-		psrc->vari_process = sinc_quad_vari_process ;
+	if (state->channels == 4)
+	{	state->const_process = sinc_quad_vari_process ;
+		state->vari_process = sinc_quad_vari_process ;
 		}
 	else
-	if (psrc->channels == 6)
-	{	psrc->const_process = sinc_hex_vari_process ;
-		psrc->vari_process = sinc_hex_vari_process ;
+	if (state->channels == 6)
+	{	state->const_process = sinc_hex_vari_process ;
+		state->vari_process = sinc_hex_vari_process ;
 		}
 	else
-	{	psrc->const_process = sinc_multichan_vari_process ;
-		psrc->vari_process = sinc_multichan_vari_process ;
+	{	state->const_process = sinc_multichan_vari_process ;
+		state->vari_process = sinc_multichan_vari_process ;
 		} ;
-	psrc->reset = sinc_reset ;
-	psrc->copy = sinc_copy ;
+	state->reset = sinc_reset ;
+	state->copy = sinc_copy ;
 
 	switch (src_enum)
 	{	case SRC_SINC_FASTEST :
@@ -229,9 +229,9 @@
 	*filter = temp_filter ;
 	memset (&temp_filter, 0xEE, sizeof (temp_filter)) ;
 
-	psrc->private_data = filter ;
+	state->private_data = filter ;
 
-	sinc_reset (psrc) ;
+	sinc_reset (state) ;
 
 	count = filter->coeff_half_len ;
 	for (bits = 0 ; (MAKE_INCREMENT_T (1) << bits) < count ; bits++)
@@ -244,10 +244,10 @@
 } /* sinc_set_converter */
 
 static void
-sinc_reset (SRC_PRIVATE *psrc)
+sinc_reset (SRC_STATE *state)
 {	SINC_FILTER *filter ;
 
-	filter = (SINC_FILTER*) psrc->private_data ;
+	filter = (SINC_FILTER*) state->private_data ;
 	if (filter == NULL)
 		return ;
 
@@ -263,7 +263,7 @@
 } /* sinc_reset */
 
 static int
-sinc_copy (SRC_PRIVATE *from, SRC_PRIVATE *to)
+sinc_copy (SRC_STATE *from, SRC_STATE *to)
 {
 	if (from->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
@@ -346,16 +346,16 @@
 } /* calc_output_single */
 
 static int
-sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+sinc_mono_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
 	increment_t	increment, start_filter_index ;
 	int			half_filter_chan_len, samples_in_hand ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	filter = (SINC_FILTER*) psrc->private_data ;
+	filter = (SINC_FILTER*) state->private_data ;
 
 	/* If there is not a problem, this will be optimised out. */
 	if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0]))
@@ -365,7 +365,7 @@
 	filter->out_count = data->output_frames * filter->channels ;
 	filter->in_used = filter->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
@@ -372,13 +372,13 @@
 
 	/* Check the sample rate ratio wrt the buffer len. */
 	count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
-	if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
-		count /= MIN (psrc->last_ratio, data->src_ratio) ;
+	if (MIN (state->last_ratio, data->src_ratio) < 1.0)
+		count /= MIN (state->last_ratio, data->src_ratio) ;
 
 	/* Maximum coefficientson either side of center point. */
 	half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	rem = fmod_one (input_index) ;
 	filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
@@ -393,8 +393,8 @@
 		samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 
 		if (samples_in_hand <= half_filter_chan_len)
-		{	if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
-				return psrc->error ;
+		{	if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
+				return state->error ;
 
 			samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 			if (samples_in_hand <= half_filter_chan_len)
@@ -407,8 +407,8 @@
 				break ;
 			} ;
 
-		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 ;
+		if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10)
+			src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ;
 
 		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
@@ -427,10 +427,10 @@
 		input_index = rem ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = filter->in_used / filter->channels ;
 	data->output_frames_gen = filter->out_gen / filter->channels ;
@@ -502,16 +502,16 @@
 } /* calc_output_stereo */
 
 static int
-sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
 	increment_t	increment, start_filter_index ;
 	int			half_filter_chan_len, samples_in_hand ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	filter = (SINC_FILTER*) psrc->private_data ;
+	filter = (SINC_FILTER*) state->private_data ;
 
 	/* If there is not a problem, this will be optimised out. */
 	if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0]))
@@ -521,7 +521,7 @@
 	filter->out_count = data->output_frames * filter->channels ;
 	filter->in_used = filter->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
@@ -528,13 +528,13 @@
 
 	/* Check the sample rate ratio wrt the buffer len. */
 	count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
-	if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
-		count /= MIN (psrc->last_ratio, data->src_ratio) ;
+	if (MIN (state->last_ratio, data->src_ratio) < 1.0)
+		count /= MIN (state->last_ratio, data->src_ratio) ;
 
 	/* Maximum coefficientson either side of center point. */
 	half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	rem = fmod_one (input_index) ;
 	filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
@@ -549,8 +549,8 @@
 		samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 
 		if (samples_in_hand <= half_filter_chan_len)
-		{	if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
-				return psrc->error ;
+		{	if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
+				return state->error ;
 
 			samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 			if (samples_in_hand <= half_filter_chan_len)
@@ -563,8 +563,8 @@
 				break ;
 			} ;
 
-		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 ;
+		if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10)
+			src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ;
 
 		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
@@ -582,10 +582,10 @@
 		input_index = rem ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = filter->in_used / filter->channels ;
 	data->output_frames_gen = filter->out_gen / filter->channels ;
@@ -658,16 +658,16 @@
 } /* calc_output_quad */
 
 static int
-sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
 	increment_t	increment, start_filter_index ;
 	int			half_filter_chan_len, samples_in_hand ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	filter = (SINC_FILTER*) psrc->private_data ;
+	filter = (SINC_FILTER*) state->private_data ;
 
 	/* If there is not a problem, this will be optimised out. */
 	if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0]))
@@ -677,7 +677,7 @@
 	filter->out_count = data->output_frames * filter->channels ;
 	filter->in_used = filter->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
@@ -684,13 +684,13 @@
 
 	/* Check the sample rate ratio wrt the buffer len. */
 	count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
-	if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
-		count /= MIN (psrc->last_ratio, data->src_ratio) ;
+	if (MIN (state->last_ratio, data->src_ratio) < 1.0)
+		count /= MIN (state->last_ratio, data->src_ratio) ;
 
 	/* Maximum coefficientson either side of center point. */
 	half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	rem = fmod_one (input_index) ;
 	filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
@@ -705,8 +705,8 @@
 		samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 
 		if (samples_in_hand <= half_filter_chan_len)
-		{	if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
-				return psrc->error ;
+		{	if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
+				return state->error ;
 
 			samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 			if (samples_in_hand <= half_filter_chan_len)
@@ -719,8 +719,8 @@
 				break ;
 			} ;
 
-		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 ;
+		if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10)
+			src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ;
 
 		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
@@ -738,10 +738,10 @@
 		input_index = rem ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = filter->in_used / filter->channels ;
 	data->output_frames_gen = filter->out_gen / filter->channels ;
@@ -813,16 +813,16 @@
 } /* calc_output_hex */
 
 static int
-sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
 	increment_t	increment, start_filter_index ;
 	int			half_filter_chan_len, samples_in_hand ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	filter = (SINC_FILTER*) psrc->private_data ;
+	filter = (SINC_FILTER*) state->private_data ;
 
 	/* If there is not a problem, this will be optimised out. */
 	if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0]))
@@ -832,7 +832,7 @@
 	filter->out_count = data->output_frames * filter->channels ;
 	filter->in_used = filter->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
@@ -839,13 +839,13 @@
 
 	/* Check the sample rate ratio wrt the buffer len. */
 	count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
-	if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
-		count /= MIN (psrc->last_ratio, data->src_ratio) ;
+	if (MIN (state->last_ratio, data->src_ratio) < 1.0)
+		count /= MIN (state->last_ratio, data->src_ratio) ;
 
 	/* Maximum coefficientson either side of center point. */
 	half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	rem = fmod_one (input_index) ;
 	filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
@@ -860,8 +860,8 @@
 		samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 
 		if (samples_in_hand <= half_filter_chan_len)
-		{	if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
-				return psrc->error ;
+		{	if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
+				return state->error ;
 
 			samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 			if (samples_in_hand <= half_filter_chan_len)
@@ -874,8 +874,8 @@
 				break ;
 			} ;
 
-		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 ;
+		if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10)
+			src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ;
 
 		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
@@ -893,10 +893,10 @@
 		input_index = rem ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = filter->in_used / filter->channels ;
 	data->output_frames_gen = filter->out_gen / filter->channels ;
@@ -978,16 +978,16 @@
 } /* calc_output_multi */
 
 static int
-sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+sinc_multichan_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
 	increment_t	increment, start_filter_index ;
 	int			half_filter_chan_len, samples_in_hand ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	filter = (SINC_FILTER*) psrc->private_data ;
+	filter = (SINC_FILTER*) state->private_data ;
 
 	/* If there is not a problem, this will be optimised out. */
 	if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0]))
@@ -997,7 +997,7 @@
 	filter->out_count = data->output_frames * filter->channels ;
 	filter->in_used = filter->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
@@ -1004,13 +1004,13 @@
 
 	/* Check the sample rate ratio wrt the buffer len. */
 	count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
-	if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
-		count /= MIN (psrc->last_ratio, data->src_ratio) ;
+	if (MIN (state->last_ratio, data->src_ratio) < 1.0)
+		count /= MIN (state->last_ratio, data->src_ratio) ;
 
 	/* Maximum coefficientson either side of center point. */
 	half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	rem = fmod_one (input_index) ;
 	filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ;
@@ -1025,8 +1025,8 @@
 		samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 
 		if (samples_in_hand <= half_filter_chan_len)
-		{	if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
-				return psrc->error ;
+		{	if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0)
+				return state->error ;
 
 			samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ;
 			if (samples_in_hand <= half_filter_chan_len)
@@ -1039,8 +1039,8 @@
 				break ;
 			} ;
 
-		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 ;
+		if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10)
+			src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ;
 
 		float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
 		increment = double_to_fp (float_increment) ;
@@ -1048,7 +1048,7 @@
 		start_filter_index = double_to_fp (input_index * float_increment) ;
 
 		calc_output_multi (filter, increment, start_filter_index, filter->channels, float_increment / filter->index_inc, data->data_out + filter->out_gen) ;
-		filter->out_gen += psrc->channels ;
+		filter->out_gen += state->channels ;
 
 		/* Figure out the next index. */
 		input_index += 1.0 / src_ratio ;
@@ -1058,10 +1058,10 @@
 		input_index = rem ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = filter->in_used / filter->channels ;
 	data->output_frames_gen = filter->out_gen / filter->channels ;
--- a/src/src_zoh.c
+++ b/src/src_zoh.c
@@ -14,9 +14,9 @@
 #include "src_config.h"
 #include "common.h"
 
-static int zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
-static void zoh_reset (SRC_PRIVATE *psrc) ;
-static int zoh_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) ;
+static int zoh_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static void zoh_reset (SRC_STATE *state) ;
+static int zoh_copy (SRC_STATE *from, SRC_STATE *to) ;
 
 /*========================================================================================
 */
@@ -36,7 +36,7 @@
 */
 
 static int
-zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+zoh_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	ZOH_DATA 	*priv ;
 	double		src_ratio, input_index, rem ;
 	int			ch ;
@@ -44,10 +44,10 @@
 	if (data->input_frames <= 0)
 		return SRC_ERR_NO_ERROR ;
 
-	if (psrc->private_data == NULL)
+	if (state->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;
 
-	priv = (ZOH_DATA*) psrc->private_data ;
+	priv = (ZOH_DATA*) state->private_data ;
 
 	if (priv->reset)
 	{	/* If we have just been reset, set the last_value data. */
@@ -60,12 +60,12 @@
 	priv->out_count = data->output_frames * priv->channels ;
 	priv->in_used = priv->out_gen = 0 ;
 
-	src_ratio = psrc->last_ratio ;
+	src_ratio = state->last_ratio ;
 
 	if (is_bad_src_ratio (src_ratio))
 		return SRC_ERR_BAD_INTERNAL_STATE ;
 
-	input_index = psrc->last_position ;
+	input_index = state->last_position ;
 
 	/* Calculate samples before first sample in input array. */
 	while (input_index < 1.0 && priv->out_gen < priv->out_count)
@@ -73,8 +73,8 @@
 		if (priv->in_used + priv->channels * input_index >= priv->in_count)
 			break ;
 
-		if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
-			src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
+		if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+			src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
 
 		for (ch = 0 ; ch < priv->channels ; ch++)
 		{	data->data_out [priv->out_gen] = priv->last_value [ch] ;
@@ -92,8 +92,8 @@
 	/* Main processing loop. */
 	while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index <= priv->in_count)
 	{
-		if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
-			src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
+		if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
+			src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ;
 
 		for (ch = 0 ; ch < priv->channels ; ch++)
 		{	data->data_out [priv->out_gen] = data->data_in [priv->in_used - priv->channels + ch] ;
@@ -113,7 +113,7 @@
 		priv->in_used = priv->in_count ;
 		} ;
 
-	psrc->last_position = input_index ;
+	state->last_position = input_index ;
 
 	if (priv->in_used > 0)
 		for (ch = 0 ; ch < priv->channels ; ch++)
@@ -120,7 +120,7 @@
 			priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ;
 
 	/* Save current ratio rather then target ratio. */
-	psrc->last_ratio = src_ratio ;
+	state->last_ratio = src_ratio ;
 
 	data->input_frames_used = priv->in_used / priv->channels ;
 	data->output_frames_gen = priv->out_gen / priv->channels ;
@@ -150,20 +150,20 @@
 } /* zoh_get_descrition */
 
 int
-zoh_set_converter (SRC_PRIVATE *psrc, int src_enum)
+zoh_set_converter (SRC_STATE *state, int src_enum)
 {	ZOH_DATA *priv = NULL ;
 
 	if (src_enum != SRC_ZERO_ORDER_HOLD)
 		return SRC_ERR_BAD_CONVERTER ;
 
-	if (psrc->private_data != NULL)
-	{	free (psrc->private_data) ;
-		psrc->private_data = NULL ;
+	if (state->private_data != NULL)
+	{	free (state->private_data) ;
+		state->private_data = NULL ;
 		} ;
 
-	if (psrc->private_data == NULL)
-	{	priv = ZERO_ALLOC (ZOH_DATA, sizeof (*priv) + psrc->channels * sizeof (float)) ;
-		psrc->private_data = priv ;
+	if (state->private_data == NULL)
+	{	priv = ZERO_ALLOC (ZOH_DATA, sizeof (*priv) + state->channels * sizeof (float)) ;
+		state->private_data = priv ;
 		} ;
 
 	if (priv == NULL)
@@ -170,14 +170,14 @@
 		return SRC_ERR_MALLOC_FAILED ;
 
 	priv->zoh_magic_marker = ZOH_MAGIC_MARKER ;
-	priv->channels = psrc->channels ;
+	priv->channels = state->channels ;
 
-	psrc->const_process = zoh_vari_process ;
-	psrc->vari_process = zoh_vari_process ;
-	psrc->reset = zoh_reset ;
-	psrc->copy = zoh_copy ;
+	state->const_process = zoh_vari_process ;
+	state->vari_process = zoh_vari_process ;
+	state->reset = zoh_reset ;
+	state->copy = zoh_copy ;
 
-	zoh_reset (psrc) ;
+	zoh_reset (state) ;
 
 	return SRC_ERR_NO_ERROR ;
 } /* zoh_set_converter */
@@ -186,14 +186,14 @@
 */
 
 static void
-zoh_reset (SRC_PRIVATE *psrc)
+zoh_reset (SRC_STATE *state)
 {	ZOH_DATA *priv ;
 
-	priv = (ZOH_DATA*) psrc->private_data ;
+	priv = (ZOH_DATA*) state->private_data ;
 	if (priv == NULL)
 		return ;
 
-	priv->channels = psrc->channels ;
+	priv->channels = state->channels ;
 	priv->reset = 1 ;
 	memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ;
 
@@ -201,7 +201,7 @@
 } /* zoh_reset */
 
 static int
-zoh_copy (SRC_PRIVATE *from, SRC_PRIVATE *to)
+zoh_copy (SRC_STATE *from, SRC_STATE *to)
 {
 	if (from->private_data == NULL)
 		return SRC_ERR_NO_PRIVATE ;