[PATCH] dsound: Don't use lrintf if it's not available.
Alex Henrie
alexhenrie24 at gmail.com
Sun Oct 29 15:59:30 CDT 2017
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
Fixes https://bugs.winehq.org/show_bug.cgi?id=43000
lrintf is not part of C89, and we were already using HAVE_LRINTF in
msvcrt.
---
dlls/dsound/dsound_convert.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/dlls/dsound/dsound_convert.c b/dlls/dsound/dsound_convert.c
index 6887bae558..ad1aba3737 100644
--- a/dlls/dsound/dsound_convert.c
+++ b/dlls/dsound/dsound_convert.c
@@ -120,7 +120,11 @@ static inline unsigned char f_to_8(float value)
return 0;
if(value >= 1.f * 0x7f / 0x80)
return 0xFF;
+#ifdef HAVE_LRINTF
return lrintf((value + 1.f) * 0x80);
+#else
+ return (value + 1) * 0x80;
+#endif
}
static inline SHORT f_to_16(float value)
@@ -129,7 +133,11 @@ static inline SHORT f_to_16(float value)
return 0x8000;
if(value >= 1.f * 0x7FFF / 0x8000)
return 0x7FFF;
+#ifdef HAVE_LRINTF
return le16(lrintf(value * 0x8000));
+#else
+ return le16(value * 0x8000);
+#endif
}
static LONG f_to_24(float value)
@@ -138,7 +146,11 @@ static LONG f_to_24(float value)
return 0x80000000;
if(value >= 1.f * 0x7FFFFF / 0x800000)
return 0x7FFFFF00;
+#ifdef HAVE_LRINTF
return lrintf(value * 0x80000000U);
+#else
+ return value * 0x80000000U;
+#endif
}
static inline LONG f_to_32(float value)
@@ -147,7 +159,11 @@ static inline LONG f_to_32(float value)
return 0x80000000;
if(value >= 1.f * 0x7FFFFFFF / 0x80000000U) /* this rounds to 1.f */
return 0x7FFFFFFF;
+#ifdef HAVE_LRINTF
return le32(lrintf(value * 0x80000000U));
+#else
+ return le32(value * 0x80000000U);
+#endif
}
void putieee32(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value)
--
2.14.2
More information about the wine-patches
mailing list