Skip to content

Commit

Permalink
feat(patchbay)!: add only_speakers setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed May 31, 2024
1 parent 5a12732 commit d52565c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions addon/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct patchbay : public Napi::ObjectWrap<patchbay>
auto include = to_array<vencord::node>(data.Get("include"));
auto exclude = to_array<vencord::node>(data.Get("exclude"));
auto ignore_devices = convert<bool>(data.Get("ignore_devices"));
auto only_speakers = convert<bool>(data.Get("only_speakers"));
auto only_default_speakers = convert<bool>(data.Get("only_default_speakers"));
auto workaround = to_array<vencord::node>(data.Get("workaround"));

Expand All @@ -187,6 +188,7 @@ struct patchbay : public Napi::ObjectWrap<patchbay>
.include = include.value_or(std::vector<vencord::node>{}),
.exclude = exclude.value_or(std::vector<vencord::node>{}),
.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<vencord::node>{}),
});
Expand Down
4 changes: 3 additions & 1 deletion include/vencord/patchbay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace vencord
std::vector<node> 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:
Expand Down
2 changes: 2 additions & 0 deletions lib/module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface LinkData
exclude: Node[];

ignore_devices?: boolean;

only_speakers?: boolean;
only_default_speakers?: boolean;

workaround?: Node[];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions src/patchbay.impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d52565c

Please sign in to comment.