summaryrefslogtreecommitdiff
path: root/audio/mixeng.c
diff options
context:
space:
mode:
authorVolker Rümelin <vr_qemu@t-online.de>2020-02-02 15:06:41 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-02-06 14:35:04 +0100
commit180b044ffde2cdd4a7209c727b5a8ce93d36741f (patch)
tree0bb3178baab2fbd361cfc9849d348224a52176a7 /audio/mixeng.c
parentfb35c2cec58985f0b8d2733f1b91927542eeb3fd (diff)
coreaudio: fix coreaudio playback
There are reports that since commit 2ceb8240fa "coreaudio: port to the new audio backend api" audio playback with CoreAudio is broken. This patch reverts some parts the commit. Because of changes in the audio subsystem the audio clip function in v4.1.0 of coreaudio.c had to be moved to mixeng.c and the generic buffer management code needed a hint about the size of the float type. This patch is based on a patch from Zoltán Kővágó found at https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html. Fixes: 2ceb8240fa "coreaudio: port to the new audio backend api" Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200202140641.4737-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/mixeng.c')
-rw-r--r--audio/mixeng.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/audio/mixeng.c b/audio/mixeng.c
index 2f5ba71381..16b646d48c 100644
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -267,6 +267,54 @@ f_sample *mixeng_clip[2][2][2][3] = {
}
};
+void conv_natural_float_to_stereo(struct st_sample *dst, const void *src,
+ int samples)
+{
+ float *in = (float *)src;
+#ifndef FLOAT_MIXENG
+ const float scale = UINT_MAX;
+#endif
+
+ while (samples--) {
+#ifdef FLOAT_MIXENG
+ dst->l = *in++;
+ dst->r = *in++;
+#else
+ dst->l = *in++ * scale;
+ dst->r = *in++ * scale;
+#endif
+ dst++;
+ }
+}
+
+void clip_natural_float_from_stereo(void *dst, const struct st_sample *src,
+ int samples)
+{
+ float *out = (float *)dst;
+#ifndef FLOAT_MIXENG
+#ifdef RECIPROCAL
+ const float scale = 1.f / UINT_MAX;
+#else
+ const float scale = UINT_MAX;
+#endif
+#endif
+
+ while (samples--) {
+#ifdef FLOAT_MIXENG
+ *out++ = src->l;
+ *out++ = src->r;
+#else
+#ifdef RECIPROCAL
+ *out++ = src->l * scale;
+ *out++ = src->r * scale;
+#else
+ *out++ = src->l / scale;
+ *out++ = src->r / scale;
+#endif
+#endif
+ src++;
+ }
+}
void audio_sample_to_uint64(void *samples, int pos,
uint64_t *left, uint64_t *right)