aboutsummaryrefslogtreecommitdiff
path: root/src/pcm_volume.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-19 21:00:50 +0100
committerMax Kellermann <max@duempel.org>2009-11-19 21:00:50 +0100
commit135842803156ab3d983babb61d22905a43977be3 (patch)
tree4087984407caa2361118950238fa8672dce94aa1 /src/pcm_volume.c
parent5a480137d2c724c8a3359c66a9120e310ea19cd1 (diff)
pcm_volume: implemented 32 bit support
Support 32 bit samples with software mixer.
Diffstat (limited to 'src/pcm_volume.c')
-rw-r--r--src/pcm_volume.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pcm_volume.c b/src/pcm_volume.c
index ca720a30..90ad17d6 100644
--- a/src/pcm_volume.c
+++ b/src/pcm_volume.c
@@ -114,6 +114,29 @@ pcm_volume_change_24(int32_t *buffer, unsigned num_samples, int volume)
}
}
+static void
+pcm_volume_change_32(int32_t *buffer, unsigned num_samples, int volume)
+{
+ while (num_samples > 0) {
+#ifdef __i386__
+ /* assembly version for i386 */
+ int32_t sample = *buffer;
+
+ *buffer++ = pcm_volume_sample_24(sample, volume, 0);
+#else
+ /* portable version */
+ int64_t sample = *buffer;
+
+ sample = (sample * volume + pcm_volume_dither() +
+ PCM_VOLUME_1 / 2)
+ / PCM_VOLUME_1;
+ *buffer++ = pcm_range_64(sample, 32);
+#endif
+
+ --num_samples;
+ }
+}
+
bool
pcm_volume(void *buffer, int length,
const struct audio_format *format,
@@ -142,6 +165,11 @@ pcm_volume(void *buffer, int length,
volume);
return true;
+ case 32:
+ pcm_volume_change_32((int32_t*)buffer, length / 4,
+ volume);
+ return true;
+
default:
return false;
}