src/audio/SDL_audiocvt.c
changeset 10804 1502bb751ca4
parent 10799 234f71894a52
child 10805 30a00d960dc9
     1.1 --- a/src/audio/SDL_audiocvt.c	Mon Jan 09 15:56:11 2017 -0500
     1.2 +++ b/src/audio/SDL_audiocvt.c	Mon Jan 09 16:31:57 2017 -0500
     1.3 @@ -377,53 +377,16 @@
     1.4      const int srclen = cvt->len_cvt;
     1.5      float *dst = (float *) (cvt->buf + srclen);
     1.6      const int dstlen = (cvt->len * cvt->len_mult) - srclen;
     1.7 -    SDL_bool do_simple = SDL_TRUE;
     1.8 +    float state[8];
     1.9 +    int i;
    1.10  
    1.11      SDL_assert(format == AUDIO_F32SYS);
    1.12  
    1.13 -#ifdef HAVE_LIBSAMPLERATE_H
    1.14 -    if (SRC_available) {
    1.15 -        int result = 0;
    1.16 -        SRC_STATE *state = SRC_src_new(SRC_SINC_FASTEST, chans, &result);
    1.17 -        if (state) {
    1.18 -            const int framelen = sizeof(float) * chans;
    1.19 -            SRC_DATA data;
    1.20 +    for (i = 0; i < chans; i++) {
    1.21 +        state[i] = src[i];
    1.22 +    }
    1.23  
    1.24 -            data.data_in = (float *)src; /* Older versions of libsamplerate had a non-const pointer, but didn't write to it */
    1.25 -            data.input_frames = srclen / framelen;
    1.26 -            data.input_frames_used = 0;
    1.27 -
    1.28 -            data.data_out = dst;
    1.29 -            data.output_frames = dstlen / framelen;
    1.30 -
    1.31 -            data.end_of_input = 0;
    1.32 -            data.src_ratio = cvt->rate_incr;
    1.33 -
    1.34 -            result = SRC_src_process(state, &data);
    1.35 -            SDL_assert(result == 0);  /* what to do if this fails? Can it fail? */
    1.36 -
    1.37 -            /* What to do if this fails...? */
    1.38 -            SDL_assert(data.input_frames_used == data.input_frames);
    1.39 -
    1.40 -            SRC_src_delete(state);
    1.41 -            cvt->len_cvt = data.output_frames_gen * (sizeof(float) * chans);
    1.42 -            do_simple = SDL_FALSE;
    1.43 -        }
    1.44 -
    1.45 -        /* failed to create state? Fall back to simple method. */
    1.46 -    }
    1.47 -#endif
    1.48 -
    1.49 -    if (do_simple) {
    1.50 -        float state[8];
    1.51 -        int i;
    1.52 -
    1.53 -        for (i = 0; i < chans; i++) {
    1.54 -            state[i] = src[i];
    1.55 -        }
    1.56 -
    1.57 -        cvt->len_cvt = SDL_ResampleAudioSimple(chans, cvt->rate_incr, state, src, srclen, dst, dstlen);
    1.58 -    }
    1.59 +    cvt->len_cvt = SDL_ResampleAudioSimple(chans, cvt->rate_incr, state, src, srclen, dst, dstlen);
    1.60  
    1.61      SDL_memcpy(cvt->buf, dst, cvt->len_cvt);
    1.62      if (cvt->filters[++cvt->filter_index]) {