aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_volume.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-10-20 02:33:51 +0200
committerMax Kellermann <max@duempel.org>2011-10-20 02:33:51 +0200
commitbfef0fbff34e80a86d7b740eace597efe52136e1 (patch)
treee962439504e4bd9874be40b243aab859066c960f /src/pcm_volume.c
parent545685bc3209d9cfdf6c4b9aeee4715edd453dc1 (diff)
downloadmpd-bfef0fbff34e80a86d7b740eace597efe52136e1.tar.gz
mpd-bfef0fbff34e80a86d7b740eace597efe52136e1.tar.xz
mpd-bfef0fbff34e80a86d7b740eace597efe52136e1.zip
pcm_volume: implement float samples
Diffstat (limited to 'src/pcm_volume.c')
-rw-r--r--src/pcm_volume.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pcm_volume.c b/src/pcm_volume.c
index f732060b2..de4bda6c9 100644
--- a/src/pcm_volume.c
+++ b/src/pcm_volume.c
@@ -132,6 +132,16 @@ pcm_volume_change_32(int32_t *buffer, const int32_t *end, int volume)
}
}
+static void
+pcm_volume_change_float(float *buffer, const float *end, float volume)
+{
+ while (buffer < end) {
+ float sample = *buffer;
+ sample *= volume;
+ *buffer++ = sample;
+ }
+}
+
bool
pcm_volume(void *buffer, size_t length,
enum sample_format format,
@@ -169,8 +179,9 @@ pcm_volume(void *buffer, size_t length,
return true;
case SAMPLE_FORMAT_FLOAT:
- /* XXX */
- return false;
+ pcm_volume_change_float(buffer, end,
+ pcm_volume_to_float(volume));
+ return true;
}
/* unreachable */