From d52565c00ee67c7accef5e29d4a326b4547fe1cd Mon Sep 17 00:00:00 2001 From: Curve Date: Fri, 31 May 2024 16:47:55 +0200 Subject: [PATCH] feat(patchbay)!: add `only_speakers` setting --- CMakeLists.txt | 2 +- README.md | 3 +++ addon/addon.cpp | 2 ++ include/vencord/patchbay.hpp | 4 +++- lib/module.d.ts | 2 ++ package.json | 2 +- src/patchbay.impl.cpp | 6 +++--- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33054aa..2f7b9b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.21) -project(venmic LANGUAGES CXX VERSION 5.0.0) +project(venmic LANGUAGES CXX VERSION 6.0.0) # -------------------------------------------------------------------------------------------------------- # Library options diff --git a/README.md b/README.md index 3f586a7..31fbf75 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ The Rest-Server exposes three simple endpoints The setting `ignore_devices` is optional and will default to `true`. When enabled it will prevent hardware-devices like speakers and microphones from being linked to the virtual microphone. + The setting `only_speakers` is optional and will default to `true`. + When enabled it will prevent linking against nodes that don't play to a speaker. + The setting `only_default_speakers` is optional and will default to `true`. When enabled it will prevent linking against nodes that don't play to the default speaker. diff --git a/addon/addon.cpp b/addon/addon.cpp index 7d921f8..e4827d6 100644 --- a/addon/addon.cpp +++ b/addon/addon.cpp @@ -171,6 +171,7 @@ struct patchbay : public Napi::ObjectWrap auto include = to_array(data.Get("include")); auto exclude = to_array(data.Get("exclude")); auto ignore_devices = convert(data.Get("ignore_devices")); + auto only_speakers = convert(data.Get("only_speakers")); auto only_default_speakers = convert(data.Get("only_default_speakers")); auto workaround = to_array(data.Get("workaround")); @@ -187,6 +188,7 @@ struct patchbay : public Napi::ObjectWrap .include = include.value_or(std::vector{}), .exclude = exclude.value_or(std::vector{}), .ignore_devices = ignore_devices.value_or(true), + .only_speakers = only_speakers.value_or(true), .only_default_speakers = only_default_speakers.value_or(true), .workaround = workaround.value_or(std::vector{}), }); diff --git a/include/vencord/patchbay.hpp b/include/vencord/patchbay.hpp index 8b29772..635c340 100644 --- a/include/vencord/patchbay.hpp +++ b/include/vencord/patchbay.hpp @@ -15,7 +15,9 @@ namespace vencord std::vector exclude; public: - bool ignore_devices{true}; // Only link against non-device nodes + bool ignore_devices{true}; // Only link against non-device nodes + public: + bool only_speakers{true}; // Ignore nodes that don't play to speakers bool only_default_speakers{true}; // Ignore nodes that don't play to the default speaker public: diff --git a/lib/module.d.ts b/lib/module.d.ts index 5fbef16..b754647 100644 --- a/lib/module.d.ts +++ b/lib/module.d.ts @@ -18,6 +18,8 @@ export interface LinkData exclude: Node[]; ignore_devices?: boolean; + + only_speakers?: boolean; only_default_speakers?: boolean; workaround?: Node[]; diff --git a/package.json b/package.json index 7c6bc5d..b1d3ca8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "private": false, "license": "MPL-2.0", "author": "Curve (https://github.com/Curve)", - "version": "5.0.0", + "version": "6.0.0", "main": "./lib/index.js", "types": "./lib/module.d.ts", "scripts": { diff --git a/src/patchbay.impl.cpp b/src/patchbay.impl.cpp index e7794d1..4ee6029 100644 --- a/src/patchbay.impl.cpp +++ b/src/patchbay.impl.cpp @@ -305,16 +305,16 @@ namespace vencord if (options.only_default_speakers && input_id != speaker->id) { - logger::get()->trace("[patchbay] (on_link) {} is not connected to speaker but with {}", id, input_id); + logger::get()->debug("[patchbay] (on_link) {} is not connected to speaker but with {}", id, input_id); return; } auto output_props = nodes[output_id].info.props; // The node emitting sound auto input_props = nodes[input_id].info.props; // The node receiving sound - if (!options.only_default_speakers && input_props["device.id"].empty()) + if (options.only_speakers && input_props["device.id"].empty()) { - logger::get()->trace("[patchbay] (on_link) {} is not playing to a device: {}", id, input_id); + logger::get()->debug("[patchbay] (on_link) {} is not playing to a device: {}", id, input_id); return; }