aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-23 20:01:12 +0200
committerMax Kellermann <max@duempel.org>2008-10-23 20:01:12 +0200
commit124f79a2a69d2103bcaf460d38868c1718a5a1e3 (patch)
tree0ff477e50e0a2fc837eb1bc34d583b16fb9a99fd
parentb13d656f811d318ba37002cf18ddc3d85f0e2f1d (diff)
downloadmpd-124f79a2a69d2103bcaf460d38868c1718a5a1e3.tar.gz
mpd-124f79a2a69d2103bcaf460d38868c1718a5a1e3.tar.xz
mpd-124f79a2a69d2103bcaf460d38868c1718a5a1e3.zip
pcm_resample: don't resample partial samples
Added assertions which ensure that there are no partial samples in the source buffer.
-rw-r--r--src/pcm_resample_fallback.c5
-rw-r--r--src/pcm_resample_libsamplerate.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/src/pcm_resample_fallback.c b/src/pcm_resample_fallback.c
index c5c4ae08c..59d095b66 100644
--- a/src/pcm_resample_fallback.c
+++ b/src/pcm_resample_fallback.c
@@ -20,6 +20,8 @@
#include "pcm_resample.h"
#include "gcc.h"
+#include <assert.h>
+
/* resampling code blatantly ripped from ESD */
size_t
pcm_resample_16(uint8_t channels,
@@ -33,6 +35,9 @@ pcm_resample_16(uint8_t channels,
unsigned dest_samples = dest_size / sizeof(*dest_buffer);
int16_t lsample, rsample;
+ assert((src_size % (sizeof(*src_buffer) * channels)) == 0);
+ assert((dest_size % (sizeof(*dest_buffer) * channels)) == 0);
+
switch (channels) {
case 1:
while (dest_pos < dest_samples) {
diff --git a/src/pcm_resample_libsamplerate.c b/src/pcm_resample_libsamplerate.c
index d4b85b811..fd778acc3 100644
--- a/src/pcm_resample_libsamplerate.c
+++ b/src/pcm_resample_libsamplerate.c
@@ -22,6 +22,7 @@
#include "log.h"
#include "utils.h"
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@ -75,6 +76,9 @@ pcm_resample_16(uint8_t channels,
size_t data_out_size;
int error;
+ assert((src_size % (sizeof(*src_buffer) * channels)) == 0);
+ assert((dest_size % (sizeof(*dest_buffer) * channels)) == 0);
+
if (convalgo < 0)
convalgo = pcm_resample_get_converter();