Skip to content

Commit

Permalink
feat(patchbay): cache has_pipewire result
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Oct 14, 2023
1 parent 7c5837d commit 4e14a01
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/patchbay.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "patchbay.impl.hpp"

#include <future>
#include <optional>
#include <pulse/pulseaudio.h>

namespace vencord
Expand Down Expand Up @@ -39,6 +40,13 @@ namespace vencord

bool patchbay::has_pipewire()
{
static std::optional<bool> cached;

if (cached)
{
return cached.value();
}

auto *loop = pa_mainloop_new();
auto *context = pa_context_new(pa_mainloop_get_api(loop), "venmic-info");

Expand Down Expand Up @@ -98,6 +106,9 @@ namespace vencord
auto name = result.get();
std::transform(name.begin(), name.end(), name.begin(), [](char c) { return std::tolower(c); });

return name.find("pipewire") != std::string::npos;
auto rtn = name.find("pipewire") != std::string::npos;
cached.emplace(rtn);

return rtn;
}
} // namespace vencord

0 comments on commit 4e14a01

Please sign in to comment.