Unified · Split
| @@ -75,18 +75,23 @@ enum · 74 unmodified lines | |||
| 75 | typedef struct SRC_PRIVATE_tag | 75 | typedef struct SRC_PRIVATE_tag |
| 76 | { double last_ratio, last_position ; | 76 | { double last_ratio, last_position ; |
| 77 | 77 | ||
| 78 | int error ; | ||
| 79 | int channels ; | ||
| 80 | |||
| 81 | /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */ | ||
| 82 | int mode ; | ||
| 83 | |||
| 84 | /* Pointer to data to converter specific data. */ | ||
| 78 | void *private_data ; | 85 | void *private_data ; |
| 79 | 86 | ||
| 80 | int (*process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; | 87 | int (*process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; |
| 81 | void (*reset) (struct SRC_PRIVATE_tag *psrc) ; | 88 | void (*reset) (struct SRC_PRIVATE_tag *psrc) ; |
| 82 | 89 | ||
| 83 | int error ; | 90 | /* Data specific to SRC_MODE_CALLBACK. */ |
| 84 | int channels ; | ||
| 85 | |||
| 86 | int mode ; /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */ | ||
| 87 | |||
| 88 | src_callback_t callback_func ; | 91 | src_callback_t callback_func ; |
| 89 | void *user_callback_data ; | 92 | void *user_callback_data ; |
| 93 | long saved_frames ; | ||
| 94 | float *saved_data ; | ||
| 90 | } SRC_PRIVATE ; | 95 | } SRC_PRIVATE ; |
| 91 | 96 | ||
| 92 | /* In src_sinc.c */ | 97 | /* In src_sinc.c */ |
| @@ -205,6 +205,9 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 204 unmodified lines | |||
| 205 | src_data.data_out = data ; | 205 | src_data.data_out = data ; |
| 206 | src_data.output_frames = frames ; | 206 | src_data.output_frames = frames ; |
| 207 | 207 | ||
| 208 | src_data.data_in = psrc->saved_data ; | ||
| 209 | src_data.input_frames = psrc->saved_frames ; | ||
| 210 | |||
| 208 | output_frames_gen = 0 ; | 211 | output_frames_gen = 0 ; |
| 209 | while (output_frames_gen < frames) | 212 | while (output_frames_gen < frames) |
| 210 | { | 213 | { |
| @@ -218,17 +221,17 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 7 unmodified lines | |||
| 218 | src_data.end_of_input = 1 ; | 221 | src_data.end_of_input = 1 ; |
| 219 | } ; | 222 | } ; |
| 220 | 223 | ||
| 221 | /* Now call process function. However, we need to set the mode to | 224 | /* |
| 222 | ** SRC_MODE_PROCESS first and when we return set it back to SRC_MODE_CALLBACK. | 225 | ** Now call process function. However, we need to set the mode |
| 226 | ** to SRC_MODE_PROCESS first and when we return set it back to | ||
| 227 | ** SRC_MODE_CALLBACK. | ||
| 223 | */ | 228 | */ |
| 224 | psrc->mode = SRC_MODE_PROCESS ; | 229 | psrc->mode = SRC_MODE_PROCESS ; |
| 225 | error = src_process (state, &src_data) ; | 230 | error = src_process (state, &src_data) ; |
| 226 | psrc->mode = SRC_MODE_CALLBACK ; | 231 | psrc->mode = SRC_MODE_CALLBACK ; |
| 227 | 232 | ||
| 228 | if (error != 0) | 233 | if (error != 0) |
| 229 | { psrc->error = error ; | 234 | break ; |
| 230 | return 0 ; | ||
| 231 | } ; | ||
| 232 | 235 | ||
| 233 | src_data.data_in += src_data.input_frames_used * psrc->channels ; | 236 | src_data.data_in += src_data.input_frames_used * psrc->channels ; |
| 234 | src_data.input_frames -= src_data.input_frames_used ; | 237 | src_data.input_frames -= src_data.input_frames_used ; |
| @@ -242,6 +245,14 @@ src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) · 7 unmodified lines | |||
| 242 | break ; | 245 | break ; |
| 243 | } ; | 246 | } ; |
| 244 | 247 | ||
| 248 | psrc->saved_data = src_data.data_in ; | ||
| 249 | psrc->saved_frames = src_data.input_frames ; | ||
| 250 | |||
| 251 | if (error != 0) | ||
| 252 | { psrc->error = error ; | ||
| 253 | return 0 ; | ||
| 254 | } ; | ||
| 255 | |||
| 245 | return output_frames_gen ; | 256 | return output_frames_gen ; |
| 246 | } /* src_callback_read */ | 257 | } /* src_callback_read */ |
| 247 | 258 | ||
| @@ -51,7 +51,7 @@ typedef struct · 50 unmodified lines | |||
| 51 | } SRC_CB_DATA ; | 51 | } SRC_CB_DATA ; |
| 52 | 52 | ||
| 53 | /* | 53 | /* |
| 54 | ** User supplied callback function type for use with src_callback_new() | 54 | ** User supplied callback function type for use with src_callback_new() |
| 55 | ** and src_callback_read(). First parameter is the same pointer that was | 55 | ** and src_callback_read(). First parameter is the same pointer that was |
| 56 | ** passed into src_callback_new(). Second parameter is pointer to a | 56 | ** passed into src_callback_new(). Second parameter is pointer to a |
| 57 | ** pointer. The user supplied callback function must modify *data to | 57 | ** pointer. The user supplied callback function must modify *data to |
| @@ -62,16 +62,16 @@ typedef struct · 4 unmodified lines | |||
| 62 | typedef long (*src_callback_t) (void *cb_data, float **data) ; | 62 | typedef long (*src_callback_t) (void *cb_data, float **data) ; |
| 63 | 63 | ||
| 64 | /* | 64 | /* |
| 65 | ** Standard initialisation function : return an anonymous pointer to the | 65 | ** Standard initialisation function : return an anonymous pointer to the |
| 66 | ** internal state of the converter. Choose a converter from the enums below. | 66 | ** internal state of the converter. Choose a converter from the enums below. |
| 67 | ** Error returned in *error. | 67 | ** Error returned in *error. |
| 68 | */ | 68 | */ |
| 69 | 69 | ||
| 70 | SRC_STATE* src_new (int converter_type, int channels, int *error) ; | 70 | SRC_STATE* src_new (int converter_type, int channels, int *error) ; |
| 71 | 71 | ||
| 72 | /* | 72 | /* |
| 73 | ** Initilisation for callback based API : return an anonymous pointer to the | 73 | ** Initilisation for callback based API : return an anonymous pointer to the |
| 74 | ** internal state of the converter. Choose a converter from the enums below. | 74 | ** internal state of the converter. Choose a converter from the enums below. |
| 75 | ** The cb_data pointer can point to any data or be set to NULL. Whatever the | 75 | ** The cb_data pointer can point to any data or be set to NULL. Whatever the |
| 76 | ** value, when processing, user supplied function "func" gets called with | 76 | ** value, when processing, user supplied function "func" gets called with |
| 77 | ** cb_data as first parameter. | 77 | ** cb_data as first parameter. |
| @@ -188,7 +188,7 @@ void src_float_to_short_array (const float *in, short *out, int len) ; · 110 unmodified lines | |||
| 188 | 188 | ||
| 189 | /* | 189 | /* |
| 190 | ** Do not edit or modify anything in this comment block. | 190 | ** Do not edit or modify anything in this comment block. |
| 191 | ** The arch-tag line is a file identity tag for the GNU Arch | 191 | ** The arch-tag line is a file identity tag for the GNU Arch |
| 192 | ** revision control system. | 192 | ** revision control system. |
| 193 | ** | 193 | ** |
| 194 | ** arch-tag: 5421ef3e-c898-4ec3-8671-ea03d943ee00 | 194 | ** arch-tag: 5421ef3e-c898-4ec3-8671-ea03d943ee00 |