Monitor refactor; link_nodes PW utility
This commit is contained in:
70
pipewire.cpp
70
pipewire.cpp
@@ -9,31 +9,6 @@
|
||||
namespace Pipewire
|
||||
{
|
||||
|
||||
bool link_ports(int out_port_id, int in_port_id)
|
||||
{
|
||||
QProcess process;
|
||||
process.start("pw-link", { QString::number(out_port_id), QString::number(in_port_id) });
|
||||
return process.waitForFinished() && process.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool destroy_link(int link_id)
|
||||
{
|
||||
QProcess process;
|
||||
process.start("pw-cli", { "destroy", QString::number(link_id) });
|
||||
return process.waitForFinished() && process.exitCode() == 0;
|
||||
}
|
||||
|
||||
void set_volume(const QString& target_node, int volume_percent)
|
||||
{
|
||||
volume_percent = std::max(0, std::min(100, volume_percent));
|
||||
|
||||
QProcess process;
|
||||
process.startDetached("pactl", {
|
||||
"set-sink-volume", target_node,
|
||||
QString::number(volume_percent) + "%"
|
||||
});
|
||||
}
|
||||
|
||||
QString Node::get_display_name() const
|
||||
{
|
||||
if (!application_name.isEmpty()) return application_name;
|
||||
@@ -259,4 +234,49 @@ void Sink::destroy(int pulse_audio_id)
|
||||
process.waitForFinished();
|
||||
}
|
||||
|
||||
bool link_ports(int out_port_id, int in_port_id)
|
||||
{
|
||||
QProcess process;
|
||||
process.start("pw-link", { QString::number(out_port_id), QString::number(in_port_id) });
|
||||
return process.waitForFinished() && process.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool link_nodes(int out_node_id, int in_node_id, const Graph& graph)
|
||||
{
|
||||
auto out_ports = graph.get_ports_for_node(out_node_id, "out");
|
||||
auto in_ports = graph.get_ports_for_node(in_node_id, "in");
|
||||
|
||||
for (const Port& out_port : out_ports) {
|
||||
for (const Port& in_port : in_ports) {
|
||||
if (out_port.channel != in_port.channel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!link_ports(out_port.id, in_port.id)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool destroy_link(int link_id)
|
||||
{
|
||||
QProcess process;
|
||||
process.start("pw-cli", { "destroy", QString::number(link_id) });
|
||||
return process.waitForFinished() && process.exitCode() == 0;
|
||||
}
|
||||
|
||||
void set_volume(const QString& target_node, int volume_percent)
|
||||
{
|
||||
volume_percent = std::max(0, std::min(100, volume_percent));
|
||||
|
||||
QProcess process;
|
||||
process.startDetached("pactl", {
|
||||
"set-sink-volume", target_node,
|
||||
QString::number(volume_percent) + "%"
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Pipewire
|
||||
|
||||
Reference in New Issue
Block a user