diff --git a/examples/channels/main.cpp b/examples/channels/main.cpp index 06698bd..f5e8924 100644 --- a/examples/channels/main.cpp +++ b/examples/channels/main.cpp @@ -26,8 +26,7 @@ int main() { auto [sender, receiver] = pw::channel(); - auto thread = [](recipe::receiver receiver) - { + auto thread = [](recipe::receiver receiver) { auto loop = pw::main_loop::create(); auto context = pw::context::create(loop); auto core = context->core(); @@ -37,46 +36,44 @@ int main() bool exit = false; - receiver.attach(loop, - [&](const T &msg) + receiver.attach(loop, [&](const T &msg) { + if constexpr (std::same_as) + { + auto node = core->create(pw::factory{ + .name = "adapter", + .props = { - if constexpr (std::same_as) - { - auto node = core->create(pw::factory{ - .name = "adapter", - .props = - { - {"node.name", msg.name}, - {"media.class", "Audio/Source/Virtual"}, - {"factory.name", "support.null-audio-sink"}, - }, - }); - - created.emplace_back(std::move(node.get())); - } - else if constexpr (std::same_as) - { - auto &mic = created.back(); - - if (!mic.has_value()) - { - std::cerr << "Failed to create node!" << std::endl; - - auto error = mic.error(); - std::cerr << error.message << std::endl; - - return; - } - - std::cout << "Created successfully!" << std::endl; - std::cout << mic.value().id() << std::endl; - } - else if constexpr (std::same_as) - { - exit = true; - loop->quit(); - } - }); + {"node.name", msg.name}, + {"media.class", "Audio/Source/Virtual"}, + {"factory.name", "support.null-audio-sink"}, + }, + }); + + created.emplace_back(std::move(node.get())); + } + else if constexpr (std::same_as) + { + auto &mic = created.back(); + + if (!mic.has_value()) + { + std::cerr << "Failed to create node!" << std::endl; + + auto error = mic.error(); + std::cerr << error.message << std::endl; + + return; + } + + std::cout << "Created successfully!" << std::endl; + std::cout << mic.value().id() << std::endl; + } + else if constexpr (std::same_as) + { + exit = true; + loop->quit(); + } + }); while (!exit) { @@ -95,4 +92,4 @@ int main() t1.join(); return 0; -} \ No newline at end of file +} diff --git a/examples/mute-microphone/main.cpp b/examples/mute-microphone/main.cpp index c3d0121..583bb83 100644 --- a/examples/mute-microphone/main.cpp +++ b/examples/mute-microphone/main.cpp @@ -2,9 +2,11 @@ #include #include -#include #include +#include +#include + namespace pw = pipewire; int main() @@ -18,8 +20,7 @@ int main() auto listener = reg->listen(); - auto on_global = [&](const pipewire::global &global) - { + auto on_global = [&](const pipewire::global &global) { if (global.type != pipewire::device::type) { return; @@ -61,12 +62,10 @@ int main() auto params = device.params(); core->update(); - auto get_mute = [](const pw::spa::pod &pod) - { + auto get_mute = [](const pw::spa::pod &pod) { // NOLINTNEXTLINE auto impl = [](const pw::spa::pod_prop *parent, const pw::spa::pod &pod, - auto &self) -> std::optional - { + auto &self) -> std::optional { if (pod.type() == pw::spa::pod_type::object) { for (const auto &item : pod.body()) @@ -125,4 +124,4 @@ int main() device.set_param(13, pods.at(13).get()); core.sync(); -*/ \ No newline at end of file +*/ diff --git a/examples/roundtrip/main.cpp b/examples/roundtrip/main.cpp index 700b260..f8df536 100644 --- a/examples/roundtrip/main.cpp +++ b/examples/roundtrip/main.cpp @@ -2,6 +2,8 @@ #include #include + +#include #include namespace pw = pipewire; @@ -15,8 +17,7 @@ int main() auto listener = reg->listen(); - auto on_global = [&](const pw::global &global) - { + auto on_global = [&](const pw::global &global) { if (global.type != pw::node::type) { return; diff --git a/examples/virtual-mic/main.cpp b/examples/virtual-mic/main.cpp index 579f6b9..9d0ab77 100644 --- a/examples/virtual-mic/main.cpp +++ b/examples/virtual-mic/main.cpp @@ -6,6 +6,8 @@ #include #include + +#include #include namespace pw = pipewire; @@ -25,8 +27,7 @@ int main() auto listener = reg->listen(); - auto on_global = [&](const pw::global &global) - { + auto on_global = [&](const pw::global &global) { if (global.type == pw::metadata::type) { auto metadata = reg->bind(global.id).get(); @@ -180,4 +181,4 @@ int main() std::cin.get(); return 0; -} \ No newline at end of file +}