Skip to content

Commit

Permalink
feat: add menu + stage music support (#386)
Browse files Browse the repository at this point in the history
* Add support for Rust in CMake via Corrosion

* Tweak .gitignore to handle Rust target dir

* It's 3AM and I have no desire to deal with this

* Initial scaffolding for loading Rust library in Dolphin

* Expose the Dolphin logging mechanisms to Rust via some callback trickery

* Attempt patching Core.vcxproj to support building Rust dylib

* Attempt patching Core.vcxproj to support building Rust dylib, take 2 OR

* Instruct the build to actually use the steps

* Attempt the older style vcxproj definition format

* Push build targets to end

* Just don't use va_args when calling through from Rust

* Enable Windows project linking, move to generic project structure, start moving out of HW

* Add note to README about Rust requirement

* Update slippi-rust-extensions to have proper EXI Device skeleton

* Attach shadow EXI device to cpp EXI device, add feature flag for playback-specific code, rewrite README for rust extensions slightly

* Remove unused log file

* Ongoing logging work

* Tweak Dolphin LogContainer to auto forward enabled/level status over to Rust, expose more methods on Rust side for control, rebuild logger layer subscriber

* Remove debug flag for release mode but add note about it

* Reorganize module definitions, pass in sampler handler fn for SoundStream

* Fix log target

* Rename to SlippiRustExtensions, separate out into cargo workspace, rename General Rust log

* Tweak logging layer so that we don't double-allocate strings on all log messages, properly surface log locations

* cargo fmt

* initial port of slippi-jukebox code

* minor cleanup and leverage channels rather than atomic bool for stopping
threads

* Add config option for enabling/disabling Jukebox

* Invert shutdown order for Memory and ExpansionInterface so we avoid a null ptr race in the Jukebox, as we need Memory to still be valid at Jukebox shutdown

* update dolphin additional include dirs to facilitate new slippi config pane changes

* Ensure Core is running before trying to find an EXI device, as ExpansionInterface isn't initialized unless Core is running - fixes a crash on bad access

* Expose streaming sampler to jukebox, disable DVDInterface streaming sampler pushes to avoid null data being pushed in

* Expose setters for streaming sample rate and streaming volume to Rust

* jukebox: renaming variables for clarity

* try to use new jukebox sample functions

* jukebox: add support for all star rest area

* jukebox: add support for adventure mode field stages

* jukebox: continuously send chunks of pcm data to dolphin's audio mixer

* Audio somewhat coming through now, albeit with pops and pitch issues...

* Force-log samples to wav

* jukebox: switch from dolphin mixer back to rodio for music playback

* Mark doc example as notest

* Attempt an initial CI pass

* Tinkering with CI

* Specify CI working directory for cargo fmt

* Specify CI working directory for cargo fmt

* Specify CI working directory for cargo fmt

* Specify CI working directory for cargo fmt

* Specify CI working directory for cargo fmt

* Specify CI working directory for cargo fmt

* [CI] More permissive for compiling code

* jukebox: replace rand with fastrand

* jukebox: dont use static memory for menu & tournament tracks

* Attempt to resolve Windows playback lib loading oddity

* Add a method for grabbing the current volume level

* Have Dolphin pass over the iso path and a getter for the volume level

* Cargo fmt pass

* Include rustfmt.toml

* Remove the Jukebox config option from playback builds entirely, do not start the jukebox if we're in WASAPI Exclusive mode

* Ix-nay the bad check I copied by accident, lol

* SlippiRustExtensions: add build instructions for windows

* jukebox: make proper use of dolphin's volume + remove unused dependencies

* SlippiRustExtensions(readme): simplify suggested out-of-band build command

* jukebox: remove 'anyhow' dependency

* jukebox: simplify read_dolphin_state fn

* jukebox: reduce hps fingerprint size for track matching

* jukebox: remove 'bus' dependency and improve comments

* jukebox: add readme

* jukebox: add description field to Cargo.toml

* README cleanup, extra writeup for logcontainer creation

* Cleanup unused imports

* Rename DolphinState to DolphinGameState

* Pin to Rust 1.70.0

* Re-enable SFX, stop force-dumping WAV DTK audiograph logs

* Revert attempted change of disabling DTK reads

* Revise documentation surrounding logging infrastructure changes

* Ensure the Volume getter is outside of a C++ namespace, just to try and be careful with ABI oddities

* Add an extra LogContainer.

- A generic Rust dependencies log container that we can use if we need
  to ever inspect dependency tracing logs.
- Moves the AudioCommon::GetVolume call out of the namespace for now
  since I want someone (or me, when I get more time) to verify that
  being inside a C++ namespace is safe.
- Remove once_cell as a dependency now that this is pinned to `1.70.0`.

* Fix the typo, because C++

* Additional README contexts

* ifndef PLAYBACK for GUI toggles

* Always publish an artifact for macOS even if we're not signing and notarizing

* Try changing into the directory - why is there so little documentation about what is supported in these files...?

* Pin toolchain in CI to 1.70.0, update Visual Studio to change into working directory for pre-build Rust step so that toolchain file is actually detected

* Opt for a root symlink to the toolchain config per Nikki's idea, comment out forced 1.70.0 in CI build flow

* Revert symlink toolchain to see if there's a CI bug for Linux

* jukebox: reduce music volume by 20%

* jukebox: link to hps_decode crate in the docs

* ci: sed out rust version from rust-toolchain.toml

* ci: add id field for rust_ver

* jukebox: stop blocking the main thread when scanning iso for tracks

* jukebox: respect melee's volume setting when restarting jukebox during emulation

* jukebox: improve code readability

* jukebox: leverage disc filesystem table to locate .hps files

* jukebox: minor fst parsing code improvements

* remove '.unwrap()' from Jukebox destructor

---------

Co-authored-by: Ryan McGrath <ryan@rymc.io>
Co-authored-by: Nikhil Narayana <nikhil.narayana@live.com>
  • Loading branch information
3 people authored Jul 28, 2023
1 parent f68f6f6 commit e29fe70
Show file tree
Hide file tree
Showing 60 changed files with 9,461 additions and 1,251 deletions.
63 changes: 54 additions & 9 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ on:
- "**.md"

jobs:
slprs_cargo_fmt:
name: (SlippiRustExtensions) Cargo Format
runs-on: ubuntu-latest
outputs:
rust_ver: ${{ steps.rust_ver.outputs.rust_ver }}
steps:
- uses: actions/checkout@v3
- id: rust_ver
name: Grab Rust Version
run: echo "rust_ver=$(sed -rn 's/^channel = "(.*)"/\1/p' ./Externals/SlippiRustExtensions/rust-toolchain.toml)" >> "$GITHUB_OUTPUT"
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.rust_ver.outputs.rust_ver }}
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
with:
manifest-path: ./Externals/SlippiRustExtensions/Cargo.toml

skip_duplicates:
name: Skip Duplicate Runs
runs-on: ubuntu-latest
Expand All @@ -26,7 +45,7 @@ jobs:
do_not_skip: '["push", "workflow_dispatch", "schedule"]'

windows:
needs: skip_duplicates
needs: [skip_duplicates, slprs_cargo_fmt]
if: ${{ needs.skip_duplicates.outputs.should_skip != 'true' }}
strategy:
fail-fast: false
Expand All @@ -47,6 +66,13 @@ jobs:
steps:
- name: "Checkout"
uses: actions/checkout@v2
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ needs.slprs_cargo_fmt.outputs.rust_ver }} # Pin to our specific Rust version.
rustflags: "" # Disable default injection of warnings = errors.
- name: "(SlippiRustExtensions) Run cargo test"
run: cargo test --all --all-features --manifest-path=Externals/SlippiRustExtensions/Cargo.toml
- name: "Remove Redistributable"
shell: cmd
run: |
Expand Down Expand Up @@ -121,7 +147,7 @@ jobs:
path: "./artifact/"

linux:
needs: skip_duplicates
needs: [skip_duplicates, slprs_cargo_fmt]
if: ${{ needs.skip_duplicates.outputs.should_skip != 'true' }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -191,6 +217,13 @@ jobs:
qtbase5-private-dev \
libxxf86vm-dev \
x11proto-xinerama-dev
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ needs.slprs_cargo_fmt.outputs.rust_ver }} # Pin to our specific Rust version.
rustflags: "" # Disable default injection of warnings = errors.
- name: "(SlippiRustExtensions) Run cargo test"
run: cargo test --all --all-features --manifest-path=Externals/SlippiRustExtensions/Cargo.toml
- name: "Build ${{ matrix.build_type }} Dolphin"
if: success()
working-directory: ${{ github.workspace }}
Expand Down Expand Up @@ -222,7 +255,7 @@ jobs:
path: "./artifact/"

macOS:
needs: skip_duplicates
needs: [skip_duplicates, slprs_cargo_fmt]
if: ${{ needs.skip_duplicates.outputs.should_skip != 'true' }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -274,6 +307,13 @@ jobs:
sound-touch \
hidapi \
python@3.10
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ needs.slprs_cargo_fmt.outputs.rust_ver }} # Pin to our specific Rust version.
rustflags: "" # Disable default injection of warnings = errors.
- name: "(SlippiRustExtensions) Run cargo test"
run: cargo test --all --all-features --manifest-path=Externals/SlippiRustExtensions/Cargo.toml
- name: "Build ${{ matrix.build_type }} Dolphin"
if: success()
shell: bash
Expand All @@ -298,14 +338,10 @@ jobs:
mkdir -p ~/private_keys/
echo '${{ secrets.APPLE_CONNECT_API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
/usr/bin/codesign -f -s "${{ secrets.APPLE_IDENTITY_HASH }}" --deep --options runtime --entitlements Source/Core/DolphinWX/Entitlements.plist ./build/Binaries/Slippi\ Dolphin.app
- name: "Package, Sign and Notarize Netplay Release DMG"
if: success() && env.CERTIFICATE_MACOS_APPLICATION != null
- name: "Package ${{ matrix.build_type }} Release DMG"
if: success()
shell: bash
working-directory: ${{ github.workspace }}
env:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
CERTIFICATE_MACOS_APPLICATION: ${{ secrets.CERTIFICATE_MACOS_APPLICATION }}
run: |
rm build/Binaries/traversal_server
chmod +x Tools/create-dmg/run.sh
Expand All @@ -323,6 +359,15 @@ jobs:
"${{ env.FILE_NAME }}.dmg" \
"./build/Binaries/"
mv "${{ env.FILE_NAME }}.dmg" artifact/
- name: "Sign and Notarize ${{ matrix.build_type }} Release DMG"
if: success() && env.CERTIFICATE_MACOS_APPLICATION != null
shell: bash
working-directory: ${{ github.workspace }}
env:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
CERTIFICATE_MACOS_APPLICATION: ${{ secrets.CERTIFICATE_MACOS_APPLICATION }}
run: |
/usr/bin/codesign -f -s "${{ secrets.APPLE_IDENTITY_HASH }}" --deep --options runtime ./artifact/${{ env.FILE_NAME }}.dmg
chmod +x Tools/notarize_netplay.sh && ./Tools/notarize_netplay.sh ./artifact/${{ env.FILE_NAME }}.dmg
- name: "Publish"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Externals/SlippiLib/CMakeCache.txt
Externals/SlippiLib/CMakeFiles/
Externals/SlippiLib/Makefile
Externals/SlippiLib/cmake_install.cmake

# The rust build directory, just ignore it
Externals/SlippiRustExtensions/target

Ishiiruka.pro
Source/.idea/
Source/enc_temp_folder/
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ if(ENCODE_FRAMEDUMPS)

endif()

message("Using static Corrosion from Externals for Rust linking support")
add_subdirectory(Externals/corrosion)

if(NOT ANDROID)
set(PORTAUDIO_FOUND TRUE)
add_definitions(-DHAVE_PORTAUDIO=1)
Expand Down
Loading

0 comments on commit e29fe70

Please sign in to comment.