aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_mix.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-19 21:00:54 +0100
committerMax Kellermann <max@duempel.org>2009-11-19 21:00:54 +0100
commit300f9362282b1152e2d517314e72064ae4ca395a (patch)
treebd22471a0120d9845269c28a12b0927c61a95750 /src/pcm_mix.c
parent135842803156ab3d983babb61d22905a43977be3 (diff)
downloadmpd-300f9362282b1152e2d517314e72064ae4ca395a.tar.gz
mpd-300f9362282b1152e2d517314e72064ae4ca395a.tar.xz
mpd-300f9362282b1152e2d517314e72064ae4ca395a.zip
pcm_mix: implemented 32 bit support
Diffstat (limited to '')
-rw-r--r--src/pcm_mix.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pcm_mix.c b/src/pcm_mix.c
index 34b4b9175..6e678a912 100644
--- a/src/pcm_mix.c
+++ b/src/pcm_mix.c
@@ -82,6 +82,23 @@ pcm_add_24(int32_t *buffer1, const int32_t *buffer2,
}
static void
+pcm_add_32(int32_t *buffer1, const int32_t *buffer2,
+ unsigned num_samples, unsigned volume1, unsigned volume2)
+{
+ while (num_samples > 0) {
+ int64_t sample1 = *buffer1;
+ int64_t sample2 = *buffer2++;
+
+ sample1 = ((sample1 * volume1 + sample2 * volume2) +
+ pcm_volume_dither() + PCM_VOLUME_1 / 2)
+ / PCM_VOLUME_1;
+
+ *buffer1++ = pcm_range_64(sample1, 32);
+ --num_samples;
+ }
+}
+
+static void
pcm_add(void *buffer1, const void *buffer2, size_t size,
int vol1, int vol2,
const struct audio_format *format)
@@ -103,6 +120,12 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
size / 4, vol1, vol2);
break;
+ case 32:
+ pcm_add_32((int32_t*)buffer1,
+ (const int32_t*)buffer2,
+ size / 4, vol1, vol2);
+ break;
+
default:
g_error("%u bits not supported by pcm_add!\n", format->bits);
}