[client] audio/pw: use scaling forumula provided by quantum

This commit is contained in:
Geoffrey McRae 2021-12-25 20:53:11 +11:00
parent 64b64b61be
commit 9fa643484c

View File

@ -23,6 +23,7 @@
#include <spa/param/audio/format-utils.h> #include <spa/param/audio/format-utils.h>
#include <spa/param/props.h> #include <spa/param/props.h>
#include <pipewire/pipewire.h> #include <pipewire/pipewire.h>
#include <math.h>
#include "common/debug.h" #include "common/debug.h"
#include "common/ringbuffer.h" #include "common/ringbuffer.h"
@ -244,10 +245,7 @@ static void pipewire_volume(int channels, const uint16_t volume[])
float param[channels]; float param[channels];
for(int i = 0; i < channels; ++i) for(int i = 0; i < channels; ++i)
{ param[i] = 9.3234e-7 * pow(1.000211902, volume[i]) - 0.000172787;
//TODO: the scaling here is wrong and needs fixing
param[i] = (1.0f / 65535.0f) * volume[i];
}
pw_thread_loop_lock(pw.thread); pw_thread_loop_lock(pw.thread);
pw_stream_set_control(pw.stream, SPA_PROP_channelVolumes, channels, param, 0); pw_stream_set_control(pw.stream, SPA_PROP_channelVolumes, channels, param, 0);