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