Add config option for virtual_sink on windows

This commit is contained in:
loki
2021-05-21 14:28:24 +02:00
parent b119121e10
commit 2fb5f8a7d0
4 changed files with 10 additions and 6 deletions

View File

@@ -84,7 +84,11 @@
# #
# !! Windows only !! # !! Windows only !!
# tools\audio-info.exe # tools\audio-info.exe
# audio_sink = {0.0.0.00000000}.{FD47D9CC-4218-4135-9CE2-0C195C87405B} # audio_sink = {0.0.0.00000000}.{FD47D9CC-4218-4135-9CE2-0C195C87405B}
#
# The virtual sink, is the audio device that's virtual (Like Steam Streaming Speakers), it allows Sunshine
# to stream audio, while muting the speakers.
# virtual_sink = {0.0.0.00000000}.{8edba70c-1125-467c-b89c-15da389bc1d4}
# !! Windows only !! # !! Windows only !!
# You can select the video card you want to stream: # You can select the video card you want to stream:

View File

@@ -39,6 +39,7 @@ struct video_t {
struct audio_t { struct audio_t {
std::string sink; std::string sink;
std::string virtual_sink;
}; };
struct stream_t { struct stream_t {

View File

@@ -214,7 +214,6 @@ std::string from_sockaddr(const sockaddr *const);
std::pair<std::uint16_t, std::string> from_sockaddr_ex(const sockaddr *const); std::pair<std::uint16_t, std::string> from_sockaddr_ex(const sockaddr *const);
std::unique_ptr<audio_control_t> audio_control(); std::unique_ptr<audio_control_t> audio_control();
std::unique_ptr<mic_t> microphone(std::uint32_t sample_rate, std::uint32_t frame_size);
std::shared_ptr<display_t> display(dev_type_e hwdevice_type); std::shared_ptr<display_t> display(dev_type_e hwdevice_type);
input_t input(); input_t input();

View File

@@ -259,10 +259,10 @@ const wchar_t *no_null(const wchar_t *str) {
return str ? str : L"Unknown"; return str ? str : L"Unknown";
} }
format_t::type_e validate_device(device_t &device) { format_t::type_e validate_device(device_t &device, int sample_rate) {
for(const auto &format : formats) { for(const auto &format : formats) {
// Ensure WaveFromat is compatible // Ensure WaveFromat is compatible
auto audio_client = make_audio_client(device, format, SAMPLE_RATE); auto audio_client = make_audio_client(device, format, sample_rate);
BOOST_LOG(debug) << format.name << ": "sv << !audio_client ? "unsupported"sv : "supported"sv; BOOST_LOG(debug) << format.name << ": "sv << !audio_client ? "unsupported"sv : "supported"sv;
@@ -550,13 +550,13 @@ public:
UINT count; UINT count;
collection->GetCount(&count); collection->GetCount(&count);
std::string virtual_device_id; std::string virtual_device_id = config::audio.virtual_sink;
BOOST_LOG(debug) << "====== Found "sv << count << " potential audio devices ======"sv; BOOST_LOG(debug) << "====== Found "sv << count << " potential audio devices ======"sv;
for(auto x = 0; x < count; ++x) { for(auto x = 0; x < count; ++x) {
audio::device_t device; audio::device_t device;
collection->Item(x, &device); collection->Item(x, &device);
auto type = validate_device(device); auto type = validate_device(device, SAMPLE_RATE);
if(type == format_t::none) { if(type == format_t::none) {
continue; continue;
} }