Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compile commands for IDE
set(MOONLIGHT_BUILD_KIND "HOST" CACHE STRING "Internal Moonlight build mode")
set_property(CACHE MOONLIGHT_BUILD_KIND PROPERTY STRINGS HOST XBOX)
option(MOONLIGHT_BUILD_VIDEO_EXPERIMENTS "Build standalone GPU presentation and MPEG-2 sampling experiments" OFF)
option(MOONLIGHT_BUILD_AUDIO_EXPERIMENTS "Build the standalone Opus playback probe" OFF)
option(MOONLIGHT_INPUT_DIAGNOSTICS "Display digital controller state while diagnosing stream input" OFF)

if(MOONLIGHT_BUILD_KIND STREQUAL "XBOX")
Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ framebuffer when available and performed better in xemu. **GPU** uses NV2A color
with automatic software fallback. The setting is saved as `streaming.gpu_presentation` and both paths
are available in the same build.

## Stream audio

Choose **Settings → Audio → Audio Mode** before starting or resuming a stream. **Stereo** keeps
left and right separate and is the default. **Mono** mixes the stereo stream locally and plays the
same signal through both outputs. The selection is saved as `streaming.audio_mode` with a value
of `stereo` or `mono`.

**Play Audio on Xbox** defaults to **On**. Turn it off to skip local audio decoding and playback.
**Play Audio on PC** defaults to **Off**. Turn it on to request playback on the host during the stream.
Saved choices take precedence. To check Xbox audio without a host, use the
[standalone audio probe](experiments/README.md#audio-playback-probe).

## Streaming controls and statistics

The default stream profile is **640×480 at 60 FPS and 3 Mbps**. Saved settings take precedence.
Expand Down Expand Up @@ -263,11 +275,12 @@ For host and Xbox builds, CMake checks whether the compiler supports Clang's `un
cmake -S . -B cmake-build-release -DBUILD_DOCS=OFF -DCMAKE_BUILD_TYPE=Release
```

Video build settings:
Optional Xbox build settings:

| CMake option | Default | Purpose |
| ----------------------------------- | ------- | ---------------------------------------------------------------------------------------------- |
| `MOONLIGHT_BUILD_VIDEO_EXPERIMENTS` | `OFF` | Build the standalone probes described in [Video experiments](experiments/README.md). |
| `MOONLIGHT_BUILD_VIDEO_EXPERIMENTS` | `OFF` | Build the standalone [video probes](experiments/README.md). |
| `MOONLIGHT_BUILD_AUDIO_EXPERIMENTS` | `OFF` | Build the standalone [audio playback probe](experiments/README.md#audio-playback-probe). |
| `MOONLIGHT_INPUT_DIAGNOSTICS` | `OFF` | Show controller state and event counters. Select Software presentation to see the debug strip. |

Pass these options when configuring. Existing build directories retain cached build options until
Expand Down Expand Up @@ -425,19 +438,18 @@ scripts\setup-xemu.cmd --skip-support-files
- [x] Game/App Selection
- [x] Host Details
- [x] App Details
- [ ] Pause/Hotkey overlay
- [x] Pause/Hotkey overlay
- Streaming
- [x] Video - https://www.xbmc4xbox.org.uk/wiki/XBMC_Features_and_Supported_Formats#Xbox_supported_video_formats_and_resolutions
- [ ] Audio
- [ ] Mono
- [ ] Stereo
- [ ] 5.1 Surround
- [ ] 7.1 Surround
- [x] Mono
- [x] Stereo
- [ ] Dolby Digital 5.1 output over optical S/PDIF
- Input
- [x] Gamepad Input
- [ ] Keyboard Input
- [ ] Mouse Input
- [ ] Mouse Emulation via Gamepad
- [x] Keyboard Input
- [x] Mouse Input
- [x] Mouse Emulation via Gamepad
- Misc.
- [x] Save config and pairing states
- [x] Host pairing
Expand Down
1 change: 1 addition & 0 deletions cmake/nxdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ function(moonlight_add_xbox_build)
-DMOONLIGHT_TOOLCHAIN_FILE:FILEPATH=${toolchain_file}
-DMOONLIGHT_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DMOONLIGHT_BUILD_VIDEO_EXPERIMENTS:BOOL=${MOONLIGHT_BUILD_VIDEO_EXPERIMENTS}
-DMOONLIGHT_BUILD_AUDIO_EXPERIMENTS:BOOL=${MOONLIGHT_BUILD_AUDIO_EXPERIMENTS}
-DMOONLIGHT_INPUT_DIAGNOSTICS:BOOL=${MOONLIGHT_INPUT_DIAGNOSTICS}
-P "${driver_script}"
)
Expand Down
1 change: 1 addition & 0 deletions cmake/run-child-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(MOONLIGHT_COMMAND_MODE STREQUAL "configure")
-B "${MOONLIGHT_BINARY_DIR}"
-DMOONLIGHT_BUILD_KIND:STRING=XBOX
"-DMOONLIGHT_BUILD_VIDEO_EXPERIMENTS:BOOL=${MOONLIGHT_BUILD_VIDEO_EXPERIMENTS}"
"-DMOONLIGHT_BUILD_AUDIO_EXPERIMENTS:BOOL=${MOONLIGHT_BUILD_AUDIO_EXPERIMENTS}"
"-DMOONLIGHT_INPUT_DIAGNOSTICS:BOOL=${MOONLIGHT_INPUT_DIAGNOSTICS}"
"-DMOONLIGHT_NXDK_DIR:PATH=${MOONLIGHT_NXDK_SOURCE_DIR}"
"-DMOONLIGHT_NXDK_BUILD_DIR:PATH=${MOONLIGHT_NXDK_DIR}"
Expand Down
1 change: 1 addition & 0 deletions cmake/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ list(REMOVE_ITEM MOONLIGHT_SOURCES
set(MOONLIGHT_TEST_EXCLUDED_SOURCES
"${MOONLIGHT_SOURCE_ROOT}/src/input/shell_controller.cpp"
"${MOONLIGHT_SOURCE_ROOT}/src/main.cpp"
"${MOONLIGHT_SOURCE_ROOT}/src/streaming/audio_player.cpp"
"${MOONLIGHT_SOURCE_ROOT}/src/splash/splash_screen.cpp"
"${MOONLIGHT_SOURCE_ROOT}/src/streaming/ffmpeg_stream_backend.cpp"
"${MOONLIGHT_SOURCE_ROOT}/src/streaming/ffmpeg_video_frame.cpp"
Expand Down
1 change: 1 addition & 0 deletions cmake/stage-lucide.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ foreach(icon IN ITEMS
scroll-text
settings
share-2
volume-2
)
set(_icon_source "${LUCIDE_SOURCE_DIR}/icons/${icon}.svg")
if(NOT EXISTS "${_icon_source}")
Expand Down
31 changes: 31 additions & 0 deletions cmake/xbox-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,37 @@ add_custom_target(xbe_iso ALL
)
add_dependencies(xbe_iso cxbe_convert)

if(MOONLIGHT_BUILD_AUDIO_EXPERIMENTS)
add_executable(audio_playback_probe
"${CMAKE_SOURCE_DIR}/experiments/audio_playback_probe.cpp"
"${CMAKE_SOURCE_DIR}/src/logging/logger.cpp"
"${CMAKE_SOURCE_DIR}/src/streaming/audio_configuration.cpp"
"${CMAKE_SOURCE_DIR}/src/streaming/audio_player.cpp"
"${CMAKE_SOURCE_DIR}/src/_nxdk_compat/fenv_compat.cpp")
target_include_directories(audio_playback_probe PRIVATE
"${CMAKE_SOURCE_DIR}"
"${MOONLIGHT_FFMPEG_INCLUDE_DIR}")
target_compile_definitions(audio_playback_probe PRIVATE NXDK XBOX)
target_compile_options(audio_playback_probe PRIVATE -std=gnu++17)
target_link_options(audio_playback_probe PRIVATE /safeseh:no)
target_link_libraries(audio_playback_probe PRIVATE
${MOONLIGHT_FFMPEG_LIBRARIES}
NXDK::NXDK NXDK::NXDK_CXX NXDK::SDL2 moonlight_nxdk_compat)
set(_audio_playback_probe_xbe_dir "${CMAKE_CURRENT_BINARY_DIR}/audio-playback-probe")
file(MAKE_DIRECTORY "${_audio_playback_probe_xbe_dir}")
add_custom_target(audio_playback_probe_iso ALL
COMMAND "${NXDK_DIR}/tools/cxbe/cxbe"
"-OUT:${_audio_playback_probe_xbe_dir}/default.xbe"
"-TITLE:Opus audio playback probe"
"$<TARGET_FILE:audio_playback_probe>"
COMMAND "${NXDK_DIR}/tools/extract-xiso/build/extract-xiso"
-c "${_audio_playback_probe_xbe_dir}" "AudioPlaybackProbe.iso"
DEPENDS audio_playback_probe
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Package the standalone Opus playback probe"
VERBATIM)
endif()

if(MOONLIGHT_BUILD_VIDEO_EXPERIMENTS)
add_executable(pvideo_presentation_probe
"${CMAKE_SOURCE_DIR}/experiments/pvideo_presentation_probe.cpp"
Expand Down
Binary file modified docs/images/screenshots/04-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 46 additions & 5 deletions experiments/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Video experiments
# Xbox experiments

These optional Xbox programs exercise video presentation and fractional sampling independently
of a streaming host. They use the production presenter and are disabled in the default build.
These optional Xbox programs exercise video presentation, fractional sampling and audio playback
independently of a streaming host. They share production code and are disabled in the default build.

## Build and run

From the repository root, using the normal build prerequisites and toolchain:

```bash
cmake -S . -B cmake-build-experiments -DCMAKE_BUILD_TYPE=Release -DBUILD_DOCS=OFF -DMOONLIGHT_BUILD_VIDEO_EXPERIMENTS=ON
cmake -S . -B cmake-build-experiments -DCMAKE_BUILD_TYPE=Release -DBUILD_DOCS=OFF -DMOONLIGHT_BUILD_VIDEO_EXPERIMENTS=ON -DMOONLIGHT_BUILD_AUDIO_EXPERIMENTS=ON
cmake --build cmake-build-experiments
```

Expand All @@ -19,6 +19,7 @@ The Xbox child build selects Unix Makefiles automatically. The generated files a
| ----------------- | ---------------------------------------------------------- | -------------------------------------------------------------------- |
| Presentation | `cmake-build-experiments/xbox/PvideoPresentationProbe.iso` | `cmake-build-experiments/xbox/pvideo-presentation-probe/default.xbe` |
| MPEG-2 prediction | `cmake-build-experiments/xbox/Mpeg2MotionProbe.iso` | `cmake-build-experiments/xbox/mpeg2-motion-probe/default.xbe` |
| Audio playback | `cmake-build-experiments/xbox/AudioPlaybackProbe.iso` | `cmake-build-experiments/xbox/audio-playback-probe/default.xbe` |

Launch an ISO with the repository's configured xemu installation, for example:

Expand All @@ -27,7 +28,7 @@ Launch an ISO with the repository's configured xemu installation, for example:
```

From a Windows command prompt, use `scripts\run-xemu.cmd --iso` with the same ISO path.
The probes use GPU presentation directly. The streaming client selects its path in
The video probes use GPU presentation directly. The streaming client selects its path in
**Settings → Display → Video Presentation**.

## Presentation probe
Expand All @@ -50,3 +51,43 @@ This is a visual comparison of one prediction stage, not a compressed-video deco
bit-exact reconstruction test. The overlay is composed during scanout and cannot be read back
through the RGB framebuffer. Console testing is needed to assess image correctness and
performance on hardware; emulator output alone cannot establish those properties.

## Audio playback probe

Launch `AudioPlaybackProbe.iso` with the same launcher. The probe runs two short tone tests through
the stream client's FFmpeg Opus decoder, mixer and SDL playback device.

| Test | Encoded tone | Expected Xbox output |
| ------ | ------------ | -------------------- |
| Stereo | Front left | 500 Hz on the left |
| Mono | Front left | 500 Hz on both sides |

Listen for the listed speaker in each test. **AUDIO PROBE COMPLETE** confirms every mode decoded and
queued the expected PCM byte count and the SDL queue drained. Audible output or a host audio capture
verifies the channel routing. The probe uses local Opus packets and can run with Sunshine closed.

## 5.1 channel check

Generate the host-side test files from the repository root with Python and FFmpeg on your path.
Choose an output directory under the current directory. Use a fresh directory for each run to
preserve any existing test files.

```bash
python experiments/generate_surround_channel_check.py cmake-build-experiments/audio
```

The 5.1 WAV plays a one-second tone on each channel with half a second of silence between tones.
Play it through a 5.1-capable player and output to check speaker routing.

| Time | Active channel |
| --------- | -------------- |
| 0.5–1.5 s | Front left |
| 2.0–3.0 s | Front right |
| 3.5–4.5 s | Front center |
| 5.0–6.0 s | LFE |
| 6.5–7.5 s | Surround left |
| 8.0–9.0 s | Surround right |

The `.spdif` file carries the same sequence as IEC 61937 bursts containing Dolby Digital AC-3.
It provides test data for a future Xbox digital output backend. The xemu playback probe above
exercises the existing stereo PCM output.
Loading
Loading