Merge remote-tracking branch 'sunshine/master'
This commit is contained in:
@@ -129,13 +129,10 @@ namespace audio {
|
||||
|
||||
void capture(safe::mail_t mail, config_t config, void *channel_data) {
|
||||
auto shutdown_event = mail->event<bool>(mail::shutdown);
|
||||
|
||||
if (config.input_only) {
|
||||
BOOST_LOG(info) << "Input only session, audio will not be captured."sv;
|
||||
if (!config::audio.stream || config.input_only) {
|
||||
shutdown_event->view();
|
||||
return;
|
||||
}
|
||||
|
||||
auto stream = stream_configs[map_stream(config.channels, config.flags[config_t::HIGH_QUALITY])];
|
||||
if (config.flags[config_t::CUSTOM_SURROUND_PARAMS]) {
|
||||
apply_surround_params(stream, config.customStreamParams);
|
||||
|
||||
@@ -416,12 +416,7 @@ namespace config {
|
||||
auto final_resolution = entry.template get_optional<std::string>("final_resolution"s);
|
||||
auto final_refresh_rate = entry.template get_optional<std::string>("final_refresh_rate"s);
|
||||
|
||||
output_field.push_back(video_t::dd_t::mode_remapping_entry_t {
|
||||
requested_resolution.value_or(""),
|
||||
requested_fps.value_or(""),
|
||||
final_resolution.value_or(""),
|
||||
final_refresh_rate.value_or("")
|
||||
});
|
||||
output_field.push_back(video_t::dd_t::mode_remapping_entry_t {requested_resolution.value_or(""), requested_fps.value_or(""), final_resolution.value_or(""), final_refresh_rate.value_or("")});
|
||||
}
|
||||
}};
|
||||
|
||||
@@ -523,6 +518,7 @@ namespace config {
|
||||
audio_t audio {
|
||||
{}, // audio_sink
|
||||
{}, // virtual_sink
|
||||
true, // stream audio
|
||||
true, // install_steam_drivers
|
||||
true, // keep_sink_default
|
||||
true, // auto_capture
|
||||
@@ -1215,6 +1211,7 @@ namespace config {
|
||||
|
||||
string_f(vars, "audio_sink", audio.sink);
|
||||
string_f(vars, "virtual_sink", audio.virtual_sink);
|
||||
bool_f(vars, "stream_audio", audio.stream);
|
||||
bool_f(vars, "install_steam_audio_drivers", audio.install_steam_drivers);
|
||||
bool_f(vars, "keep_sink_default", audio.keep_default);
|
||||
bool_f(vars, "auto_capture_sink", audio.auto_capture);
|
||||
|
||||
@@ -152,6 +152,7 @@ namespace config {
|
||||
struct audio_t {
|
||||
std::string sink;
|
||||
std::string virtual_sink;
|
||||
bool stream;
|
||||
bool install_steam_drivers;
|
||||
bool keep_default;
|
||||
bool auto_capture;
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace net {
|
||||
|
||||
std::uint16_t map_port(int port) {
|
||||
// calculate the port from the config port
|
||||
auto mapped_port = (std::uint16_t)((int) config::sunshine.port + port);
|
||||
auto mapped_port = (std::uint16_t) ((int) config::sunshine.port + port);
|
||||
|
||||
// Ensure port is in the range of 1024-65535
|
||||
if (mapped_port < 1024 || mapped_port > 65535) {
|
||||
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
// There aren't that many DRM_FORMAT I need to use, so define them here
|
||||
//
|
||||
// They aren't likely to change any time soon.
|
||||
#define fourcc_code(a, b, c, d) ((std::uint32_t)(a) | ((std::uint32_t)(b) << 8) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(d) << 24))
|
||||
#define fourcc_code(a, b, c, d) ((std::uint32_t) (a) | ((std::uint32_t) (b) << 8) | ((std::uint32_t) (c) << 16) | ((std::uint32_t) (d) << 24))
|
||||
#define fourcc_mod_code(vendor, val) ((((uint64_t) vendor) << 56) | ((val) & 0x00ffffffffffffffULL))
|
||||
#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(0, ((1ULL << 56) - 1))
|
||||
|
||||
|
||||
@@ -117,15 +117,26 @@ namespace {
|
||||
|
||||
using virtual_sink_waveformats_t = std::vector<WAVEFORMATEXTENSIBLE>;
|
||||
|
||||
/**
|
||||
* @brief List of supported waveformats for an N-channel virtual audio device
|
||||
* @tparam channel_count Number of virtual audio channels
|
||||
* @returns std::vector<WAVEFORMATEXTENSIBLE>
|
||||
* @note The list of virtual formats returned are sorted in preference order and the first valid
|
||||
* format will be used. All bits-per-sample options are listed because we try to match
|
||||
* this to the default audio device. See also: set_format() below.
|
||||
*/
|
||||
template<WORD channel_count>
|
||||
virtual_sink_waveformats_t create_virtual_sink_waveformats() {
|
||||
if constexpr (channel_count == 2) {
|
||||
auto channel_mask = waveformat_mask_stereo;
|
||||
// only choose 24 or 16-bit formats to avoid clobbering existing Dolby/DTS spatial audio settings
|
||||
// The 32-bit formats are a lower priority for stereo because using one will disable Dolby/DTS
|
||||
// spatial audio mode if the user enabled it on the Steam speaker.
|
||||
return {
|
||||
create_waveformat(sample_format_e::s24in32, channel_count, channel_mask),
|
||||
create_waveformat(sample_format_e::s24, channel_count, channel_mask),
|
||||
create_waveformat(sample_format_e::s16, channel_count, channel_mask),
|
||||
create_waveformat(sample_format_e::f32, channel_count, channel_mask),
|
||||
create_waveformat(sample_format_e::s32, channel_count, channel_mask),
|
||||
};
|
||||
} else if (channel_count == 6) {
|
||||
auto channel_mask1 = waveformat_mask_surround51_with_backspeakers;
|
||||
@@ -298,6 +309,10 @@ namespace platf::audio {
|
||||
auto waveformatext_pointer = reinterpret_cast<const WAVEFORMATEXTENSIBLE *>(mixer_waveformat.get());
|
||||
capture_waveformat.dwChannelMask = waveformatext_pointer->dwChannelMask;
|
||||
}
|
||||
|
||||
BOOST_LOG(info) << "Audio mixer format is "sv << mixer_waveformat->wBitsPerSample << "-bit, "sv
|
||||
<< mixer_waveformat->nSamplesPerSec << " Hz, "sv
|
||||
<< ((mixer_waveformat->nSamplesPerSec != 48000) ? "will be resampled to 48000 by Windows"sv : "no resampling needed"sv);
|
||||
}
|
||||
|
||||
status = audio_client->Initialize(
|
||||
@@ -315,7 +330,7 @@ namespace platf::audio {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BOOST_LOG(info) << "Audio capture format is " << logging::bracket(waveformat_to_pretty_string(capture_waveformat));
|
||||
BOOST_LOG(info) << "Audio capture format is "sv << logging::bracket(waveformat_to_pretty_string(capture_waveformat));
|
||||
|
||||
return audio_client;
|
||||
}
|
||||
@@ -795,6 +810,22 @@ namespace platf::audio {
|
||||
}
|
||||
}
|
||||
|
||||
// When switching to a Steam virtual speaker device, try to retain the bit depth of the
|
||||
// default audio device. Switching from a 16-bit device to a 24-bit one has been known to
|
||||
// cause glitches for some users.
|
||||
int wanted_bits_per_sample = 32;
|
||||
auto current_default_dev = default_device(device_enum);
|
||||
if (current_default_dev) {
|
||||
audio::prop_t prop;
|
||||
prop_var_t current_device_format;
|
||||
|
||||
if (SUCCEEDED(current_default_dev->OpenPropertyStore(STGM_READ, &prop)) && SUCCEEDED(prop->GetValue(PKEY_AudioEngine_DeviceFormat, ¤t_device_format.prop))) {
|
||||
auto *format = (WAVEFORMATEXTENSIBLE *) current_device_format.prop.blob.pBlobData;
|
||||
wanted_bits_per_sample = format->Samples.wValidBitsPerSample;
|
||||
BOOST_LOG(info) << "Virtual audio device will use "sv << wanted_bits_per_sample << "-bit to match default device"sv;
|
||||
}
|
||||
}
|
||||
|
||||
auto &device_id = virtual_sink_info->first;
|
||||
auto &waveformats = virtual_sink_info->second.get().virtual_sink_waveformats;
|
||||
for (const auto &waveformat : waveformats) {
|
||||
@@ -804,6 +835,10 @@ namespace platf::audio {
|
||||
auto waveformat_copy = waveformat;
|
||||
auto waveformat_copy_pointer = reinterpret_cast<WAVEFORMATEX *>(&waveformat_copy);
|
||||
|
||||
if (wanted_bits_per_sample != waveformat.Samples.wValidBitsPerSample) {
|
||||
continue;
|
||||
}
|
||||
|
||||
WAVEFORMATEXTENSIBLE p {};
|
||||
if (SUCCEEDED(policy->SetDeviceFormat(device_id_copy.c_str(), waveformat_copy_pointer, (WAVEFORMATEX *) &p))) {
|
||||
BOOST_LOG(info) << "Changed virtual audio sink format to " << logging::bracket(waveformat_to_pretty_string(waveformat));
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace platf::dxgi {
|
||||
{
|
||||
util::buffer_t<std::uint8_t> cursor_img = img_data;
|
||||
std::for_each((std::uint32_t *) std::begin(cursor_img), (std::uint32_t *) std::end(cursor_img), [](auto &pixel) {
|
||||
auto alpha = (std::uint8_t)((pixel >> 24) & 0xFF);
|
||||
auto alpha = (std::uint8_t) ((pixel >> 24) & 0xFF);
|
||||
if (alpha == 0xFF) {
|
||||
// Pixels with 0xFF alpha will be XOR-blended as is.
|
||||
} else if (alpha == 0x00) {
|
||||
@@ -286,7 +286,7 @@ namespace platf::dxgi {
|
||||
{
|
||||
util::buffer_t<std::uint8_t> cursor_img = img_data;
|
||||
std::for_each((std::uint32_t *) std::begin(cursor_img), (std::uint32_t *) std::end(cursor_img), [](auto &pixel) {
|
||||
auto alpha = (std::uint8_t)((pixel >> 24) & 0xFF);
|
||||
auto alpha = (std::uint8_t) ((pixel >> 24) & 0xFF);
|
||||
if (alpha == 0xFF) {
|
||||
// Pixels with 0xFF alpha will be XOR-blended by make_cursor_xor_image().
|
||||
// We make them transparent for the alpha-blended cursor image.
|
||||
|
||||
@@ -92,10 +92,10 @@ namespace platf {
|
||||
|
||||
constexpr float EARTH_G = 9.80665f;
|
||||
|
||||
#define MPS2_TO_DS4_ACCEL(x) (int32_t)(((x) / EARTH_G) * 8192)
|
||||
#define DPS_TO_DS4_GYRO(x) (int32_t)((x) * (1024 / 64))
|
||||
#define MPS2_TO_DS4_ACCEL(x) (int32_t) (((x) / EARTH_G) * 8192)
|
||||
#define DPS_TO_DS4_GYRO(x) (int32_t) ((x) * (1024 / 64))
|
||||
|
||||
#define APPLY_CALIBRATION(val, bias, scale) (int32_t)(((float) (val) + (bias)) / (scale))
|
||||
#define APPLY_CALIBRATION(val, bias, scale) (int32_t) (((float) (val) + (bias)) / (scale))
|
||||
|
||||
constexpr DS4_TOUCH ds4_touch_unused = {
|
||||
.bPacketCounter = 0,
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace rtsp_stream {
|
||||
boost::asio::async_read(sock, boost::asio::buffer(begin, sizeof(encrypted_rtsp_header_t)), boost::bind(&socket_t::handle_read_encrypted_header, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||
} else {
|
||||
sock.async_read_some(
|
||||
boost::asio::buffer(begin, (std::size_t)(std::end(msg_buf) - begin)),
|
||||
boost::asio::buffer(begin, (std::size_t) (std::end(msg_buf) - begin)),
|
||||
boost::bind(
|
||||
&socket_t::handle_read_plaintext,
|
||||
shared_from_this(),
|
||||
@@ -253,7 +253,7 @@ namespace rtsp_stream {
|
||||
}
|
||||
|
||||
sock.async_read_some(
|
||||
boost::asio::buffer(begin, (std::size_t)(std::end(msg_buf) - begin)),
|
||||
boost::asio::buffer(begin, (std::size_t) (std::end(msg_buf) - begin)),
|
||||
boost::bind(
|
||||
&socket_t::handle_plaintext_payload,
|
||||
shared_from_this(),
|
||||
@@ -289,7 +289,7 @@ namespace rtsp_stream {
|
||||
|
||||
auto end = socket->begin + bytes;
|
||||
msg_t req {new msg_t::element_type {}};
|
||||
if (auto status = parseRtspMessage(req.get(), socket->msg_buf.data(), (std::size_t)(end - socket->msg_buf.data()))) {
|
||||
if (auto status = parseRtspMessage(req.get(), socket->msg_buf.data(), (std::size_t) (end - socket->msg_buf.data()))) {
|
||||
BOOST_LOG(error) << "Malformed RTSP message: ["sv << status << ']';
|
||||
|
||||
respond(socket->sock, *socket->session, nullptr, 400, "BAD REQUEST", 0, {});
|
||||
@@ -321,7 +321,7 @@ namespace rtsp_stream {
|
||||
|
||||
if (end - socket->crlf >= content_length) {
|
||||
if (end - socket->crlf > content_length) {
|
||||
BOOST_LOG(warning) << "(end - socket->crlf) > content_length -- "sv << (std::size_t)(end - socket->crlf) << " > "sv << content_length;
|
||||
BOOST_LOG(warning) << "(end - socket->crlf) > content_length -- "sv << (std::size_t) (end - socket->crlf) << " > "sv << content_length;
|
||||
}
|
||||
|
||||
fg.disable();
|
||||
|
||||
@@ -377,7 +377,7 @@ namespace util {
|
||||
return (std::uint8_t) ch - '0';
|
||||
}
|
||||
|
||||
return (std::uint8_t)(ch | (char) 32) - 'a' + (char) 10;
|
||||
return (std::uint8_t) (ch | (char) 32) - 'a' + (char) 10;
|
||||
};
|
||||
|
||||
std::fill_n(buf + buf_size, padding, 0);
|
||||
@@ -431,7 +431,7 @@ namespace util {
|
||||
return (std::uint8_t) ch - '0';
|
||||
}
|
||||
|
||||
return (std::uint8_t)(ch | (char) 32) - 'a' + (char) 10;
|
||||
return (std::uint8_t) (ch | (char) 32) - 'a' + (char) 10;
|
||||
};
|
||||
|
||||
for (auto &el : buf) {
|
||||
@@ -509,12 +509,12 @@ namespace util {
|
||||
std::int64_t res {};
|
||||
std::int64_t mul = 1;
|
||||
while (begin != --end) {
|
||||
res += (std::int64_t)(*end - '0') * mul;
|
||||
res += (std::int64_t) (*end - '0') * mul;
|
||||
|
||||
mul *= 10;
|
||||
}
|
||||
|
||||
return *begin != '-' ? res + (std::int64_t)(*begin - '0') * mul : -res;
|
||||
return *begin != '-' ? res + (std::int64_t) (*begin - '0') * mul : -res;
|
||||
}
|
||||
|
||||
inline std::int64_t from_view(const std::string_view &number) {
|
||||
@@ -981,7 +981,7 @@ namespace util {
|
||||
|
||||
template<class It>
|
||||
std::string_view view(It begin, It end) {
|
||||
return std::string_view {(const char *) begin, (std::size_t)(end - begin)};
|
||||
return std::string_view {(const char *) begin, (std::size_t) (end - begin)};
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
||||
Reference in New Issue
Block a user