int output_bits, int output_channels,
int output_rate, int output_signed,
int output_endian) {
- int error_;
memset(rs, 0, sizeof *rs);
assert(input_bits == 8 || input_bits == 16);
assert(output_bits == 8 || output_bits == 16);
rs->input_bytes_per_frame = rs->input_channels * rs->input_bytes_per_sample;
if(rs->input_rate != rs->output_rate) {
#if HAVE_SAMPLERATE_H
+ int error_;
rs->state = src_new(SRC_SINC_BEST_QUALITY, rs->output_channels, &error_);
if(!rs->state)
- fatal(0, "calling src_new: %s", src_strerror(error_));
+ disorder_fatal(0, "calling src_new: %s", src_strerror(error_));
#else
- fatal(0, "need to resample audio data but libsamplerate not available");
+ disorder_fatal(0, "need to resample audio data but libsamplerate not available");
#endif
}
}
#if HAVE_SAMPLERATE_H
if(rs->state)
src_delete(rs->state);
+#else
+ rs = 0; /* quieten compiler */
#endif
}
data.input_frames = nframesin;
data.output_frames = maxframesout;
data.end_of_input = eof;
- data.src_ratio = rs->output_rate / rs->input_rate;
+ data.src_ratio = (double)rs->output_rate / rs->input_rate;
int error_ = src_process(rs->state, &data);
if(error_)
- fatal(0, "calling src_process: %s", src_strerror(error_));
+ disorder_fatal(0, "calling src_process: %s", src_strerror(error_));
nframesin = data.input_frames_used;
nsamplesout = data.output_frames_gen * rs->output_channels;
}
if(output != input)
xfree(output);
xfree(input);
+ eof = 0; /* quieten compiler */
/* Report how many input bytes were actually consumed */
+ //fprintf(stderr, "converted %zu frames\n", nframesin);
return nframesin * rs->input_bytes_per_frame;
}