shithub: libsamplerate

Download patch

ref: 09d00868afafbbeb7632e764ed658ca3a6d60d4a
parent: 0062928c4f00f253925a9cc6580066ba2ea2eee1
author: evpobr <evpobr@gmail.com>
date: Sun Oct 25 08:05:12 EDT 2020

Wrap SRC_ERR_XXX valus to SRC_ERR enum

--- a/src/common.h
+++ b/src/common.h
@@ -74,8 +74,9 @@
 	SRC_MODE_CALLBACK	= 1
 } ;
 
-enum
-{	SRC_ERR_NO_ERROR = 0,
+enum SRC_ERR
+{
+	SRC_ERR_NO_ERROR = 0,
 
 	SRC_ERR_MALLOC_FAILED,
 	SRC_ERR_BAD_STATE,
@@ -107,7 +108,7 @@
 struct SRC_STATE_tag
 {	double	last_ratio, last_position ;
 
-	int		error ;
+	enum SRC_ERR	error ;
 	int		channels ;
 
 	/* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
@@ -117,16 +118,16 @@
 	void	*private_data ;
 
 	/* Varispeed process function. */
-	int		(*vari_process) (SRC_STATE *state, SRC_DATA *data) ;
+	enum SRC_ERR	(*vari_process) (SRC_STATE *state, SRC_DATA *data) ;
 
 	/* Constant speed process function. */
-	int		(*const_process) (SRC_STATE *state, SRC_DATA *data) ;
+	enum SRC_ERR	(*const_process) (SRC_STATE *state, SRC_DATA *data) ;
 
 	/* State reset. */
-	void	(*reset) (SRC_STATE *state) ;
+	void			(*reset) (SRC_STATE *state) ;
 
 	/* State clone. */
-	int		(*copy) (SRC_STATE *from, SRC_STATE *to) ;
+	enum SRC_ERR	(*copy) (SRC_STATE *from, SRC_STATE *to) ;
 
 	/* Data specific to SRC_MODE_CALLBACK. */
 	src_callback_t	callback_func ;
@@ -139,19 +140,19 @@
 const char* sinc_get_name (int src_enum) ;
 const char* sinc_get_description (int src_enum) ;
 
-int sinc_set_converter (SRC_STATE *state, int src_enum) ;
+enum SRC_ERR 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_STATE *state, int src_enum) ;
+enum SRC_ERR 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_STATE *state, int src_enum) ;
+enum SRC_ERR zoh_set_converter (SRC_STATE *state, int src_enum) ;
 
 /*----------------------------------------------------------
 **	Common static inline functions.
--- 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_STATE *state, SRC_DATA *data) ;
+static enum SRC_ERR 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) ;
+static enum SRC_ERR linear_copy (SRC_STATE *from, SRC_STATE *to) ;
 
 /*========================================================================================
 */
@@ -37,7 +37,7 @@
 /*----------------------------------------------------------------------------------------
 */
 
-static int
+static enum SRC_ERR
 linear_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	LINEAR_DATA *priv ;
 	double		src_ratio, input_index, rem ;
@@ -158,7 +158,7 @@
 	return NULL ;
 } /* linear_get_descrition */
 
-int
+enum SRC_ERR
 linear_set_converter (SRC_STATE *state, int src_enum)
 {	LINEAR_DATA *priv = NULL ;
 
@@ -209,7 +209,7 @@
 	return ;
 } /* linear_reset */
 
-static int
+static enum SRC_ERR
 linear_copy (SRC_STATE *from, SRC_STATE *to)
 {
 	if (from->private_data == NULL)
--- 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_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 enum SRC_ERR sinc_multichan_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static enum SRC_ERR sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static enum SRC_ERR sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static enum SRC_ERR sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data) ;
+static enum SRC_ERR 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_STATE *state) ;
-static int sinc_copy (SRC_STATE *from, SRC_STATE *to) ;
+static enum SRC_ERR sinc_copy (SRC_STATE *from, SRC_STATE *to) ;
 
 static inline increment_t
 double_to_fp (double x)
@@ -142,7 +142,7 @@
 	return NULL ;
 } /* sinc_get_descrition */
 
-int
+enum SRC_ERR
 sinc_set_converter (SRC_STATE *state, int src_enum)
 {	SINC_FILTER *filter, temp_filter ;
 	increment_t count ;
@@ -262,7 +262,7 @@
 	memset (filter->buffer + filter->b_len, 0xAA, filter->channels * sizeof (filter->buffer [0])) ;
 } /* sinc_reset */
 
-static int
+static enum SRC_ERR
 sinc_copy (SRC_STATE *from, SRC_STATE *to)
 {
 	if (from->private_data == NULL)
@@ -345,7 +345,7 @@
 	return (left + right) ;
 } /* calc_output_single */
 
-static int
+static enum SRC_ERR
 sinc_mono_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -501,7 +501,7 @@
 		output [ch] = (float) (scale * (left [ch] + right [ch])) ;
 } /* calc_output_stereo */
 
-static int
+static enum SRC_ERR
 sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -657,7 +657,7 @@
 		output [ch] = (float) (scale * (left [ch] + right [ch])) ;
 } /* calc_output_quad */
 
-static int
+static enum SRC_ERR
 sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -812,7 +812,7 @@
 		output [ch] = (float) (scale * (left [ch] + right [ch])) ;
 } /* calc_output_hex */
 
-static int
+static enum SRC_ERR
 sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -977,7 +977,7 @@
 	return ;
 } /* calc_output_multi */
 
-static int
+static enum SRC_ERR
 sinc_multichan_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	SINC_FILTER *filter ;
 	double		input_index, src_ratio, count, float_increment, terminate, rem ;
--- 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_STATE *state, SRC_DATA *data) ;
+static enum SRC_ERR 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) ;
+static enum SRC_ERR zoh_copy (SRC_STATE *from, SRC_STATE *to) ;
 
 /*========================================================================================
 */
@@ -35,7 +35,7 @@
 /*----------------------------------------------------------------------------------------
 */
 
-static int
+static enum SRC_ERR
 zoh_vari_process (SRC_STATE *state, SRC_DATA *data)
 {	ZOH_DATA 	*priv ;
 	double		src_ratio, input_index, rem ;
@@ -149,7 +149,7 @@
 	return NULL ;
 } /* zoh_get_descrition */
 
-int
+enum SRC_ERR
 zoh_set_converter (SRC_STATE *state, int src_enum)
 {	ZOH_DATA *priv = NULL ;
 
@@ -200,7 +200,7 @@
 	return ;
 } /* zoh_reset */
 
-static int
+static enum SRC_ERR
 zoh_copy (SRC_STATE *from, SRC_STATE *to)
 {
 	if (from->private_data == NULL)