Pipewireパッケージ(ちょっと変更)
Revisión | c5cc364794df56ff8e843181935caf64712e36f7 (tree) |
---|---|
Tiempo | 2023-10-03 14:15:17 |
Autor | Christian Glombek <lorbus@fedo...> |
Commiter | Christian Glombek |
module-raop-sink: Fix volume calculation
The volume interval that RAOP devices understand is [-30,0],
where -30.0 equals min vol, and 0.0 equals max. vol.
The local system volume is represented as a cubic (volumetric)
value in the [0,1] interval.
So cube root system volume value, scale by 30 and
translate -30 to map to target output range.
The special value -144 denotes volume mute. Send a corresponding RTSP
message when mute is not already toggled on.
@@ -148,9 +148,9 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME); | ||
148 | 148 | #define DEFAULT_CHANNELS 2 |
149 | 149 | #define DEFAULT_POSITION "[ FL FR ]" |
150 | 150 | |
151 | -#define VOLUME_MAX 0.0 | |
152 | -#define VOLUME_DEF -30.0 | |
153 | -#define VOLUME_MIN -144.0 | |
151 | +#define VOLUME_MAX 0.0 | |
152 | +#define VOLUME_MIN -30.0 | |
153 | +#define VOLUME_MUTE -144.0 | |
154 | 154 | |
155 | 155 | #define MODULE_USAGE "( raop.ip=<ip address of host> ) " \ |
156 | 156 | "( raop.port=<remote port> ) " \ |
@@ -1723,6 +1723,10 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp | ||
1723 | 1723 | { |
1724 | 1724 | bool mute; |
1725 | 1725 | if (spa_pod_get_bool(&prop->value, &mute) == 0) { |
1726 | + if (!impl->mute) { | |
1727 | + impl->volume = VOLUME_MUTE; | |
1728 | + rtsp_send_volume(impl); | |
1729 | + } | |
1726 | 1730 | impl->mute = mute; |
1727 | 1731 | } |
1728 | 1732 | spa_pod_builder_prop(&b, SPA_PROP_softMute, 0); |
@@ -1744,7 +1748,7 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp | ||
1744 | 1748 | soft_vols[i] = 1.0f; |
1745 | 1749 | } |
1746 | 1750 | volume /= n_vols; |
1747 | - volume = SPA_CLAMPF(20.0 * log10(volume), VOLUME_MIN, VOLUME_MAX); | |
1751 | + volume = SPA_CLAMPF(cbrt(volume) * 30 - 30, VOLUME_MIN, VOLUME_MAX); | |
1748 | 1752 | impl->volume = volume; |
1749 | 1753 | |
1750 | 1754 | rtsp_send_volume(impl); |