From 7a748a10c9738688319c785677df35dc8a016ae7 Mon Sep 17 00:00:00 2001 From: ABeltramo Date: Wed, 14 Aug 2024 20:47:35 +0100 Subject: [PATCH] fix: avoid duplicating audio modes --- src/moonlight-server/rest/endpoints.hpp | 33 +++---------------------- src/moonlight-server/wolf.cpp | 2 -- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/moonlight-server/rest/endpoints.hpp b/src/moonlight-server/rest/endpoints.hpp index 4feb0a98..117ca7ad 100644 --- a/src/moonlight-server/rest/endpoints.hpp +++ b/src/moonlight-server/rest/endpoints.hpp @@ -247,48 +247,23 @@ create_run_session(const std::shared_ptrconfig->support_hevc, state->config->support_av1}; - // forcing stereo, TODO: what should we select here? auto surround_info = std::stoi(get_header(headers, "surroundAudioInfo").value_or("196610")); int channelCount = surround_info & (65535); state::AudioMode audio_mode; switch (channelCount) { case 2: // stereo - audio_mode = {.channels = 2, - .streams = 1, - .coupled_streams = 1, - .speakers = {state::AudioMode::FRONT_LEFT, state::AudioMode::FRONT_RIGHT}}; + audio_mode = state->host->audio_modes[0]; break; case 6: // 5.1 - audio_mode = {.channels = 6, - .streams = 4, - .coupled_streams = 2, - .speakers = {state::AudioMode::FRONT_LEFT, - state::AudioMode::FRONT_RIGHT, - state::AudioMode::FRONT_CENTER, - state::AudioMode::LOW_FREQUENCY, - state::AudioMode::BACK_LEFT, - state::AudioMode::BACK_RIGHT}}; + audio_mode = state->host->audio_modes[1]; break; case 8: // 7.1 - audio_mode = {.channels = 8, - .streams = 5, - .coupled_streams = 3, - .speakers = {state::AudioMode::FRONT_LEFT, - state::AudioMode::FRONT_RIGHT, - state::AudioMode::FRONT_CENTER, - state::AudioMode::LOW_FREQUENCY, - state::AudioMode::BACK_LEFT, - state::AudioMode::BACK_RIGHT, - state::AudioMode::SIDE_LEFT, - state::AudioMode::SIDE_RIGHT}}; + audio_mode = state->host->audio_modes[2]; break; default: logs::log(logs::warning, "Moonlight sent an unsupported audio channel count: {}", channelCount); - audio_mode = {.channels = 2, - .streams = 1, - .coupled_streams = 1, - .speakers = {state::AudioMode::FRONT_LEFT, state::AudioMode::FRONT_RIGHT}}; + audio_mode = state->host->audio_modes[0]; break; } diff --git a/src/moonlight-server/wolf.cpp b/src/moonlight-server/wolf.cpp index 92fa56bd..ad19fe30 100644 --- a/src/moonlight-server/wolf.cpp +++ b/src/moonlight-server/wolf.cpp @@ -46,8 +46,6 @@ immer::array getDisplayModes() { * @brief Get the Audio Modes */ immer::array getAudioModes() { - - // TODO: avoid duplication in endpoints.hpp return {// Stereo {.channels = 2, .streams = 1,