Rename SRC_PRIVATE_tag to SRC_STATE_tag, now SRC_STATE is typedef of exsiting struct.
Showing the changes to src (5 of 5 files). Show all
Unified · Split
| @@ -98,7 +98,7 @@ enum · 97 unmodified lines | |||
| 98 | SRC_ERR_MAX_ERROR | 98 | SRC_ERR_MAX_ERROR |
| 99 | } ; | 99 | } ; |
| 100 | 100 | ||
| 101 | typedef struct SRC_PRIVATE_tag | 101 | struct SRC_STATE_tag |
| 102 | { double last_ratio, last_position ; | 102 | { double last_ratio, last_position ; |
| 103 | 103 | ||
| 104 | int error ; | 104 | int error ; |
| @@ -111,41 +111,41 @@ typedef struct SRC_PRIVATE_tag · 6 unmodified lines | |||
| 111 | void *private_data ; | 111 | void *private_data ; |
| 112 | 112 | ||
| 113 | /* Varispeed process function. */ | 113 | /* Varispeed process function. */ |
| 114 | int (*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; | 114 | int (*vari_process) (SRC_STATE *state, SRC_DATA *data) ; |
| 115 | 115 | ||
| 116 | /* Constant speed process function. */ | 116 | /* Constant speed process function. */ |
| 117 | int (*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; | 117 | int (*const_process) (SRC_STATE *state, SRC_DATA *data) ; |
| 118 | 118 | ||
| 119 | /* State reset. */ | 119 | /* State reset. */ |
| 120 | void (*reset) (struct SRC_PRIVATE_tag *psrc) ; | 120 | void (*reset) (SRC_STATE *state) ; |
| 121 | 121 | ||
| 122 | /* State clone. */ | 122 | /* State clone. */ |
| 123 | int (*copy) (struct SRC_PRIVATE_tag *from, struct SRC_PRIVATE_tag *to) ; | 123 | int (*copy) (SRC_STATE *from, SRC_STATE *to) ; |
| 124 | 124 | ||
| 125 | /* Data specific to SRC_MODE_CALLBACK. */ | 125 | /* Data specific to SRC_MODE_CALLBACK. */ |
| 126 | src_callback_t callback_func ; | 126 | src_callback_t callback_func ; |
| 127 | void *user_callback_data ; | 127 | void *user_callback_data ; |
| 128 | long saved_frames ; | 128 | long saved_frames ; |
| 129 | const float *saved_data ; | 129 | const float *saved_data ; |
| 130 | } SRC_PRIVATE ; | 130 | } ; |
| 131 | 131 | ||
| 132 | /* In src_sinc.c */ | 132 | /* In src_sinc.c */ |
| 133 | const char* sinc_get_name (int src_enum) ; | 133 | const char* sinc_get_name (int src_enum) ; |
| 134 | const char* sinc_get_description (int src_enum) ; | 134 | const char* sinc_get_description (int src_enum) ; |
| 135 | 135 | ||
| 136 | int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ; | 136 | int sinc_set_converter (SRC_STATE *state, int src_enum) ; |
| 137 | 137 | ||
| 138 | /* In src_linear.c */ | 138 | /* In src_linear.c */ |
| 139 | const char* linear_get_name (int src_enum) ; | 139 | const char* linear_get_name (int src_enum) ; |
| 140 | const char* linear_get_description (int src_enum) ; | 140 | const char* linear_get_description (int src_enum) ; |
| 141 | 141 | ||
| 142 | int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ; | 142 | int linear_set_converter (SRC_STATE *state, int src_enum) ; |
| 143 | 143 | ||
| 144 | /* In src_zoh.c */ | 144 | /* In src_zoh.c */ |
| 145 | const char* zoh_get_name (int src_enum) ; | 145 | const char* zoh_get_name (int src_enum) ; |
| 146 | const char* zoh_get_description (int src_enum) ; | 146 | const char* zoh_get_description (int src_enum) ; |
| 147 | 147 | ||
| 148 | int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ; | 148 | int zoh_set_converter (SRC_STATE *state, int src_enum) ; |
| 149 | 149 | ||
| 150 | /*---------------------------------------------------------- | 150 | /*---------------------------------------------------------- |
| 151 | ** Common static inline functions. | 151 | ** Common static inline functions. |
| @@ -16,13 +16,12 @@ · 15 unmodified lines | |||
| 16 | #include "samplerate.h" | 16 | #include "samplerate.h" |
| 17 | #include "common.h" | 17 | #include "common.h" |
| 18 | 18 | ||
| 19 | static int psrc_set_converter (SRC_PRIVATE *psrc, int converter_type) ; | 19 | static int psrc_set_converter (SRC_STATE *state, int converter_type) ; |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | SRC_STATE * | 22 | SRC_STATE * |
| 23 | src_new (int converter_type, int channels, int *error) | 23 | src_new (int converter_type, int channels, int *error) |
| 24 | { SRC_PRIVATE *psrc ; | 24 | { |
| 25 | |||
| 26 | if (error) | 25 | if (error) |
| 27 | *error = SRC_ERR_NO_ERROR ; | 26 | *error = SRC_ERR_NO_ERROR ; |
| 28 | 27 | ||
| @@ -32,58 +31,59 @@ src_new (int converter_type, int channels, int *error) · 3 unmodified lines | |||
| 32 | return NULL ; | 31 | return NULL ; |
| 33 | } ; | 32 | } ; |
| 34 | 33 | ||
| 35 | if ((psrc = ZERO_ALLOC (SRC_PRIVATE, sizeof (*psrc))) == NULL) | 34 | SRC_STATE *state = ZERO_ALLOC (SRC_STATE, sizeof (SRC_STATE)) ; |
| 35 | if (state == NULL) | ||
| 36 | { if (error) | 36 | { if (error) |
| 37 | *error = SRC_ERR_MALLOC_FAILED ; | 37 | *error = SRC_ERR_MALLOC_FAILED ; |
| 38 | return NULL ; | 38 | return NULL ; |
| 39 | } ; | 39 | } ; |
| 40 | 40 | ||
| 41 | psrc->channels = channels ; | 41 | state->channels = channels ; |
| 42 | psrc->mode = SRC_MODE_PROCESS ; | 42 | state->mode = SRC_MODE_PROCESS ; |
| 43 | 43 | ||
| 44 | if (psrc_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR) | 44 | if (psrc_set_converter (state, converter_type) != SRC_ERR_NO_ERROR) |
| 45 | { if (error) | 45 | { if (error) |
| 46 | *error = SRC_ERR_BAD_CONVERTER ; | 46 | *error = SRC_ERR_BAD_CONVERTER ; |
| 47 | free (psrc) ; | 47 | free (state) ; |
| 48 | psrc = NULL ; | 48 | state = NULL ; |
| 49 | } ; | 49 | } ; |
| 50 | 50 | ||
| 51 | src_reset ((SRC_STATE*) psrc) ; | 51 | src_reset (state) ; |
| 52 | 52 | ||
| 53 | return (SRC_STATE*) psrc ; | 53 | return state ; |
| 54 | } /* src_new */ | 54 | } /* src_new */ |
| 55 | 55 | ||
| 56 | SRC_STATE* | 56 | SRC_STATE* |
| 57 | src_clone (SRC_STATE* orig, int *error) | 57 | src_clone (SRC_STATE* orig, int *error) |
| 58 | { | 58 | { |
| 59 | SRC_PRIVATE *psrc ; | 59 | SRC_STATE *state ; |
| 60 | int copy_error ; | 60 | int copy_error ; |
| 61 | 61 | ||
| 62 | if (error) | 62 | if (error) |
| 63 | *error = SRC_ERR_NO_ERROR ; | 63 | *error = SRC_ERR_NO_ERROR ; |
| 64 | 64 | ||
| 65 | if ((psrc = ZERO_ALLOC (SRC_PRIVATE, sizeof (*psrc))) == NULL) | 65 | if ((state = ZERO_ALLOC (SRC_STATE, sizeof (SRC_STATE))) == NULL) |
| 66 | { if (error) | 66 | { if (error) |
| 67 | *error = SRC_ERR_MALLOC_FAILED ; | 67 | *error = SRC_ERR_MALLOC_FAILED ; |
| 68 | return NULL ; | 68 | return NULL ; |
| 69 | } ; | 69 | } ; |
| 70 | 70 | ||
| 71 | SRC_PRIVATE *orig_priv = (SRC_PRIVATE*) orig ; | 71 | SRC_STATE *orig_state = orig ; |
| 72 | memcpy (psrc, orig_priv, sizeof (SRC_PRIVATE)) ; | 72 | memcpy (state, orig_state, sizeof (SRC_STATE)) ; |
| 73 | 73 | ||
| 74 | if ((copy_error = orig_priv->copy (orig_priv, psrc)) != SRC_ERR_NO_ERROR) | 74 | if ((copy_error = orig_state->copy (orig_state, state)) != SRC_ERR_NO_ERROR) |
| 75 | { if (error) | 75 | { if (error) |
| 76 | *error = copy_error ; | 76 | *error = copy_error ; |
| 77 | free (psrc) ; | 77 | free (state) ; |
| 78 | psrc = NULL ; | 78 | state = NULL ; |
| 79 | } ; | 79 | } ; |
| 80 | 80 | ||
| 81 | return (SRC_STATE*) psrc ; | 81 | return state ; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | SRC_STATE* | 84 | SRC_STATE* |
| 85 | src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data) | 85 | src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data) |
| 86 | { SRC_STATE *src_state ; | 86 | { SRC_STATE *state ; |
| 87 | 87 | ||
| 88 | if (func == NULL) | 88 | if (func == NULL) |
| 89 | { if (error) | 89 | { if (error) |
| @@ -94,28 +94,26 @@ src_callback_new (src_callback_t func, int converter_type, int channels, int *er · 4 unmodified lines | |||
| 94 | if (error != NULL) | 94 | if (error != NULL) |
| 95 | *error = 0 ; | 95 | *error = 0 ; |
| 96 | 96 | ||
| 97 | if ((src_state = src_new (converter_type, channels, error)) == NULL) | 97 | if ((state = src_new (converter_type, channels, error)) == NULL) |
| 98 | return NULL ; | 98 | return NULL ; |
| 99 | 99 | ||
| 100 | src_reset (src_state) ; | 100 | src_reset (state) ; |
| 101 | 101 | ||
| 102 | ((SRC_PRIVATE*) src_state)->mode = SRC_MODE_CALLBACK ; | 102 | state->mode = SRC_MODE_CALLBACK ; |
| 103 | ((SRC_PRIVATE*) src_state)->callback_func = func ; | 103 | state->callback_func = func ; |
| 104 | ((SRC_PRIVATE*) src_state)->user_callback_data = cb_data ; | 104 | state->user_callback_data = cb_data ; |
| 105 | 105 | ||
| 106 | return src_state ; | 106 | return state ; |
| 107 | } /* src_callback_new */ | 107 | } /* src_callback_new */ |
| 108 | 108 | ||
| 109 | SRC_STATE * | 109 | SRC_STATE * |
| 110 | src_delete (SRC_STATE *state) | 110 | src_delete (SRC_STATE *state) |
| 111 | { SRC_PRIVATE *psrc ; | 111 | { |
| 112 | 112 | if (state) | |
| 113 | psrc = (SRC_PRIVATE*) state ; | 113 | { if (state->private_data) |
| 114 | if (psrc) | 114 | free (state->private_data) ; |
| 115 | { if (psrc->private_data) | 115 | memset (state, 0, sizeof (SRC_STATE)) ; |
| 116 | free (psrc->private_data) ; | 116 | free (state) ; |
| 117 | memset (psrc, 0, sizeof (SRC_PRIVATE)) ; | ||
| 118 | free (psrc) ; | ||
| 119 | } ; | 117 | } ; |
| 120 | 118 | ||
| 121 | return NULL ; | 119 | return NULL ; |
| @@ -123,17 +121,15 @@ src_delete (SRC_STATE *state) · 1 unmodified line | |||
| 123 | 121 | ||
| 124 | int | 122 | int |
| 125 | src_process (SRC_STATE *state, SRC_DATA *data) | 123 | src_process (SRC_STATE *state, SRC_DATA *data) |
| 126 | { SRC_PRIVATE *psrc ; | 124 | { |
| 127 | int error ; | 125 | int error ; |
| 128 | 126 | ||
| 129 | psrc = (SRC_PRIVATE*) state ; | 127 | if (state == NULL) |
| 130 | |||
| 131 | if (psrc == NULL) | ||
| 132 | return SRC_ERR_BAD_STATE ; | 128 | return SRC_ERR_BAD_STATE ; |
| 133 | if (psrc->vari_process == NULL || psrc->const_process == NULL) | 129 | if (state->vari_process == NULL || state->const_process == NULL) |
| 134 | return SRC_ERR_BAD_PROC_PTR ; | 130 | return SRC_ERR_BAD_PROC_PTR ; |
| 135 | 131 | ||
| 136 | if (psrc->mode != SRC_MODE_PROCESS) | 132 | if (state->mode != SRC_MODE_PROCESS) |
| 137 | return SRC_ERR_BAD_MODE ; | 133 | return SRC_ERR_BAD_MODE ; |
| 138 | 134 | ||
| 139 | /* Check for valid SRC_DATA first. */ | 135 | /* Check for valid SRC_DATA first. */ |
| @@ -155,13 +151,13 @@ src_process (SRC_STATE *state, SRC_DATA *data) · 15 unmodified lines | |||
| 155 | data->output_frames = 0 ; | 151 | data->output_frames = 0 ; |
| 156 | 152 | ||
| 157 | if (data->data_in < data->data_out) | 153 | if (data->data_in < data->data_out) |
| 158 | { if (data->data_in + data->input_frames * psrc->channels > data->data_out) | 154 | { if (data->data_in + data->input_frames * state->channels > data->data_out) |
| 159 | { /*-printf ("\n\ndata_in: %p data_out: %p\n", | 155 | { /*-printf ("\n\ndata_in: %p data_out: %p\n", |
| 160 | (void*) (data->data_in + data->input_frames * psrc->channels), (void*) data->data_out) ;-*/ | 156 | (void*) (data->data_in + data->input_frames * psrc->channels), (void*) data->data_out) ;-*/ |
| 161 | return SRC_ERR_DATA_OVERLAP ; | 157 | return SRC_ERR_DATA_OVERLAP ; |
| 162 | } ; | 158 | } ; |
| 163 | } | 159 | } |
| 164 | else if (data->data_out + data->output_frames * psrc->channels > data->data_in) | 160 | else if (data->data_out + data->output_frames * state->channels > data->data_in) |
| 165 | { /*-printf ("\n\ndata_in : %p ouput frames: %ld data_out: %p\n", (void*) data->data_in, data->output_frames, (void*) data->data_out) ; | 161 | { /*-printf ("\n\ndata_in : %p ouput frames: %ld data_out: %p\n", (void*) data->data_in, data->output_frames, (void*) data->data_out) ; |
| 166 | 162 | ||
| 167 | printf ("data_out: %p (%p) data_in: %p\n", (void*) data->data_out, | 163 | printf ("data_out: %p (%p) data_in: %p\n", (void*) data->data_out, |
| @@ -174,21 +170,21 @@ src_process (SRC_STATE *state, SRC_DATA *data) · 6 unmodified lines | |||
| 174 | data->output_frames_gen = 0 ; | 170 | data->output_frames_gen = 0 ; |
| 175 | 171 | ||
| 176 | /* Special case for when last_ratio has not been set. */ | 172 | /* Special case for when last_ratio has not been set. */ |
| 177 | if (psrc->last_ratio < (1.0 / SRC_MAX_RATIO)) | 173 | if (state->last_ratio < (1.0 / SRC_MAX_RATIO)) |
| 178 | psrc->last_ratio = data->src_ratio ; | 174 | state->last_ratio = data->src_ratio ; |
| 179 | 175 | ||
| 180 | /* Now process. */ | 176 | /* Now process. */ |
| 181 | if (fabs (psrc->last_ratio - data->src_ratio) < 1e-15) | 177 | if (fabs (state->last_ratio - data->src_ratio) < 1e-15) |
| 182 | error = psrc->const_process (psrc, data) ; | 178 | error = state->const_process (state, data) ; |
| 183 | else | 179 | else |
| 184 | error = psrc->vari_process (psrc, data) ; | 180 | error = state->vari_process (state, data) ; |
| 185 | 181 | ||
| 186 | return error ; | 182 | return error ; |
| 187 | } /* src_process */ | 183 | } /* src_process */ |
| 188 | 184 | ||
| 189 | long | 185 | long |
| 190 | src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) | 186 | src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) |
| 191 | { SRC_PRIVATE *psrc ; | 187 | { |
| 192 | SRC_DATA src_data ; | 188 | SRC_DATA src_data ; |
| 193 | 189 | ||
| 194 | long output_frames_gen ; | 190 | long output_frames_gen ; |
| @@ -200,15 +196,13 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 5 unmodified lines | |||
| 200 | if (frames <= 0) | 196 | if (frames <= 0) |
| 201 | return 0 ; | 197 | return 0 ; |
| 202 | 198 | ||
| 203 | psrc = (SRC_PRIVATE*) state ; | 199 | if (state->mode != SRC_MODE_CALLBACK) |
| 204 | 200 | { state->error = SRC_ERR_BAD_MODE ; | |
| 205 | if (psrc->mode != SRC_MODE_CALLBACK) | ||
| 206 | { psrc->error = SRC_ERR_BAD_MODE ; | ||
| 207 | return 0 ; | 201 | return 0 ; |
| 208 | } ; | 202 | } ; |
| 209 | 203 | ||
| 210 | if (psrc->callback_func == NULL) | 204 | if (state->callback_func == NULL) |
| 211 | { psrc->error = SRC_ERR_NULL_CALLBACK ; | 205 | { state->error = SRC_ERR_NULL_CALLBACK ; |
| 212 | return 0 ; | 206 | return 0 ; |
| 213 | } ; | 207 | } ; |
| 214 | 208 | ||
| @@ -216,7 +210,7 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 1 unmodified line | |||
| 216 | 210 | ||
| 217 | /* Check src_ratio is in range. */ | 211 | /* Check src_ratio is in range. */ |
| 218 | if (is_bad_src_ratio (src_ratio)) | 212 | if (is_bad_src_ratio (src_ratio)) |
| 219 | { psrc->error = SRC_ERR_BAD_SRC_RATIO ; | 213 | { state->error = SRC_ERR_BAD_SRC_RATIO ; |
| 220 | return 0 ; | 214 | return 0 ; |
| 221 | } ; | 215 | } ; |
| 222 | 216 | ||
| @@ -225,8 +219,8 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 2 unmodified lines | |||
| 225 | src_data.data_out = data ; | 219 | src_data.data_out = data ; |
| 226 | src_data.output_frames = frames ; | 220 | src_data.output_frames = frames ; |
| 227 | 221 | ||
| 228 | src_data.data_in = psrc->saved_data ; | 222 | src_data.data_in = state->saved_data ; |
| 229 | src_data.input_frames = psrc->saved_frames ; | 223 | src_data.input_frames = state->saved_frames ; |
| 230 | 224 | ||
| 231 | output_frames_gen = 0 ; | 225 | output_frames_gen = 0 ; |
| 232 | while (output_frames_gen < frames) | 226 | while (output_frames_gen < frames) |
| @@ -238,7 +232,7 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 5 unmodified lines | |||
| 238 | if (src_data.input_frames == 0) | 232 | if (src_data.input_frames == 0) |
| 239 | { float *ptr = dummy ; | 233 | { float *ptr = dummy ; |
| 240 | 234 | ||
| 241 | src_data.input_frames = psrc->callback_func (psrc->user_callback_data, &ptr) ; | 235 | src_data.input_frames = state->callback_func (state->user_callback_data, &ptr) ; |
| 242 | src_data.data_in = ptr ; | 236 | src_data.data_in = ptr ; |
| 243 | 237 | ||
| 244 | if (src_data.input_frames == 0) | 238 | if (src_data.input_frames == 0) |
| @@ -250,17 +244,17 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 5 unmodified lines | |||
| 250 | ** to SRC_MODE_PROCESS first and when we return set it back to | 244 | ** to SRC_MODE_PROCESS first and when we return set it back to |
| 251 | ** SRC_MODE_CALLBACK. | 245 | ** SRC_MODE_CALLBACK. |
| 252 | */ | 246 | */ |
| 253 | psrc->mode = SRC_MODE_PROCESS ; | 247 | state->mode = SRC_MODE_PROCESS ; |
| 254 | error = src_process (state, &src_data) ; | 248 | error = src_process (state, &src_data) ; |
| 255 | psrc->mode = SRC_MODE_CALLBACK ; | 249 | state->mode = SRC_MODE_CALLBACK ; |
| 256 | 250 | ||
| 257 | if (error != 0) | 251 | if (error != 0) |
| 258 | break ; | 252 | break ; |
| 259 | 253 | ||
| 260 | src_data.data_in += src_data.input_frames_used * psrc->channels ; | 254 | src_data.data_in += src_data.input_frames_used * state->channels ; |
| 261 | src_data.input_frames -= src_data.input_frames_used ; | 255 | src_data.input_frames -= src_data.input_frames_used ; |
| 262 | 256 | ||
| 263 | src_data.data_out += src_data.output_frames_gen * psrc->channels ; | 257 | src_data.data_out += src_data.output_frames_gen * state->channels ; |
| 264 | src_data.output_frames -= src_data.output_frames_gen ; | 258 | src_data.output_frames -= src_data.output_frames_gen ; |
| 265 | 259 | ||
| 266 | output_frames_gen += src_data.output_frames_gen ; | 260 | output_frames_gen += src_data.output_frames_gen ; |
| @@ -269,11 +263,11 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 2 unmodified lines | |||
| 269 | break ; | 263 | break ; |
| 270 | } ; | 264 | } ; |
| 271 | 265 | ||
| 272 | psrc->saved_data = src_data.data_in ; | 266 | state->saved_data = src_data.data_in ; |
| 273 | psrc->saved_frames = src_data.input_frames ; | 267 | state->saved_frames = src_data.input_frames ; |
| 274 | 268 | ||
| 275 | if (error != 0) | 269 | if (error != 0) |
| 276 | { psrc->error = error ; | 270 | { state->error = error ; |
| 277 | return 0 ; | 271 | return 0 ; |
| 278 | } ; | 272 | } ; |
| 279 | 273 | ||
| @@ -285,54 +279,47 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 5 unmodified lines | |||
| 285 | 279 | ||
| 286 | int | 280 | int |
| 287 | src_set_ratio (SRC_STATE *state, double new_ratio) | 281 | src_set_ratio (SRC_STATE *state, double new_ratio) |
| 288 | { SRC_PRIVATE *psrc ; | 282 | { |
| 289 | 283 | if (state == NULL) | |
| 290 | psrc = (SRC_PRIVATE*) state ; | ||
| 291 | |||
| 292 | if (psrc == NULL) | ||
| 293 | return SRC_ERR_BAD_STATE ; | 284 | return SRC_ERR_BAD_STATE ; |
| 294 | if (psrc->vari_process == NULL || psrc->const_process == NULL) | 285 | if (state->vari_process == NULL || state->const_process == NULL) |
| 295 | return SRC_ERR_BAD_PROC_PTR ; | 286 | return SRC_ERR_BAD_PROC_PTR ; |
| 296 | 287 | ||
| 297 | if (is_bad_src_ratio (new_ratio)) | 288 | if (is_bad_src_ratio (new_ratio)) |
| 298 | return SRC_ERR_BAD_SRC_RATIO ; | 289 | return SRC_ERR_BAD_SRC_RATIO ; |
| 299 | 290 | ||
| 300 | psrc->last_ratio = new_ratio ; | 291 | state->last_ratio = new_ratio ; |
| 301 | 292 | ||
| 302 | return SRC_ERR_NO_ERROR ; | 293 | return SRC_ERR_NO_ERROR ; |
| 303 | } /* src_set_ratio */ | 294 | } /* src_set_ratio */ |
| 304 | 295 | ||
| 305 | int | 296 | int |
| 306 | src_get_channels (SRC_STATE *state) | 297 | src_get_channels (SRC_STATE *state) |
| 307 | { SRC_PRIVATE *psrc ; | 298 | { |
| 308 | 299 | if (state == NULL) | |
| 309 | psrc = (SRC_PRIVATE*) state ; | ||
| 310 | |||
| 311 | if (psrc == NULL) | ||
| 312 | return -SRC_ERR_BAD_STATE ; | 300 | return -SRC_ERR_BAD_STATE ; |
| 313 | if (psrc->vari_process == NULL || psrc->const_process == NULL) | 301 | if (state->vari_process == NULL || state->const_process == NULL) |
| 314 | return -SRC_ERR_BAD_PROC_PTR ; | 302 | return -SRC_ERR_BAD_PROC_PTR ; |
| 315 | 303 | ||
| 316 | return psrc->channels ; | 304 | return state->channels ; |
| 317 | } /* src_get_channels */ | 305 | } /* src_get_channels */ |
| 318 | 306 | ||
| 319 | int | 307 | int |
| 320 | src_reset (SRC_STATE *state) | 308 | src_reset (SRC_STATE *state) |
| 321 | { SRC_PRIVATE *psrc ; | 309 | { |
| 322 | 310 | if (state == NULL) | |
| 323 | if ((psrc = (SRC_PRIVATE*) state) == NULL) | ||
| 324 | return SRC_ERR_BAD_STATE ; | 311 | return SRC_ERR_BAD_STATE ; |
| 325 | 312 | ||
| 326 | if (psrc->reset != NULL) | 313 | if (state->reset != NULL) |
| 327 | psrc->reset (psrc) ; | 314 | state->reset (state) ; |
| 328 | 315 | ||
| 329 | psrc->last_position = 0.0 ; | 316 | state->last_position = 0.0 ; |
| 330 | psrc->last_ratio = 0.0 ; | 317 | state->last_ratio = 0.0 ; |
| 331 | 318 | ||
| 332 | psrc->saved_data = NULL ; | 319 | state->saved_data = NULL ; |
| 333 | psrc->saved_frames = 0 ; | 320 | state->saved_frames = 0 ; |
| 334 | 321 | ||
| 335 | psrc->error = SRC_ERR_NO_ERROR ; | 322 | state->error = SRC_ERR_NO_ERROR ; |
| 336 | 323 | ||
| 337 | return SRC_ERR_NO_ERROR ; | 324 | return SRC_ERR_NO_ERROR ; |
| 338 | } /* src_reset */ | 325 | } /* src_reset */ |
| @@ -394,7 +381,7 @@ src_is_valid_ratio (double ratio) · 55 unmodified lines | |||
| 394 | int | 381 | int |
| 395 | src_error (SRC_STATE *state) | 382 | src_error (SRC_STATE *state) |
| 396 | { if (state) | 383 | { if (state) |
| 397 | return ((SRC_PRIVATE*) state)->error ; | 384 | return state->error ; |
| 398 | return SRC_ERR_NO_ERROR ; | 385 | return SRC_ERR_NO_ERROR ; |
| 399 | } /* src_error */ | 386 | } /* src_error */ |
| 400 | 387 | ||
| @@ -547,15 +534,15 @@ src_float_to_int_array (const float *in, int *out, int len) · 146 unmodified lines | |||
| 547 | */ | 534 | */ |
| 548 | 535 | ||
| 549 | static int | 536 | static int |
| 550 | psrc_set_converter (SRC_PRIVATE *psrc, int converter_type) | 537 | psrc_set_converter (SRC_STATE *state, int converter_type) |
| 551 | { | 538 | { |
| 552 | if (sinc_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR) | 539 | if (sinc_set_converter (state, converter_type) == SRC_ERR_NO_ERROR) |
| 553 | return SRC_ERR_NO_ERROR ; | 540 | return SRC_ERR_NO_ERROR ; |
| 554 | 541 | ||
| 555 | if (zoh_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR) | 542 | if (zoh_set_converter (state, converter_type) == SRC_ERR_NO_ERROR) |
| 556 | return SRC_ERR_NO_ERROR ; | 543 | return SRC_ERR_NO_ERROR ; |
| 557 | 544 | ||
| 558 | if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR) | 545 | if (linear_set_converter (state, converter_type) == SRC_ERR_NO_ERROR) |
| 559 | return SRC_ERR_NO_ERROR ; | 546 | return SRC_ERR_NO_ERROR ; |
| 560 | 547 | ||
| 561 | return SRC_ERR_BAD_CONVERTER ; | 548 | return SRC_ERR_BAD_CONVERTER ; |
| @@ -14,9 +14,9 @@ · 13 unmodified lines | |||
| 14 | #include "src_config.h" | 14 | #include "src_config.h" |
| 15 | #include "common.h" | 15 | #include "common.h" |
| 16 | 16 | ||
| 17 | static int linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 17 | static int linear_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 18 | static void linear_reset (SRC_PRIVATE *psrc) ; | 18 | static void linear_reset (SRC_STATE *state) ; |
| 19 | static int linear_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) ; | 19 | static int linear_copy (SRC_STATE *from, SRC_STATE *to) ; |
| 20 | 20 | ||
| 21 | /*======================================================================================== | 21 | /*======================================================================================== |
| 22 | */ | 22 | */ |
| @@ -38,7 +38,7 @@ typedef struct · 15 unmodified lines | |||
| 38 | */ | 38 | */ |
| 39 | 39 | ||
| 40 | static int | 40 | static int |
| 41 | linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 41 | linear_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 42 | { LINEAR_DATA *priv ; | 42 | { LINEAR_DATA *priv ; |
| 43 | double src_ratio, input_index, rem ; | 43 | double src_ratio, input_index, rem ; |
| 44 | int ch ; | 44 | int ch ; |
| @@ -46,10 +46,10 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 1 unmodified line | |||
| 46 | if (data->input_frames <= 0) | 46 | if (data->input_frames <= 0) |
| 47 | return SRC_ERR_NO_ERROR ; | 47 | return SRC_ERR_NO_ERROR ; |
| 48 | 48 | ||
| 49 | if (psrc->private_data == NULL) | 49 | if (state->private_data == NULL) |
| 50 | return SRC_ERR_NO_PRIVATE ; | 50 | return SRC_ERR_NO_PRIVATE ; |
| 51 | 51 | ||
| 52 | priv = (LINEAR_DATA*) psrc->private_data ; | 52 | priv = (LINEAR_DATA*) state->private_data ; |
| 53 | 53 | ||
| 54 | if (priv->reset) | 54 | if (priv->reset) |
| 55 | { /* If we have just been reset, set the last_value data. */ | 55 | { /* If we have just been reset, set the last_value data. */ |
| @@ -62,12 +62,12 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 62 | priv->out_count = data->output_frames * priv->channels ; | 62 | priv->out_count = data->output_frames * priv->channels ; |
| 63 | priv->in_used = priv->out_gen = 0 ; | 63 | priv->in_used = priv->out_gen = 0 ; |
| 64 | 64 | ||
| 65 | src_ratio = psrc->last_ratio ; | 65 | src_ratio = state->last_ratio ; |
| 66 | 66 | ||
| 67 | if (is_bad_src_ratio (src_ratio)) | 67 | if (is_bad_src_ratio (src_ratio)) |
| 68 | return SRC_ERR_BAD_INTERNAL_STATE ; | 68 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 69 | 69 | ||
| 70 | input_index = psrc->last_position ; | 70 | input_index = state->last_position ; |
| 71 | 71 | ||
| 72 | /* Calculate samples before first sample in input array. */ | 72 | /* Calculate samples before first sample in input array. */ |
| 73 | while (input_index < 1.0 && priv->out_gen < priv->out_count) | 73 | while (input_index < 1.0 && priv->out_gen < priv->out_count) |
| @@ -75,8 +75,8 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 1 unmodified line | |||
| 75 | if (priv->in_used + priv->channels * (1.0 + input_index) >= priv->in_count) | 75 | if (priv->in_used + priv->channels * (1.0 + input_index) >= priv->in_count) |
| 76 | break ; | 76 | break ; |
| 77 | 77 | ||
| 78 | if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) | 78 | if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) |
| 79 | src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ; | 79 | src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ; |
| 80 | 80 | ||
| 81 | for (ch = 0 ; ch < priv->channels ; ch++) | 81 | for (ch = 0 ; ch < priv->channels ; ch++) |
| 82 | { data->data_out [priv->out_gen] = (float) (priv->last_value [ch] + input_index * | 82 | { data->data_out [priv->out_gen] = (float) (priv->last_value [ch] + input_index * |
| @@ -95,8 +95,8 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 12 unmodified lines | |||
| 95 | /* Main processing loop. */ | 95 | /* Main processing loop. */ |
| 96 | while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index < priv->in_count) | 96 | while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index < priv->in_count) |
| 97 | { | 97 | { |
| 98 | if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) | 98 | if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) |
| 99 | src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ; | 99 | src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ; |
| 100 | 100 | ||
| 101 | if (SRC_DEBUG && priv->in_used < priv->channels && input_index < 1.0) | 101 | if (SRC_DEBUG && priv->in_used < priv->channels && input_index < 1.0) |
| 102 | { printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", priv->in_used, priv->channels, input_index) ; | 102 | { printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", priv->in_used, priv->channels, input_index) ; |
| @@ -122,14 +122,14 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 19 unmodified lines | |||
| 122 | priv->in_used = priv->in_count ; | 122 | priv->in_used = priv->in_count ; |
| 123 | } ; | 123 | } ; |
| 124 | 124 | ||
| 125 | psrc->last_position = input_index ; | 125 | state->last_position = input_index ; |
| 126 | 126 | ||
| 127 | if (priv->in_used > 0) | 127 | if (priv->in_used > 0) |
| 128 | for (ch = 0 ; ch < priv->channels ; ch++) | 128 | for (ch = 0 ; ch < priv->channels ; ch++) |
| 129 | priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ; | 129 | priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ; |
| 130 | 130 | ||
| 131 | /* Save current ratio rather then target ratio. */ | 131 | /* Save current ratio rather then target ratio. */ |
| 132 | psrc->last_ratio = src_ratio ; | 132 | state->last_ratio = src_ratio ; |
| 133 | 133 | ||
| 134 | data->input_frames_used = priv->in_used / priv->channels ; | 134 | data->input_frames_used = priv->in_used / priv->channels ; |
| 135 | data->output_frames_gen = priv->out_gen / priv->channels ; | 135 | data->output_frames_gen = priv->out_gen / priv->channels ; |
| @@ -159,34 +159,34 @@ linear_get_description (int src_enum) · 23 unmodified lines | |||
| 159 | } /* linear_get_descrition */ | 159 | } /* linear_get_descrition */ |
| 160 | 160 | ||
| 161 | int | 161 | int |
| 162 | linear_set_converter (SRC_PRIVATE *psrc, int src_enum) | 162 | linear_set_converter (SRC_STATE *state, int src_enum) |
| 163 | { LINEAR_DATA *priv = NULL ; | 163 | { LINEAR_DATA *priv = NULL ; |
| 164 | 164 | ||
| 165 | if (src_enum != SRC_LINEAR) | 165 | if (src_enum != SRC_LINEAR) |
| 166 | return SRC_ERR_BAD_CONVERTER ; | 166 | return SRC_ERR_BAD_CONVERTER ; |
| 167 | 167 | ||
| 168 | if (psrc->private_data != NULL) | 168 | if (state->private_data != NULL) |
| 169 | { free (psrc->private_data) ; | 169 | { free (state->private_data) ; |
| 170 | psrc->private_data = NULL ; | 170 | state->private_data = NULL ; |
| 171 | } ; | 171 | } ; |
| 172 | 172 | ||
| 173 | if (psrc->private_data == NULL) | 173 | if (state->private_data == NULL) |
| 174 | { priv = ZERO_ALLOC (LINEAR_DATA, sizeof (*priv) + psrc->channels * sizeof (float)) ; | 174 | { priv = ZERO_ALLOC (LINEAR_DATA, sizeof (*priv) + state->channels * sizeof (float)) ; |
| 175 | psrc->private_data = priv ; | 175 | state->private_data = priv ; |
| 176 | } ; | 176 | } ; |
| 177 | 177 | ||
| 178 | if (priv == NULL) | 178 | if (priv == NULL) |
| 179 | return SRC_ERR_MALLOC_FAILED ; | 179 | return SRC_ERR_MALLOC_FAILED ; |
| 180 | 180 | ||
| 181 | priv->linear_magic_marker = LINEAR_MAGIC_MARKER ; | 181 | priv->linear_magic_marker = LINEAR_MAGIC_MARKER ; |
| 182 | priv->channels = psrc->channels ; | 182 | priv->channels = state->channels ; |
| 183 | 183 | ||
| 184 | psrc->const_process = linear_vari_process ; | 184 | state->const_process = linear_vari_process ; |
| 185 | psrc->vari_process = linear_vari_process ; | 185 | state->vari_process = linear_vari_process ; |
| 186 | psrc->reset = linear_reset ; | 186 | state->reset = linear_reset ; |
| 187 | psrc->copy = linear_copy ; | 187 | state->copy = linear_copy ; |
| 188 | 188 | ||
| 189 | linear_reset (psrc) ; | 189 | linear_reset (state) ; |
| 190 | 190 | ||
| 191 | return SRC_ERR_NO_ERROR ; | 191 | return SRC_ERR_NO_ERROR ; |
| 192 | } /* linear_set_converter */ | 192 | } /* linear_set_converter */ |
| @@ -195,14 +195,14 @@ linear_set_converter (SRC_PRIVATE *psrc, int src_enum) · 2 unmodified lines | |||
| 195 | */ | 195 | */ |
| 196 | 196 | ||
| 197 | static void | 197 | static void |
| 198 | linear_reset (SRC_PRIVATE *psrc) | 198 | linear_reset (SRC_STATE *state) |
| 199 | { LINEAR_DATA *priv = NULL ; | 199 | { LINEAR_DATA *priv = NULL ; |
| 200 | 200 | ||
| 201 | priv = (LINEAR_DATA*) psrc->private_data ; | 201 | priv = (LINEAR_DATA*) state->private_data ; |
| 202 | if (priv == NULL) | 202 | if (priv == NULL) |
| 203 | return ; | 203 | return ; |
| 204 | 204 | ||
| 205 | priv->channels = psrc->channels ; | 205 | priv->channels = state->channels ; |
| 206 | priv->reset = 1 ; | 206 | priv->reset = 1 ; |
| 207 | memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ; | 207 | memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ; |
| 208 | 208 | ||
| @@ -210,7 +210,7 @@ linear_reset (SRC_PRIVATE *psrc) · 1 unmodified line | |||
| 210 | } /* linear_reset */ | 210 | } /* linear_reset */ |
| 211 | 211 | ||
| 212 | static int | 212 | static int |
| 213 | linear_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) | 213 | linear_copy (SRC_STATE *from, SRC_STATE *to) |
| 214 | { | 214 | { |
| 215 | if (from->private_data == NULL) | 215 | if (from->private_data == NULL) |
| 216 | return SRC_ERR_NO_PRIVATE ; | 216 | return SRC_ERR_NO_PRIVATE ; |
| @@ -58,16 +58,16 @@ typedef struct · 57 unmodified lines | |||
| 58 | float buffer [] ; | 58 | float buffer [] ; |
| 59 | } SINC_FILTER ; | 59 | } SINC_FILTER ; |
| 60 | 60 | ||
| 61 | static int sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 61 | static int sinc_multichan_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 62 | static int sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 62 | static int sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 63 | static int sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 63 | static int sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 64 | static int sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 64 | static int sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 65 | static int sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 65 | static int sinc_mono_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 66 | 66 | ||
| 67 | static int prepare_data (SINC_FILTER *filter, SRC_DATA *data, int half_filter_chan_len) WARN_UNUSED ; | 67 | static int prepare_data (SINC_FILTER *filter, SRC_DATA *data, int half_filter_chan_len) WARN_UNUSED ; |
| 68 | 68 | ||
| 69 | static void sinc_reset (SRC_PRIVATE *psrc) ; | 69 | static void sinc_reset (SRC_STATE *state) ; |
| 70 | static int sinc_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) ; | 70 | static int sinc_copy (SRC_STATE *from, SRC_STATE *to) ; |
| 71 | 71 | ||
| 72 | static inline increment_t | 72 | static inline increment_t |
| 73 | double_to_fp (double x) | 73 | double_to_fp (double x) |
| @@ -143,7 +143,7 @@ sinc_get_description (int src_enum) · 69 unmodified lines | |||
| 143 | } /* sinc_get_descrition */ | 143 | } /* sinc_get_descrition */ |
| 144 | 144 | ||
| 145 | int | 145 | int |
| 146 | sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) | 146 | sinc_set_converter (SRC_STATE *state, int src_enum) |
| 147 | { SINC_FILTER *filter, temp_filter ; | 147 | { SINC_FILTER *filter, temp_filter ; |
| 148 | increment_t count ; | 148 | increment_t count ; |
| 149 | uint32_t bits ; | 149 | uint32_t bits ; |
| @@ -152,43 +152,43 @@ sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) · 2 unmodified lines | |||
| 152 | if (SHIFT_BITS >= sizeof (increment_t) * 8 - 1) | 152 | if (SHIFT_BITS >= sizeof (increment_t) * 8 - 1) |
| 153 | return SRC_ERR_SHIFT_BITS ; | 153 | return SRC_ERR_SHIFT_BITS ; |
| 154 | 154 | ||
| 155 | if (psrc->private_data != NULL) | 155 | if (state->private_data != NULL) |
| 156 | { free (psrc->private_data) ; | 156 | { free (state->private_data) ; |
| 157 | psrc->private_data = NULL ; | 157 | state->private_data = NULL ; |
| 158 | } ; | 158 | } ; |
| 159 | 159 | ||
| 160 | memset (&temp_filter, 0, sizeof (temp_filter)) ; | 160 | memset (&temp_filter, 0, sizeof (temp_filter)) ; |
| 161 | 161 | ||
| 162 | temp_filter.sinc_magic_marker = SINC_MAGIC_MARKER ; | 162 | temp_filter.sinc_magic_marker = SINC_MAGIC_MARKER ; |
| 163 | temp_filter.channels = psrc->channels ; | 163 | temp_filter.channels = state->channels ; |
| 164 | 164 | ||
| 165 | if (psrc->channels > ARRAY_LEN (temp_filter.left_calc)) | 165 | if (state->channels > ARRAY_LEN (temp_filter.left_calc)) |
| 166 | return SRC_ERR_BAD_CHANNEL_COUNT ; | 166 | return SRC_ERR_BAD_CHANNEL_COUNT ; |
| 167 | else if (psrc->channels == 1) | 167 | else if (state->channels == 1) |
| 168 | { psrc->const_process = sinc_mono_vari_process ; | 168 | { state->const_process = sinc_mono_vari_process ; |
| 169 | psrc->vari_process = sinc_mono_vari_process ; | 169 | state->vari_process = sinc_mono_vari_process ; |
| 170 | } | 170 | } |
| 171 | else | 171 | else |
| 172 | if (psrc->channels == 2) | 172 | if (state->channels == 2) |
| 173 | { psrc->const_process = sinc_stereo_vari_process ; | 173 | { state->const_process = sinc_stereo_vari_process ; |
| 174 | psrc->vari_process = sinc_stereo_vari_process ; | 174 | state->vari_process = sinc_stereo_vari_process ; |
| 175 | } | 175 | } |
| 176 | else | 176 | else |
| 177 | if (psrc->channels == 4) | 177 | if (state->channels == 4) |
| 178 | { psrc->const_process = sinc_quad_vari_process ; | 178 | { state->const_process = sinc_quad_vari_process ; |
| 179 | psrc->vari_process = sinc_quad_vari_process ; | 179 | state->vari_process = sinc_quad_vari_process ; |
| 180 | } | 180 | } |
| 181 | else | 181 | else |
| 182 | if (psrc->channels == 6) | 182 | if (state->channels == 6) |
| 183 | { psrc->const_process = sinc_hex_vari_process ; | 183 | { state->const_process = sinc_hex_vari_process ; |
| 184 | psrc->vari_process = sinc_hex_vari_process ; | 184 | state->vari_process = sinc_hex_vari_process ; |
| 185 | } | 185 | } |
| 186 | else | 186 | else |
| 187 | { psrc->const_process = sinc_multichan_vari_process ; | 187 | { state->const_process = sinc_multichan_vari_process ; |
| 188 | psrc->vari_process = sinc_multichan_vari_process ; | 188 | state->vari_process = sinc_multichan_vari_process ; |
| 189 | } ; | 189 | } ; |
| 190 | psrc->reset = sinc_reset ; | 190 | state->reset = sinc_reset ; |
| 191 | psrc->copy = sinc_copy ; | 191 | state->copy = sinc_copy ; |
| 192 | 192 | ||
| 193 | switch (src_enum) | 193 | switch (src_enum) |
| 194 | { case SRC_SINC_FASTEST : | 194 | { case SRC_SINC_FASTEST : |
| @@ -229,9 +229,9 @@ sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) · 34 unmodified lines | |||
| 229 | *filter = temp_filter ; | 229 | *filter = temp_filter ; |
| 230 | memset (&temp_filter, 0xEE, sizeof (temp_filter)) ; | 230 | memset (&temp_filter, 0xEE, sizeof (temp_filter)) ; |
| 231 | 231 | ||
| 232 | psrc->private_data = filter ; | 232 | state->private_data = filter ; |
| 233 | 233 | ||
| 234 | sinc_reset (psrc) ; | 234 | sinc_reset (state) ; |
| 235 | 235 | ||
| 236 | count = filter->coeff_half_len ; | 236 | count = filter->coeff_half_len ; |
| 237 | for (bits = 0 ; (MAKE_INCREMENT_T (1) << bits) < count ; bits++) | 237 | for (bits = 0 ; (MAKE_INCREMENT_T (1) << bits) < count ; bits++) |
| @@ -244,10 +244,10 @@ sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) · 6 unmodified lines | |||
| 244 | } /* sinc_set_converter */ | 244 | } /* sinc_set_converter */ |
| 245 | 245 | ||
| 246 | static void | 246 | static void |
| 247 | sinc_reset (SRC_PRIVATE *psrc) | 247 | sinc_reset (SRC_STATE *state) |
| 248 | { SINC_FILTER *filter ; | 248 | { SINC_FILTER *filter ; |
| 249 | 249 | ||
| 250 | filter = (SINC_FILTER*) psrc->private_data ; | 250 | filter = (SINC_FILTER*) state->private_data ; |
| 251 | if (filter == NULL) | 251 | if (filter == NULL) |
| 252 | return ; | 252 | return ; |
| 253 | 253 | ||
| @@ -263,7 +263,7 @@ sinc_reset (SRC_PRIVATE *psrc) · 9 unmodified lines | |||
| 263 | } /* sinc_reset */ | 263 | } /* sinc_reset */ |
| 264 | 264 | ||
| 265 | static int | 265 | static int |
| 266 | sinc_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) | 266 | sinc_copy (SRC_STATE *from, SRC_STATE *to) |
| 267 | { | 267 | { |
| 268 | if (from->private_data == NULL) | 268 | if (from->private_data == NULL) |
| 269 | return SRC_ERR_NO_PRIVATE ; | 269 | return SRC_ERR_NO_PRIVATE ; |
| @@ -346,16 +346,16 @@ calc_output_single (SINC_FILTER *filter, increment_t increment, increment_t star · 76 unmodified lines | |||
| 346 | } /* calc_output_single */ | 346 | } /* calc_output_single */ |
| 347 | 347 | ||
| 348 | static int | 348 | static int |
| 349 | sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 349 | sinc_mono_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 350 | { SINC_FILTER *filter ; | 350 | { SINC_FILTER *filter ; |
| 351 | double input_index, src_ratio, count, float_increment, terminate, rem ; | 351 | double input_index, src_ratio, count, float_increment, terminate, rem ; |
| 352 | increment_t increment, start_filter_index ; | 352 | increment_t increment, start_filter_index ; |
| 353 | int half_filter_chan_len, samples_in_hand ; | 353 | int half_filter_chan_len, samples_in_hand ; |
| 354 | 354 | ||
| 355 | if (psrc->private_data == NULL) | 355 | if (state->private_data == NULL) |
| 356 | return SRC_ERR_NO_PRIVATE ; | 356 | return SRC_ERR_NO_PRIVATE ; |
| 357 | 357 | ||
| 358 | filter = (SINC_FILTER*) psrc->private_data ; | 358 | filter = (SINC_FILTER*) state->private_data ; |
| 359 | 359 | ||
| 360 | /* If there is not a problem, this will be optimised out. */ | 360 | /* If there is not a problem, this will be optimised out. */ |
| 361 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) | 361 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) |
| @@ -365,20 +365,20 @@ sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 3 unmodified lines | |||
| 365 | filter->out_count = data->output_frames * filter->channels ; | 365 | filter->out_count = data->output_frames * filter->channels ; |
| 366 | filter->in_used = filter->out_gen = 0 ; | 366 | filter->in_used = filter->out_gen = 0 ; |
| 367 | 367 | ||
| 368 | src_ratio = psrc->last_ratio ; | 368 | src_ratio = state->last_ratio ; |
| 369 | 369 | ||
| 370 | if (is_bad_src_ratio (src_ratio)) | 370 | if (is_bad_src_ratio (src_ratio)) |
| 371 | return SRC_ERR_BAD_INTERNAL_STATE ; | 371 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 372 | 372 | ||
| 373 | /* Check the sample rate ratio wrt the buffer len. */ | 373 | /* Check the sample rate ratio wrt the buffer len. */ |
| 374 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; | 374 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; |
| 375 | if (MIN (psrc->last_ratio, data->src_ratio) < 1.0) | 375 | if (MIN (state->last_ratio, data->src_ratio) < 1.0) |
| 376 | count /= MIN (psrc->last_ratio, data->src_ratio) ; | 376 | count /= MIN (state->last_ratio, data->src_ratio) ; |
| 377 | 377 | ||
| 378 | /* Maximum coefficientson either side of center point. */ | 378 | /* Maximum coefficientson either side of center point. */ |
| 379 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; | 379 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; |
| 380 | 380 | ||
| 381 | input_index = psrc->last_position ; | 381 | input_index = state->last_position ; |
| 382 | 382 | ||
| 383 | rem = fmod_one (input_index) ; | 383 | rem = fmod_one (input_index) ; |
| 384 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; | 384 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; |
| @@ -393,8 +393,8 @@ sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 8 unmodified lines | |||
| 393 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 393 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 394 | 394 | ||
| 395 | if (samples_in_hand <= half_filter_chan_len) | 395 | if (samples_in_hand <= half_filter_chan_len) |
| 396 | { if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0) | 396 | { if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0) |
| 397 | return psrc->error ; | 397 | return state->error ; |
| 398 | 398 | ||
| 399 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 399 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 400 | if (samples_in_hand <= half_filter_chan_len) | 400 | if (samples_in_hand <= half_filter_chan_len) |
| @@ -407,8 +407,8 @@ sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 407 | break ; | 407 | break ; |
| 408 | } ; | 408 | } ; |
| 409 | 409 | ||
| 410 | if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10) | 410 | if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10) |
| 411 | src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ; | 411 | src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ; |
| 412 | 412 | ||
| 413 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; | 413 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; |
| 414 | increment = double_to_fp (float_increment) ; | 414 | increment = double_to_fp (float_increment) ; |
| @@ -427,10 +427,10 @@ sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 12 unmodified lines | |||
| 427 | input_index = rem ; | 427 | input_index = rem ; |
| 428 | } ; | 428 | } ; |
| 429 | 429 | ||
| 430 | psrc->last_position = input_index ; | 430 | state->last_position = input_index ; |
| 431 | 431 | ||
| 432 | /* Save current ratio rather then target ratio. */ | 432 | /* Save current ratio rather then target ratio. */ |
| 433 | psrc->last_ratio = src_ratio ; | 433 | state->last_ratio = src_ratio ; |
| 434 | 434 | ||
| 435 | data->input_frames_used = filter->in_used / filter->channels ; | 435 | data->input_frames_used = filter->in_used / filter->channels ; |
| 436 | data->output_frames_gen = filter->out_gen / filter->channels ; | 436 | data->output_frames_gen = filter->out_gen / filter->channels ; |
| @@ -502,16 +502,16 @@ calc_output_stereo (SINC_FILTER *filter, increment_t increment, increment_t star · 65 unmodified lines | |||
| 502 | } /* calc_output_stereo */ | 502 | } /* calc_output_stereo */ |
| 503 | 503 | ||
| 504 | static int | 504 | static int |
| 505 | sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 505 | sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 506 | { SINC_FILTER *filter ; | 506 | { SINC_FILTER *filter ; |
| 507 | double input_index, src_ratio, count, float_increment, terminate, rem ; | 507 | double input_index, src_ratio, count, float_increment, terminate, rem ; |
| 508 | increment_t increment, start_filter_index ; | 508 | increment_t increment, start_filter_index ; |
| 509 | int half_filter_chan_len, samples_in_hand ; | 509 | int half_filter_chan_len, samples_in_hand ; |
| 510 | 510 | ||
| 511 | if (psrc->private_data == NULL) | 511 | if (state->private_data == NULL) |
| 512 | return SRC_ERR_NO_PRIVATE ; | 512 | return SRC_ERR_NO_PRIVATE ; |
| 513 | 513 | ||
| 514 | filter = (SINC_FILTER*) psrc->private_data ; | 514 | filter = (SINC_FILTER*) state->private_data ; |
| 515 | 515 | ||
| 516 | /* If there is not a problem, this will be optimised out. */ | 516 | /* If there is not a problem, this will be optimised out. */ |
| 517 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) | 517 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) |
| @@ -521,20 +521,20 @@ sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 3 unmodified lines | |||
| 521 | filter->out_count = data->output_frames * filter->channels ; | 521 | filter->out_count = data->output_frames * filter->channels ; |
| 522 | filter->in_used = filter->out_gen = 0 ; | 522 | filter->in_used = filter->out_gen = 0 ; |
| 523 | 523 | ||
| 524 | src_ratio = psrc->last_ratio ; | 524 | src_ratio = state->last_ratio ; |
| 525 | 525 | ||
| 526 | if (is_bad_src_ratio (src_ratio)) | 526 | if (is_bad_src_ratio (src_ratio)) |
| 527 | return SRC_ERR_BAD_INTERNAL_STATE ; | 527 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 528 | 528 | ||
| 529 | /* Check the sample rate ratio wrt the buffer len. */ | 529 | /* Check the sample rate ratio wrt the buffer len. */ |
| 530 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; | 530 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; |
| 531 | if (MIN (psrc->last_ratio, data->src_ratio) < 1.0) | 531 | if (MIN (state->last_ratio, data->src_ratio) < 1.0) |
| 532 | count /= MIN (psrc->last_ratio, data->src_ratio) ; | 532 | count /= MIN (state->last_ratio, data->src_ratio) ; |
| 533 | 533 | ||
| 534 | /* Maximum coefficientson either side of center point. */ | 534 | /* Maximum coefficientson either side of center point. */ |
| 535 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; | 535 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; |
| 536 | 536 | ||
| 537 | input_index = psrc->last_position ; | 537 | input_index = state->last_position ; |
| 538 | 538 | ||
| 539 | rem = fmod_one (input_index) ; | 539 | rem = fmod_one (input_index) ; |
| 540 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; | 540 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; |
| @@ -549,8 +549,8 @@ sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 8 unmodified lines | |||
| 549 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 549 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 550 | 550 | ||
| 551 | if (samples_in_hand <= half_filter_chan_len) | 551 | if (samples_in_hand <= half_filter_chan_len) |
| 552 | { if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0) | 552 | { if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0) |
| 553 | return psrc->error ; | 553 | return state->error ; |
| 554 | 554 | ||
| 555 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 555 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 556 | if (samples_in_hand <= half_filter_chan_len) | 556 | if (samples_in_hand <= half_filter_chan_len) |
| @@ -563,8 +563,8 @@ sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 563 | break ; | 563 | break ; |
| 564 | } ; | 564 | } ; |
| 565 | 565 | ||
| 566 | if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10) | 566 | if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10) |
| 567 | src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ; | 567 | src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ; |
| 568 | 568 | ||
| 569 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; | 569 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; |
| 570 | increment = double_to_fp (float_increment) ; | 570 | increment = double_to_fp (float_increment) ; |
| @@ -582,10 +582,10 @@ sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 11 unmodified lines | |||
| 582 | input_index = rem ; | 582 | input_index = rem ; |
| 583 | } ; | 583 | } ; |
| 584 | 584 | ||
| 585 | psrc->last_position = input_index ; | 585 | state->last_position = input_index ; |
| 586 | 586 | ||
| 587 | /* Save current ratio rather then target ratio. */ | 587 | /* Save current ratio rather then target ratio. */ |
| 588 | psrc->last_ratio = src_ratio ; | 588 | state->last_ratio = src_ratio ; |
| 589 | 589 | ||
| 590 | data->input_frames_used = filter->in_used / filter->channels ; | 590 | data->input_frames_used = filter->in_used / filter->channels ; |
| 591 | data->output_frames_gen = filter->out_gen / filter->channels ; | 591 | data->output_frames_gen = filter->out_gen / filter->channels ; |
| @@ -658,16 +658,16 @@ calc_output_quad (SINC_FILTER *filter, increment_t increment, increment_t start_ · 66 unmodified lines | |||
| 658 | } /* calc_output_quad */ | 658 | } /* calc_output_quad */ |
| 659 | 659 | ||
| 660 | static int | 660 | static int |
| 661 | sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 661 | sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 662 | { SINC_FILTER *filter ; | 662 | { SINC_FILTER *filter ; |
| 663 | double input_index, src_ratio, count, float_increment, terminate, rem ; | 663 | double input_index, src_ratio, count, float_increment, terminate, rem ; |
| 664 | increment_t increment, start_filter_index ; | 664 | increment_t increment, start_filter_index ; |
| 665 | int half_filter_chan_len, samples_in_hand ; | 665 | int half_filter_chan_len, samples_in_hand ; |
| 666 | 666 | ||
| 667 | if (psrc->private_data == NULL) | 667 | if (state->private_data == NULL) |
| 668 | return SRC_ERR_NO_PRIVATE ; | 668 | return SRC_ERR_NO_PRIVATE ; |
| 669 | 669 | ||
| 670 | filter = (SINC_FILTER*) psrc->private_data ; | 670 | filter = (SINC_FILTER*) state->private_data ; |
| 671 | 671 | ||
| 672 | /* If there is not a problem, this will be optimised out. */ | 672 | /* If there is not a problem, this will be optimised out. */ |
| 673 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) | 673 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) |
| @@ -677,20 +677,20 @@ sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 3 unmodified lines | |||
| 677 | filter->out_count = data->output_frames * filter->channels ; | 677 | filter->out_count = data->output_frames * filter->channels ; |
| 678 | filter->in_used = filter->out_gen = 0 ; | 678 | filter->in_used = filter->out_gen = 0 ; |
| 679 | 679 | ||
| 680 | src_ratio = psrc->last_ratio ; | 680 | src_ratio = state->last_ratio ; |
| 681 | 681 | ||
| 682 | if (is_bad_src_ratio (src_ratio)) | 682 | if (is_bad_src_ratio (src_ratio)) |
| 683 | return SRC_ERR_BAD_INTERNAL_STATE ; | 683 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 684 | 684 | ||
| 685 | /* Check the sample rate ratio wrt the buffer len. */ | 685 | /* Check the sample rate ratio wrt the buffer len. */ |
| 686 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; | 686 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; |
| 687 | if (MIN (psrc->last_ratio, data->src_ratio) < 1.0) | 687 | if (MIN (state->last_ratio, data->src_ratio) < 1.0) |
| 688 | count /= MIN (psrc->last_ratio, data->src_ratio) ; | 688 | count /= MIN (state->last_ratio, data->src_ratio) ; |
| 689 | 689 | ||
| 690 | /* Maximum coefficientson either side of center point. */ | 690 | /* Maximum coefficientson either side of center point. */ |
| 691 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; | 691 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; |
| 692 | 692 | ||
| 693 | input_index = psrc->last_position ; | 693 | input_index = state->last_position ; |
| 694 | 694 | ||
| 695 | rem = fmod_one (input_index) ; | 695 | rem = fmod_one (input_index) ; |
| 696 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; | 696 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; |
| @@ -705,8 +705,8 @@ sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 8 unmodified lines | |||
| 705 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 705 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 706 | 706 | ||
| 707 | if (samples_in_hand <= half_filter_chan_len) | 707 | if (samples_in_hand <= half_filter_chan_len) |
| 708 | { if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0) | 708 | { if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0) |
| 709 | return psrc->error ; | 709 | return state->error ; |
| 710 | 710 | ||
| 711 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 711 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 712 | if (samples_in_hand <= half_filter_chan_len) | 712 | if (samples_in_hand <= half_filter_chan_len) |
| @@ -719,8 +719,8 @@ sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 719 | break ; | 719 | break ; |
| 720 | } ; | 720 | } ; |
| 721 | 721 | ||
| 722 | if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10) | 722 | if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10) |
| 723 | src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ; | 723 | src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ; |
| 724 | 724 | ||
| 725 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; | 725 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; |
| 726 | increment = double_to_fp (float_increment) ; | 726 | increment = double_to_fp (float_increment) ; |
| @@ -738,10 +738,10 @@ sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 11 unmodified lines | |||
| 738 | input_index = rem ; | 738 | input_index = rem ; |
| 739 | } ; | 739 | } ; |
| 740 | 740 | ||
| 741 | psrc->last_position = input_index ; | 741 | state->last_position = input_index ; |
| 742 | 742 | ||
| 743 | /* Save current ratio rather then target ratio. */ | 743 | /* Save current ratio rather then target ratio. */ |
| 744 | psrc->last_ratio = src_ratio ; | 744 | state->last_ratio = src_ratio ; |
| 745 | 745 | ||
| 746 | data->input_frames_used = filter->in_used / filter->channels ; | 746 | data->input_frames_used = filter->in_used / filter->channels ; |
| 747 | data->output_frames_gen = filter->out_gen / filter->channels ; | 747 | data->output_frames_gen = filter->out_gen / filter->channels ; |
| @@ -813,16 +813,16 @@ calc_output_hex (SINC_FILTER *filter, increment_t increment, increment_t start_f · 65 unmodified lines | |||
| 813 | } /* calc_output_hex */ | 813 | } /* calc_output_hex */ |
| 814 | 814 | ||
| 815 | static int | 815 | static int |
| 816 | sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 816 | sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 817 | { SINC_FILTER *filter ; | 817 | { SINC_FILTER *filter ; |
| 818 | double input_index, src_ratio, count, float_increment, terminate, rem ; | 818 | double input_index, src_ratio, count, float_increment, terminate, rem ; |
| 819 | increment_t increment, start_filter_index ; | 819 | increment_t increment, start_filter_index ; |
| 820 | int half_filter_chan_len, samples_in_hand ; | 820 | int half_filter_chan_len, samples_in_hand ; |
| 821 | 821 | ||
| 822 | if (psrc->private_data == NULL) | 822 | if (state->private_data == NULL) |
| 823 | return SRC_ERR_NO_PRIVATE ; | 823 | return SRC_ERR_NO_PRIVATE ; |
| 824 | 824 | ||
| 825 | filter = (SINC_FILTER*) psrc->private_data ; | 825 | filter = (SINC_FILTER*) state->private_data ; |
| 826 | 826 | ||
| 827 | /* If there is not a problem, this will be optimised out. */ | 827 | /* If there is not a problem, this will be optimised out. */ |
| 828 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) | 828 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) |
| @@ -832,20 +832,20 @@ sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 3 unmodified lines | |||
| 832 | filter->out_count = data->output_frames * filter->channels ; | 832 | filter->out_count = data->output_frames * filter->channels ; |
| 833 | filter->in_used = filter->out_gen = 0 ; | 833 | filter->in_used = filter->out_gen = 0 ; |
| 834 | 834 | ||
| 835 | src_ratio = psrc->last_ratio ; | 835 | src_ratio = state->last_ratio ; |
| 836 | 836 | ||
| 837 | if (is_bad_src_ratio (src_ratio)) | 837 | if (is_bad_src_ratio (src_ratio)) |
| 838 | return SRC_ERR_BAD_INTERNAL_STATE ; | 838 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 839 | 839 | ||
| 840 | /* Check the sample rate ratio wrt the buffer len. */ | 840 | /* Check the sample rate ratio wrt the buffer len. */ |
| 841 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; | 841 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; |
| 842 | if (MIN (psrc->last_ratio, data->src_ratio) < 1.0) | 842 | if (MIN (state->last_ratio, data->src_ratio) < 1.0) |
| 843 | count /= MIN (psrc->last_ratio, data->src_ratio) ; | 843 | count /= MIN (state->last_ratio, data->src_ratio) ; |
| 844 | 844 | ||
| 845 | /* Maximum coefficientson either side of center point. */ | 845 | /* Maximum coefficientson either side of center point. */ |
| 846 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; | 846 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; |
| 847 | 847 | ||
| 848 | input_index = psrc->last_position ; | 848 | input_index = state->last_position ; |
| 849 | 849 | ||
| 850 | rem = fmod_one (input_index) ; | 850 | rem = fmod_one (input_index) ; |
| 851 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; | 851 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; |
| @@ -860,8 +860,8 @@ sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 8 unmodified lines | |||
| 860 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 860 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 861 | 861 | ||
| 862 | if (samples_in_hand <= half_filter_chan_len) | 862 | if (samples_in_hand <= half_filter_chan_len) |
| 863 | { if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0) | 863 | { if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0) |
| 864 | return psrc->error ; | 864 | return state->error ; |
| 865 | 865 | ||
| 866 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 866 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 867 | if (samples_in_hand <= half_filter_chan_len) | 867 | if (samples_in_hand <= half_filter_chan_len) |
| @@ -874,8 +874,8 @@ sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 874 | break ; | 874 | break ; |
| 875 | } ; | 875 | } ; |
| 876 | 876 | ||
| 877 | if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10) | 877 | if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10) |
| 878 | src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ; | 878 | src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ; |
| 879 | 879 | ||
| 880 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; | 880 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; |
| 881 | increment = double_to_fp (float_increment) ; | 881 | increment = double_to_fp (float_increment) ; |
| @@ -893,10 +893,10 @@ sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 11 unmodified lines | |||
| 893 | input_index = rem ; | 893 | input_index = rem ; |
| 894 | } ; | 894 | } ; |
| 895 | 895 | ||
| 896 | psrc->last_position = input_index ; | 896 | state->last_position = input_index ; |
| 897 | 897 | ||
| 898 | /* Save current ratio rather then target ratio. */ | 898 | /* Save current ratio rather then target ratio. */ |
| 899 | psrc->last_ratio = src_ratio ; | 899 | state->last_ratio = src_ratio ; |
| 900 | 900 | ||
| 901 | data->input_frames_used = filter->in_used / filter->channels ; | 901 | data->input_frames_used = filter->in_used / filter->channels ; |
| 902 | data->output_frames_gen = filter->out_gen / filter->channels ; | 902 | data->output_frames_gen = filter->out_gen / filter->channels ; |
| @@ -978,16 +978,16 @@ calc_output_multi (SINC_FILTER *filter, increment_t increment, increment_t start · 75 unmodified lines | |||
| 978 | } /* calc_output_multi */ | 978 | } /* calc_output_multi */ |
| 979 | 979 | ||
| 980 | static int | 980 | static int |
| 981 | sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 981 | sinc_multichan_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 982 | { SINC_FILTER *filter ; | 982 | { SINC_FILTER *filter ; |
| 983 | double input_index, src_ratio, count, float_increment, terminate, rem ; | 983 | double input_index, src_ratio, count, float_increment, terminate, rem ; |
| 984 | increment_t increment, start_filter_index ; | 984 | increment_t increment, start_filter_index ; |
| 985 | int half_filter_chan_len, samples_in_hand ; | 985 | int half_filter_chan_len, samples_in_hand ; |
| 986 | 986 | ||
| 987 | if (psrc->private_data == NULL) | 987 | if (state->private_data == NULL) |
| 988 | return SRC_ERR_NO_PRIVATE ; | 988 | return SRC_ERR_NO_PRIVATE ; |
| 989 | 989 | ||
| 990 | filter = (SINC_FILTER*) psrc->private_data ; | 990 | filter = (SINC_FILTER*) state->private_data ; |
| 991 | 991 | ||
| 992 | /* If there is not a problem, this will be optimised out. */ | 992 | /* If there is not a problem, this will be optimised out. */ |
| 993 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) | 993 | if (sizeof (filter->buffer [0]) != sizeof (data->data_in [0])) |
| @@ -997,20 +997,20 @@ sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 3 unmodified lines | |||
| 997 | filter->out_count = data->output_frames * filter->channels ; | 997 | filter->out_count = data->output_frames * filter->channels ; |
| 998 | filter->in_used = filter->out_gen = 0 ; | 998 | filter->in_used = filter->out_gen = 0 ; |
| 999 | 999 | ||
| 1000 | src_ratio = psrc->last_ratio ; | 1000 | src_ratio = state->last_ratio ; |
| 1001 | 1001 | ||
| 1002 | if (is_bad_src_ratio (src_ratio)) | 1002 | if (is_bad_src_ratio (src_ratio)) |
| 1003 | return SRC_ERR_BAD_INTERNAL_STATE ; | 1003 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 1004 | 1004 | ||
| 1005 | /* Check the sample rate ratio wrt the buffer len. */ | 1005 | /* Check the sample rate ratio wrt the buffer len. */ |
| 1006 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; | 1006 | count = (filter->coeff_half_len + 2.0) / filter->index_inc ; |
| 1007 | if (MIN (psrc->last_ratio, data->src_ratio) < 1.0) | 1007 | if (MIN (state->last_ratio, data->src_ratio) < 1.0) |
| 1008 | count /= MIN (psrc->last_ratio, data->src_ratio) ; | 1008 | count /= MIN (state->last_ratio, data->src_ratio) ; |
| 1009 | 1009 | ||
| 1010 | /* Maximum coefficientson either side of center point. */ | 1010 | /* Maximum coefficientson either side of center point. */ |
| 1011 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; | 1011 | half_filter_chan_len = filter->channels * (int) (lrint (count) + 1) ; |
| 1012 | 1012 | ||
| 1013 | input_index = psrc->last_position ; | 1013 | input_index = state->last_position ; |
| 1014 | 1014 | ||
| 1015 | rem = fmod_one (input_index) ; | 1015 | rem = fmod_one (input_index) ; |
| 1016 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; | 1016 | filter->b_current = (filter->b_current + filter->channels * lrint (input_index - rem)) % filter->b_len ; |
| @@ -1025,8 +1025,8 @@ sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 8 unmodified lines | |||
| 1025 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 1025 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 1026 | 1026 | ||
| 1027 | if (samples_in_hand <= half_filter_chan_len) | 1027 | if (samples_in_hand <= half_filter_chan_len) |
| 1028 | { if ((psrc->error = prepare_data (filter, data, half_filter_chan_len)) != 0) | 1028 | { if ((state->error = prepare_data (filter, data, half_filter_chan_len)) != 0) |
| 1029 | return psrc->error ; | 1029 | return state->error ; |
| 1030 | 1030 | ||
| 1031 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; | 1031 | samples_in_hand = (filter->b_end - filter->b_current + filter->b_len) % filter->b_len ; |
| 1032 | if (samples_in_hand <= half_filter_chan_len) | 1032 | if (samples_in_hand <= half_filter_chan_len) |
| @@ -1039,8 +1039,8 @@ sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 1039 | break ; | 1039 | break ; |
| 1040 | } ; | 1040 | } ; |
| 1041 | 1041 | ||
| 1042 | if (filter->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > 1e-10) | 1042 | if (filter->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > 1e-10) |
| 1043 | src_ratio = psrc->last_ratio + filter->out_gen * (data->src_ratio - psrc->last_ratio) / filter->out_count ; | 1043 | src_ratio = state->last_ratio + filter->out_gen * (data->src_ratio - state->last_ratio) / filter->out_count ; |
| 1044 | 1044 | ||
| 1045 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; | 1045 | float_increment = filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ; |
| 1046 | increment = double_to_fp (float_increment) ; | 1046 | increment = double_to_fp (float_increment) ; |
| @@ -1048,7 +1048,7 @@ sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 1 unmodified line | |||
| 1048 | start_filter_index = double_to_fp (input_index * float_increment) ; | 1048 | start_filter_index = double_to_fp (input_index * float_increment) ; |
| 1049 | 1049 | ||
| 1050 | calc_output_multi (filter, increment, start_filter_index, filter->channels, float_increment / filter->index_inc, data->data_out + filter->out_gen) ; | 1050 | calc_output_multi (filter, increment, start_filter_index, filter->channels, float_increment / filter->index_inc, data->data_out + filter->out_gen) ; |
| 1051 | filter->out_gen += psrc->channels ; | 1051 | filter->out_gen += state->channels ; |
| 1052 | 1052 | ||
| 1053 | /* Figure out the next index. */ | 1053 | /* Figure out the next index. */ |
| 1054 | input_index += 1.0 / src_ratio ; | 1054 | input_index += 1.0 / src_ratio ; |
| @@ -1058,10 +1058,10 @@ sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 3 unmodified lines | |||
| 1058 | input_index = rem ; | 1058 | input_index = rem ; |
| 1059 | } ; | 1059 | } ; |
| 1060 | 1060 | ||
| 1061 | psrc->last_position = input_index ; | 1061 | state->last_position = input_index ; |
| 1062 | 1062 | ||
| 1063 | /* Save current ratio rather then target ratio. */ | 1063 | /* Save current ratio rather then target ratio. */ |
| 1064 | psrc->last_ratio = src_ratio ; | 1064 | state->last_ratio = src_ratio ; |
| 1065 | 1065 | ||
| 1066 | data->input_frames_used = filter->in_used / filter->channels ; | 1066 | data->input_frames_used = filter->in_used / filter->channels ; |
| 1067 | data->output_frames_gen = filter->out_gen / filter->channels ; | 1067 | data->output_frames_gen = filter->out_gen / filter->channels ; |
| @@ -14,9 +14,9 @@ · 13 unmodified lines | |||
| 14 | #include "src_config.h" | 14 | #include "src_config.h" |
| 15 | #include "common.h" | 15 | #include "common.h" |
| 16 | 16 | ||
| 17 | static int zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; | 17 | static int zoh_vari_process (SRC_STATE *state, SRC_DATA *data) ; |
| 18 | static void zoh_reset (SRC_PRIVATE *psrc) ; | 18 | static void zoh_reset (SRC_STATE *state) ; |
| 19 | static int zoh_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) ; | 19 | static int zoh_copy (SRC_STATE *from, SRC_STATE *to) ; |
| 20 | 20 | ||
| 21 | /*======================================================================================== | 21 | /*======================================================================================== |
| 22 | */ | 22 | */ |
| @@ -36,7 +36,7 @@ typedef struct · 13 unmodified lines | |||
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | static int | 38 | static int |
| 39 | zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) | 39 | zoh_vari_process (SRC_STATE *state, SRC_DATA *data) |
| 40 | { ZOH_DATA *priv ; | 40 | { ZOH_DATA *priv ; |
| 41 | double src_ratio, input_index, rem ; | 41 | double src_ratio, input_index, rem ; |
| 42 | int ch ; | 42 | int ch ; |
| @@ -44,10 +44,10 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 1 unmodified line | |||
| 44 | if (data->input_frames <= 0) | 44 | if (data->input_frames <= 0) |
| 45 | return SRC_ERR_NO_ERROR ; | 45 | return SRC_ERR_NO_ERROR ; |
| 46 | 46 | ||
| 47 | if (psrc->private_data == NULL) | 47 | if (state->private_data == NULL) |
| 48 | return SRC_ERR_NO_PRIVATE ; | 48 | return SRC_ERR_NO_PRIVATE ; |
| 49 | 49 | ||
| 50 | priv = (ZOH_DATA*) psrc->private_data ; | 50 | priv = (ZOH_DATA*) state->private_data ; |
| 51 | 51 | ||
| 52 | if (priv->reset) | 52 | if (priv->reset) |
| 53 | { /* If we have just been reset, set the last_value data. */ | 53 | { /* If we have just been reset, set the last_value data. */ |
| @@ -60,12 +60,12 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 6 unmodified lines | |||
| 60 | priv->out_count = data->output_frames * priv->channels ; | 60 | priv->out_count = data->output_frames * priv->channels ; |
| 61 | priv->in_used = priv->out_gen = 0 ; | 61 | priv->in_used = priv->out_gen = 0 ; |
| 62 | 62 | ||
| 63 | src_ratio = psrc->last_ratio ; | 63 | src_ratio = state->last_ratio ; |
| 64 | 64 | ||
| 65 | if (is_bad_src_ratio (src_ratio)) | 65 | if (is_bad_src_ratio (src_ratio)) |
| 66 | return SRC_ERR_BAD_INTERNAL_STATE ; | 66 | return SRC_ERR_BAD_INTERNAL_STATE ; |
| 67 | 67 | ||
| 68 | input_index = psrc->last_position ; | 68 | input_index = state->last_position ; |
| 69 | 69 | ||
| 70 | /* Calculate samples before first sample in input array. */ | 70 | /* Calculate samples before first sample in input array. */ |
| 71 | while (input_index < 1.0 && priv->out_gen < priv->out_count) | 71 | while (input_index < 1.0 && priv->out_gen < priv->out_count) |
| @@ -73,8 +73,8 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 1 unmodified line | |||
| 73 | if (priv->in_used + priv->channels * input_index >= priv->in_count) | 73 | if (priv->in_used + priv->channels * input_index >= priv->in_count) |
| 74 | break ; | 74 | break ; |
| 75 | 75 | ||
| 76 | if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) | 76 | if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) |
| 77 | src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ; | 77 | src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ; |
| 78 | 78 | ||
| 79 | for (ch = 0 ; ch < priv->channels ; ch++) | 79 | for (ch = 0 ; ch < priv->channels ; ch++) |
| 80 | { data->data_out [priv->out_gen] = priv->last_value [ch] ; | 80 | { data->data_out [priv->out_gen] = priv->last_value [ch] ; |
| @@ -92,8 +92,8 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 11 unmodified lines | |||
| 92 | /* Main processing loop. */ | 92 | /* Main processing loop. */ |
| 93 | while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index <= priv->in_count) | 93 | while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index <= priv->in_count) |
| 94 | { | 94 | { |
| 95 | if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) | 95 | if (priv->out_count > 0 && fabs (state->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF) |
| 96 | src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ; | 96 | src_ratio = state->last_ratio + priv->out_gen * (data->src_ratio - state->last_ratio) / priv->out_count ; |
| 97 | 97 | ||
| 98 | for (ch = 0 ; ch < priv->channels ; ch++) | 98 | for (ch = 0 ; ch < priv->channels ; ch++) |
| 99 | { data->data_out [priv->out_gen] = data->data_in [priv->in_used - priv->channels + ch] ; | 99 | { data->data_out [priv->out_gen] = data->data_in [priv->in_used - priv->channels + ch] ; |
| @@ -113,14 +113,14 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 13 unmodified lines | |||
| 113 | priv->in_used = priv->in_count ; | 113 | priv->in_used = priv->in_count ; |
| 114 | } ; | 114 | } ; |
| 115 | 115 | ||
| 116 | psrc->last_position = input_index ; | 116 | state->last_position = input_index ; |
| 117 | 117 | ||
| 118 | if (priv->in_used > 0) | 118 | if (priv->in_used > 0) |
| 119 | for (ch = 0 ; ch < priv->channels ; ch++) | 119 | for (ch = 0 ; ch < priv->channels ; ch++) |
| 120 | priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ; | 120 | priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ; |
| 121 | 121 | ||
| 122 | /* Save current ratio rather then target ratio. */ | 122 | /* Save current ratio rather then target ratio. */ |
| 123 | psrc->last_ratio = src_ratio ; | 123 | state->last_ratio = src_ratio ; |
| 124 | 124 | ||
| 125 | data->input_frames_used = priv->in_used / priv->channels ; | 125 | data->input_frames_used = priv->in_used / priv->channels ; |
| 126 | data->output_frames_gen = priv->out_gen / priv->channels ; | 126 | data->output_frames_gen = priv->out_gen / priv->channels ; |
| @@ -150,34 +150,34 @@ zoh_get_description (int src_enum) · 23 unmodified lines | |||
| 150 | } /* zoh_get_descrition */ | 150 | } /* zoh_get_descrition */ |
| 151 | 151 | ||
| 152 | int | 152 | int |
| 153 | zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) | 153 | zoh_set_converter (SRC_STATE *state, int src_enum) |
| 154 | { ZOH_DATA *priv = NULL ; | 154 | { ZOH_DATA *priv = NULL ; |
| 155 | 155 | ||
| 156 | if (src_enum != SRC_ZERO_ORDER_HOLD) | 156 | if (src_enum != SRC_ZERO_ORDER_HOLD) |
| 157 | return SRC_ERR_BAD_CONVERTER ; | 157 | return SRC_ERR_BAD_CONVERTER ; |
| 158 | 158 | ||
| 159 | if (psrc->private_data != NULL) | 159 | if (state->private_data != NULL) |
| 160 | { free (psrc->private_data) ; | 160 | { free (state->private_data) ; |
| 161 | psrc->private_data = NULL ; | 161 | state->private_data = NULL ; |
| 162 | } ; | 162 | } ; |
| 163 | 163 | ||
| 164 | if (psrc->private_data == NULL) | 164 | if (state->private_data == NULL) |
| 165 | { priv = ZERO_ALLOC (ZOH_DATA, sizeof (*priv) + psrc->channels * sizeof (float)) ; | 165 | { priv = ZERO_ALLOC (ZOH_DATA, sizeof (*priv) + state->channels * sizeof (float)) ; |
| 166 | psrc->private_data = priv ; | 166 | state->private_data = priv ; |
| 167 | } ; | 167 | } ; |
| 168 | 168 | ||
| 169 | if (priv == NULL) | 169 | if (priv == NULL) |
| 170 | return SRC_ERR_MALLOC_FAILED ; | 170 | return SRC_ERR_MALLOC_FAILED ; |
| 171 | 171 | ||
| 172 | priv->zoh_magic_marker = ZOH_MAGIC_MARKER ; | 172 | priv->zoh_magic_marker = ZOH_MAGIC_MARKER ; |
| 173 | priv->channels = psrc->channels ; | 173 | priv->channels = state->channels ; |
| 174 | 174 | ||
| 175 | psrc->const_process = zoh_vari_process ; | 175 | state->const_process = zoh_vari_process ; |
| 176 | psrc->vari_process = zoh_vari_process ; | 176 | state->vari_process = zoh_vari_process ; |
| 177 | psrc->reset = zoh_reset ; | 177 | state->reset = zoh_reset ; |
| 178 | psrc->copy = zoh_copy ; | 178 | state->copy = zoh_copy ; |
| 179 | 179 | ||
| 180 | zoh_reset (psrc) ; | 180 | zoh_reset (state) ; |
| 181 | 181 | ||
| 182 | return SRC_ERR_NO_ERROR ; | 182 | return SRC_ERR_NO_ERROR ; |
| 183 | } /* zoh_set_converter */ | 183 | } /* zoh_set_converter */ |
| @@ -186,14 +186,14 @@ zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) · 2 unmodified lines | |||
| 186 | */ | 186 | */ |
| 187 | 187 | ||
| 188 | static void | 188 | static void |
| 189 | zoh_reset (SRC_PRIVATE *psrc) | 189 | zoh_reset (SRC_STATE *state) |
| 190 | { ZOH_DATA *priv ; | 190 | { ZOH_DATA *priv ; |
| 191 | 191 | ||
| 192 | priv = (ZOH_DATA*) psrc->private_data ; | 192 | priv = (ZOH_DATA*) state->private_data ; |
| 193 | if (priv == NULL) | 193 | if (priv == NULL) |
| 194 | return ; | 194 | return ; |
| 195 | 195 | ||
| 196 | priv->channels = psrc->channels ; | 196 | priv->channels = state->channels ; |
| 197 | priv->reset = 1 ; | 197 | priv->reset = 1 ; |
| 198 | memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ; | 198 | memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ; |
| 199 | 199 | ||
| @@ -201,7 +201,7 @@ zoh_reset (SRC_PRIVATE *psrc) · 1 unmodified line | |||
| 201 | } /* zoh_reset */ | 201 | } /* zoh_reset */ |
| 202 | 202 | ||
| 203 | static int | 203 | static int |
| 204 | zoh_copy (SRC_PRIVATE *from, SRC_PRIVATE *to) | 204 | zoh_copy (SRC_STATE *from, SRC_STATE *to) |
| 205 | { | 205 | { |
| 206 | if (from->private_data == NULL) | 206 | if (from->private_data == NULL) |
| 207 | return SRC_ERR_NO_PRIVATE ; | 207 | return SRC_ERR_NO_PRIVATE ; |