mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-28 09:36:28 +00:00
[client] audio/pw: implement volume and mute control
This commit is contained in:
parent
433a5420cb
commit
64b64b61be
@ -21,6 +21,7 @@
|
|||||||
#include "interface/audiodev.h"
|
#include "interface/audiodev.h"
|
||||||
|
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
|
#include <spa/param/props.h>
|
||||||
#include <pipewire/pipewire.h>
|
#include <pipewire/pipewire.h>
|
||||||
|
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
@ -236,6 +237,30 @@ static void pipewire_stop(void)
|
|||||||
pw_thread_loop_unlock(pw.thread);
|
pw_thread_loop_unlock(pw.thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pipewire_volume(int channels, const uint16_t volume[])
|
||||||
|
{
|
||||||
|
if (channels != pw.channels)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float param[channels];
|
||||||
|
for(int i = 0; i < channels; ++i)
|
||||||
|
{
|
||||||
|
//TODO: the scaling here is wrong and needs fixing
|
||||||
|
param[i] = (1.0f / 65535.0f) * volume[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
pw_thread_loop_lock(pw.thread);
|
||||||
|
pw_stream_set_control(pw.stream, SPA_PROP_channelVolumes, channels, param, 0);
|
||||||
|
pw_thread_loop_unlock(pw.thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pipewire_mute(bool mute)
|
||||||
|
{
|
||||||
|
pw_thread_loop_lock(pw.thread);
|
||||||
|
pw_stream_set_control(pw.stream, SPA_PROP_mute, 1, (void *)&mute, 0);
|
||||||
|
pw_thread_loop_unlock(pw.thread);
|
||||||
|
}
|
||||||
|
|
||||||
struct LG_AudioDevOps LGAD_PipeWire =
|
struct LG_AudioDevOps LGAD_PipeWire =
|
||||||
{
|
{
|
||||||
.name = "PipeWire",
|
.name = "PipeWire",
|
||||||
@ -243,5 +268,7 @@ struct LG_AudioDevOps LGAD_PipeWire =
|
|||||||
.free = pipewire_free,
|
.free = pipewire_free,
|
||||||
.start = pipewire_start,
|
.start = pipewire_start,
|
||||||
.play = pipewire_play,
|
.play = pipewire_play,
|
||||||
.stop = pipewire_stop
|
.stop = pipewire_stop,
|
||||||
|
.volume = pipewire_volume,
|
||||||
|
.mute = pipewire_mute
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user