Unified · Split
| @@ -75,18 +75,23 @@ enum · 74 unmodified lines | ||
| 75 | 75 | typedef struct SRC_PRIVATE_tag |
| 76 | 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 | 85 | void *private_data ; |
| 79 | 86 | |
| 80 | 87 | int (*process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ; |
| 81 | 88 | void (*reset) (struct SRC_PRIVATE_tag *psrc) ; |
| 82 | 89 | |
| 83 | − int error ; | |
| 84 | − int channels ; | |
| 85 | − | |
| 86 | − int mode ; /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */ | |
| 87 | − | |
| 90 | + /* Data specific to SRC_MODE_CALLBACK. */ | |
| 88 | 91 | src_callback_t callback_func ; |
| 89 | 92 | void *user_callback_data ; |
| 93 | + long saved_frames ; | |
| 94 | + float *saved_data ; | |
| 90 | 95 | } SRC_PRIVATE ; |
| 91 | 96 | |
| 92 | 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 | 205 | src_data.data_out = data ; |
| 206 | 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 | 211 | output_frames_gen = 0 ; |
| 209 | 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 | 221 | src_data.end_of_input = 1 ; |
| 219 | 222 | } ; |
| 220 | 223 | |
| 221 | − /* Now call process function. However, we need to set the mode to | |
| 222 | − ** SRC_MODE_PROCESS first and when we return set it back to SRC_MODE_CALLBACK. | |
| 224 | + /* | |
| 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 | 229 | psrc->mode = SRC_MODE_PROCESS ; |
| 225 | 230 | error = src_process (state, &src_data) ; |
| 226 | 231 | psrc->mode = SRC_MODE_CALLBACK ; |
| 227 | 232 | |
| 228 | 233 | if (error != 0) |
| 229 | − { psrc->error = error ; | |
| 230 | − return 0 ; | |
| 231 | − } ; | |
| 234 | + break ; | |
| 232 | 235 | |
| 233 | 236 | src_data.data_in += src_data.input_frames_used * psrc->channels ; |
| 234 | 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 | 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 | 256 | return output_frames_gen ; |
| 246 | 257 | } /* src_callback_read */ |
| 247 | 258 | |
| @@ -51,7 +51,7 @@ typedef struct · 50 unmodified lines | ||
| 51 | 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 | 55 | ** and src_callback_read(). First parameter is the same pointer that was |
| 56 | 56 | ** passed into src_callback_new(). Second parameter is pointer to a |
| 57 | 57 | ** pointer. The user supplied callback function must modify *data to |
| @@ -62,16 +62,16 @@ typedef struct · 4 unmodified lines | ||
| 62 | 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 | |
| 66 | −** internal state of the converter. Choose a converter from the enums below. | |
| 65 | +** Standard initialisation function : return an anonymous pointer to the | |
| 66 | +** internal state of the converter. Choose a converter from the enums below. | |
| 67 | 67 | ** Error returned in *error. |
| 68 | 68 | */ |
| 69 | 69 | |
| 70 | 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 | |
| 74 | −** internal state of the converter. Choose a converter from the enums below. | |
| 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. | |
| 75 | 75 | ** The cb_data pointer can point to any data or be set to NULL. Whatever the |
| 76 | 76 | ** value, when processing, user supplied function "func" gets called with |
| 77 | 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 | 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 | 192 | ** revision control system. |
| 193 | 193 | ** |
| 194 | 194 | ** arch-tag: 5421ef3e-c898-4ec3-8671-ea03d943ee00 |