Select audio endpoint based on config option audio_sink on Windows
This commit is contained in:
@@ -62,9 +62,13 @@ fec_percentage = 10
|
|||||||
# If you do not specify this variable, pulseaudio will select the default monitor device.
|
# If you do not specify this variable, pulseaudio will select the default monitor device.
|
||||||
#
|
#
|
||||||
# You can find the name of the audio sink using the following command:
|
# You can find the name of the audio sink using the following command:
|
||||||
|
# !! Linux only !!
|
||||||
# pacmd list-sources | grep "name:"
|
# pacmd list-sources | grep "name:"
|
||||||
# audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo.monitor
|
# audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo.monitor
|
||||||
|
#
|
||||||
|
# !! Windows only !!
|
||||||
|
# tools\audio-info.exe
|
||||||
|
# audio_sink = {0.0.0.00000000}.{FD47D9CC-4218-4135-9CE2-0C195C87405B}
|
||||||
|
|
||||||
# !! Windows only !!
|
# !! Windows only !!
|
||||||
# You can select the video card you want to stream:
|
# You can select the video card you want to stream:
|
||||||
|
|||||||
@@ -6,8 +6,11 @@
|
|||||||
#include <mmdeviceapi.h>
|
#include <mmdeviceapi.h>
|
||||||
#include <audioclient.h>
|
#include <audioclient.h>
|
||||||
|
|
||||||
|
#include <codecvt>
|
||||||
|
|
||||||
#include <synchapi.h>
|
#include <synchapi.h>
|
||||||
|
|
||||||
|
#include "sunshine/config.h"
|
||||||
#include "sunshine/main.h"
|
#include "sunshine/main.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@@ -83,14 +86,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
device_t::pointer device_p{};
|
device_t::pointer device_p{};
|
||||||
status = device_enum->GetDefaultAudioEndpoint(
|
|
||||||
eRender,
|
if(config::audio.sink.empty()) {
|
||||||
eConsole,
|
status = device_enum->GetDefaultAudioEndpoint(
|
||||||
&device_p);
|
eRender,
|
||||||
|
eConsole,
|
||||||
|
&device_p);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter;
|
||||||
|
auto wstring_device_id = converter.from_bytes(config::audio.sink);
|
||||||
|
|
||||||
|
status = device_enum->GetDevice(wstring_device_id.c_str(), &device_p);
|
||||||
|
}
|
||||||
device.reset(device_p);
|
device.reset(device_p);
|
||||||
|
|
||||||
if (FAILED(status)) {
|
if (FAILED(status)) {
|
||||||
BOOST_LOG(error) << "Couldn't create Device [0x"sv << util::hex(status).to_string_view() << ']';
|
BOOST_LOG(error) << "Couldn't create audio Device [0x"sv << util::hex(status).to_string_view() << ']';
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -104,7 +116,7 @@ public:
|
|||||||
audio_client.reset(audio_client_p);
|
audio_client.reset(audio_client_p);
|
||||||
|
|
||||||
if (FAILED(status)) {
|
if (FAILED(status)) {
|
||||||
BOOST_LOG(error) << "Couldn't activate Device [0x"sv << util::hex(status).to_string_view() << ']';
|
BOOST_LOG(error) << "Couldn't activate audio Device [0x"sv << util::hex(status).to_string_view() << ']';
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -167,7 +179,7 @@ public:
|
|||||||
std::uint32_t frames;
|
std::uint32_t frames;
|
||||||
status = audio_client->GetBufferSize(&frames);
|
status = audio_client->GetBufferSize(&frames);
|
||||||
if (FAILED(status)) {
|
if (FAILED(status)) {
|
||||||
BOOST_LOG(error) << "Couldn't acquire the number of frames [0x"sv << util::hex(status).to_string_view() << ']';
|
BOOST_LOG(error) << "Couldn't acquire the number of audio frames [0x"sv << util::hex(status).to_string_view() << ']';
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user