refactor: return list of currently passthrough'd/input'd apps instead of size

This commit is contained in:
Curve 2021-05-26 18:13:12 +02:00
parent d88e97b708
commit 9642159de9
No known key found for this signature in database
GPG Key ID: 460F6C466BD35813
5 changed files with 46 additions and 20 deletions

View File

@ -2,6 +2,7 @@
#if defined(__linux__)
#include <core/enums/enums.hpp>
#include <memory>
#include <set>
#include <string>
#include <vector>
@ -39,8 +40,8 @@ namespace Soundux
virtual bool revertDefault() = 0;
virtual bool muteInput(bool) = 0;
virtual bool isCurrentlyPassingThrough() = 0;
virtual std::size_t passedThroughApplications() = 0;
virtual std::set<std::string> currentlyInputApps() = 0;
virtual std::set<std::string> currentlyPassedThrough() = 0;
virtual bool stopAllPassthrough() = 0;
virtual bool stopPassthrough(const std::string &) = 0;

View File

@ -668,9 +668,25 @@ namespace Soundux::Objects
return success;
}
bool PipeWire::isCurrentlyPassingThrough()
std::set<std::string> PipeWire::currentlyInputApps()
{
return !passthroughLinks.empty();
std::set<std::string> rtn;
for (const auto &[app, links] : soundInputLinks)
{
rtn.emplace(app);
}
return rtn;
}
std::set<std::string> PipeWire::currentlyPassedThrough()
{
std::set<std::string> rtn;
for (const auto &[app, links] : passthroughLinks)
{
rtn.emplace(app);
}
return rtn;
}
bool PipeWire::stopPassthrough(const std::string &name)
@ -701,10 +717,5 @@ namespace Soundux::Objects
passthroughLinks.clear();
return true;
}
std::size_t PipeWire::passedThroughApplications()
{
return passthroughLinks.size();
}
} // namespace Soundux::Objects
#endif

View File

@ -103,9 +103,10 @@ namespace Soundux
bool revertDefault() override;
bool muteInput(bool state) override;
std::set<std::string> currentlyInputApps() override;
std::set<std::string> currentlyPassedThrough() override;
bool stopAllPassthrough() override;
bool isCurrentlyPassingThrough() override;
std::size_t passedThroughApplications() override;
bool stopPassthrough(const std::string &name) override;
bool passthroughFrom(std::shared_ptr<PlaybackApp> app) override;

View File

@ -635,11 +635,6 @@ namespace Soundux::Objects
return success;
}
bool PulseAudio::isCurrentlyPassingThrough()
{
return !movedPassthroughApplications.empty();
}
bool PulseAudio::switchOnConnectPresent()
{
bool isPresent = false;
@ -702,9 +697,26 @@ namespace Soundux::Objects
return false;
}
std::size_t PulseAudio::passedThroughApplications()
std::set<std::string> PulseAudio::currentlyInputApps()
{
return movedPassthroughApplications.size();
std::set<std::string> rtn;
for (const auto &[app, original] : movedApplications)
{
rtn.emplace(app);
}
return rtn;
}
std::set<std::string> PulseAudio::currentlyPassedThrough()
{
std::set<std::string> rtn;
for (const auto &[app, original] : movedPassthroughApplications)
{
rtn.emplace(app);
}
return rtn;
}
} // namespace Soundux::Objects
#endif

View File

@ -76,9 +76,10 @@ namespace Soundux
bool revertDefault() override;
bool muteInput(bool state) override;
std::set<std::string> currentlyInputApps() override;
std::set<std::string> currentlyPassedThrough() override;
bool stopAllPassthrough() override;
bool isCurrentlyPassingThrough() override;
std::size_t passedThroughApplications() override;
bool stopPassthrough(const std::string &name) override;
bool passthroughFrom(std::shared_ptr<PlaybackApp> app) override;