diff options
author | Max Kellermann <max@duempel.org> | 2008-10-23 20:01:08 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-23 20:01:08 +0200 |
commit | b13d656f811d318ba37002cf18ddc3d85f0e2f1d (patch) | |
tree | 0cb17c41caae994c8d47d81efd4eac128c95a8f3 /src/pcm_resample_libsamplerate.c | |
parent | 6b1c54ef9646abddfbd4960c207b32426300a90c (diff) |
pcm_resample: don't hard-code sample size
Use sizeof(sample) instead of hard-coding "2". Although we're in 16
bit right now, this will make code sharing easier when we support
other sample sizes.
Diffstat (limited to 'src/pcm_resample_libsamplerate.c')
-rw-r--r-- | src/pcm_resample_libsamplerate.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pcm_resample_libsamplerate.c b/src/pcm_resample_libsamplerate.c index 5321c0e0b..d4b85b811 100644 --- a/src/pcm_resample_libsamplerate.c +++ b/src/pcm_resample_libsamplerate.c @@ -108,14 +108,14 @@ pcm_resample_16(uint8_t channels, if (state->error) return 0; - data->input_frames = src_size / 2 / channels; + data->input_frames = src_size / sizeof(*src_buffer) / channels; data_in_size = data->input_frames * sizeof(float) * channels; if (data_in_size > state->data_in_size) { state->data_in_size = data_in_size; data->data_in = xrealloc(data->data_in, data_in_size); } - data->output_frames = dest_size / 2 / channels; + data->output_frames = dest_size / sizeof(*dest_buffer) / channels; data_out_size = data->output_frames * sizeof(float) * channels; if (data_out_size > state->data_out_size) { state->data_out_size = data_out_size; @@ -136,5 +136,5 @@ pcm_resample_16(uint8_t channels, src_float_to_short_array(data->data_out, dest_buffer, data->output_frames_gen * channels); - return data->output_frames_gen * 2 * channels; + return data->output_frames_gen * sizeof(*dest_buffer) * channels; } |