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
+4
View File
@@ -75,6 +75,10 @@ Trouleshooting:
* If you get "Could not create Sunshine Gamepad: Permission Denied" Try the following steps before running sunshine:
* sudo chown root:input /dev/uinput
* sudo chmod 660 /dev/uinput
* If Sunshine sends audio from the microphone instead of the speaker, try the following steps:
* pacmd list-sources | grep "name:"
* Copy the name to the configuration option "audio_sink"
* restart sunshine
When an application is started, if there is an application already running, it will be terminated.
When the application has been shutdown, the stream shuts down as well.
+7
View File
@@ -57,6 +57,13 @@ fec_percentage = 10
# If back_button_timeout < 0, then the Home/Guide button will not be emulated
# back_button_timeout = 2000
# The name of the audio sink used for Audio Loopback
# If you do not specify this variable, pulseaudio will select a default device, which could be a microphone instead of a speaker
#
# You can find the name of the audio sink using the following command:
# pacmd list-sources | grep "name:"
# audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo.monitor
###############################################
# FFmpeg software encoding parameters
+4
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
});
+5
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;
+10 -2
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;