summaryrefslogtreecommitdiff
path: root/media-video/pipewire/files/0.3.79/0002-alsa-non-portable-isinf-use.patch
blob: 767c399bd515aafac679e689fc82f6ff0081358b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/aa11dbe10c0f2319a5c4c8dcfff1d5dccc03589e

From aa11dbe10c0f2319a5c4c8dcfff1d5dccc03589e Mon Sep 17 00:00:00 2001
From: q66 <q66@chimera-linux.org>
Date: Thu, 31 Aug 2023 03:17:54 +0200
Subject: [PATCH] alsa: get rid of non-portable isinf use

The isinf function returns -1 for negative infinity on glibc, but
the standard guarantees no such behavior (e.g. in C++ it always
returns a bool, on musl libc it's a macro that expands to a bool
expression), saying just that it returns a non-zero value.

This was added in pulseaudio around 15 years ago, and was never
fixed; pipewire then got the code from it. However, we can portably
check against -INFINITY instead (from math.h, already included).

Ref https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/045c1d6
--- a/spa/plugins/alsa/acp/volume.h
+++ b/spa/plugins/alsa/acp/volume.h
@@ -83,7 +83,7 @@ static inline pa_volume_t pa_sw_volume_from_linear(double v)
 
 static inline pa_volume_t pa_sw_volume_from_dB(double dB)
 {
-    if (isinf(dB) < 0 || dB <= PA_DECIBEL_MININFTY)
+    if (dB == -INFINITY || dB <= PA_DECIBEL_MININFTY)
         return PA_VOLUME_MUTED;
     return pa_sw_volume_from_linear(pa_volume_dB_to_linear(dB));
 }
-- 
GitLab