Skip to content

Commit

Permalink
fix: avoid duplicating audio modes
Browse files Browse the repository at this point in the history
  • Loading branch information
ABeltramo committed Aug 14, 2024
1 parent b445cb2 commit 7a748a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
33 changes: 4 additions & 29 deletions src/moonlight-server/rest/endpoints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,48 +247,23 @@ create_run_session(const std::shared_ptr<typename SimpleWeb::Server<SimpleWeb::H
std::stoi(display_mode_str[2].data()),
state->config->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;
}

Expand Down
2 changes: 0 additions & 2 deletions src/moonlight-server/wolf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ immer::array<moonlight::DisplayMode> getDisplayModes() {
* @brief Get the Audio Modes
*/
immer::array<state::AudioMode> getAudioModes() {

// TODO: avoid duplication in endpoints.hpp
return {// Stereo
{.channels = 2,
.streams = 1,
Expand Down

0 comments on commit 7a748a1

Please sign in to comment.