Provide option to select the source for audio on Linux

This commit is contained in:
loki
2020-01-18 00:58:27 +01:00
parent 29098a8f1d
commit 15dd6b3cd0
5 changed files with 30 additions and 2 deletions

View File

@@ -26,6 +26,8 @@ video_t video {
"zerolatency"s // tune
};
audio_t audio {};
stream_t stream {
2s, // ping_timeout
@@ -172,6 +174,8 @@ void parse_file(const char *file) {
string_f(vars, "file_devices", nvhttp.file_devices);
string_f(vars, "external_ip", nvhttp.external_ip);
string_f(vars, "audio_sink", audio.sink);
string_restricted_f(vars, "origin_pin_allowed", nvhttp.origin_pin_allowed, {
"pc"sv, "lan"sv, "wan"sv
});

View File

@@ -19,6 +19,10 @@ struct video_t {
std::string tune;
};
struct audio_t {
std::string sink;
};
struct stream_t {
std::chrono::milliseconds ping_timeout;
@@ -52,6 +56,7 @@ struct sunshine_t {
};
extern video_t video;
extern audio_t audio;
extern stream_t stream;
extern nvhttp_t nvhttp;
extern input_t input;

View File

@@ -23,6 +23,7 @@
#include <bitset>
#include <sunshine/task_pool.h>
#include <sunshine/config.h>
namespace platf {
using namespace std::literals;
@@ -330,15 +331,22 @@ std::unique_ptr<mic_t> microphone(std::uint32_t sample_rate) {
};
int status;
const char *audio_sink = nullptr;
if(!config::audio.sink.empty()) {
audio_sink = config::audio.sink.c_str();
}
mic->mic.reset(
pa_simple_new(nullptr, "sunshine", pa_stream_direction_t::PA_STREAM_RECORD, nullptr, "sunshine_record", &mic->ss, nullptr, nullptr, &status)
pa_simple_new(nullptr, "sunshine", pa_stream_direction_t::PA_STREAM_RECORD, audio_sink, "sunshine_record", &mic->ss, nullptr, nullptr, &status)
);
if(!mic->mic) {
auto err_str = pa_strerror(status);
BOOST_LOG(error) << "pa_simple_new() failed: "sv << err_str;
exit(1);
log_flush();
std::abort();
}
return mic;