From 09f76e438bc9c38775c8d46a5e9afc62073be2e7 Mon Sep 17 00:00:00 2001 From: scootz Date: Sat, 2 May 2026 14:49:32 +0100 Subject: [PATCH] properly fix pinning --- .README.md.kate-swp | Bin 0 -> 48 bytes README.md | 61 +++++++++++++++++--------------------------- reforger-surround | 30 ++++++++++++++-------- 3 files changed, 44 insertions(+), 47 deletions(-) create mode 100644 .README.md.kate-swp diff --git a/.README.md.kate-swp b/.README.md.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..a3a8dcc43c074ad5cba96326448f70691e73712f GIT binary patch literal 48 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?VnIdihA!vFTm?Si~hC!K9}Hr-vsb3WJ= E09qRmwEzGB literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 188e73f..854f24e 100644 --- a/README.md +++ b/README.md @@ -2,53 +2,42 @@ Temporary PipeWire/PulseAudio 5.1 sink helper for testing Arma Reforger surround output on Linux. -The goal is narrow: create a virtual 5.1 output device, make it the launch-time default, then let Arma Reforger decide whether to create a surround stream. Carla, QPWGraph, EQ, convolution, and long-term routing are intentionally manual follow-up steps. +It creates a virtual 5.1 output device, makes it the launch-time default, then exposes Reforger back to that device after normal system audio is restored. ## Requirements - PipeWire with PulseAudio compatibility - `pactl` -- Arma Reforger running through Steam/Proton or another Linux audio path that appears in PipeWire/Pulse +- Arma Reforger running through Steam/Proton ## Install -Run directly from the repo: +Run from the repo: ```bash ./reforger-surround --help ``` -Or place it somewhere on your `PATH`: +Or install locally: ```bash install -Dm755 reforger-surround ~/.local/bin/reforger-surround ``` -## Basic Test Workflow - -Create the 5.1 sink and make it the temporary default: +## Workflow ```bash reforger-surround up ``` -Launch Arma Reforger manually while `Reforger Surround 5.1` is the selected/default output device. - -After Arma has created its audio stream, restore your normal default device: +Launch Arma Reforger while `Reforger Surround 5.1` is the default output. ```bash reforger-surround restore -``` - -`restore` first pins the running Arma stream to the 5.1 sink, then switches normal system audio back to the previous default device. - -Check whether Arma negotiated surround: - -```bash reforger-surround check ``` -Clean up the temporary sink: +If successful, clean up later with: ```bash reforger-surround down @@ -57,53 +46,51 @@ reforger-surround down ## Commands ```bash -reforger-surround create # create the 5.1 sink without changing defaults -reforger-surround up # create the sink, save current default, make 5.1 default -reforger-surround pin # move a running Arma/Reforger stream to the 5.1 sink -reforger-surround restore # pin Reforger if running, then restore the saved previous default -reforger-surround down # restore previous default and unload the 5.1 sink -reforger-surround status # show sink/default/game stream state -reforger-surround check # report whether Arma is 2ch or 6ch +reforger-surround create # create the 5.1 sink only +reforger-surround up # create sink, save default, make 5.1 default +reforger-surround expose # move running Reforger stream to the 5.1 sink +reforger-surround pin # alias for expose +reforger-surround restore # restore previous default, then expose Reforger +reforger-surround down # restore default and unload the 5.1 sink +reforger-surround status # show current state +reforger-surround check # report whether Reforger is 2ch or 6ch ``` ## Configuration -Defaults are intentionally generic: - ```bash REFORGER_SURROUND_SINK_NAME=reforger_surround_51 REFORGER_SURROUND_DESCRIPTION="Reforger Surround 5.1" REFORGER_SURROUND_APP_NAME="Arma Reforger" ``` -Override them per command if needed: +Example override: ```bash REFORGER_SURROUND_APP_NAME="ArmaReforgerSteam.exe" reforger-surround check ``` -## Expected Results +## Expected Result -Good result: +Good: ```text Sample Specification: ... 6ch 48000Hz Channel Map: front-left,front-right,front-center,lfe,rear-left,rear-right ``` -Stereo-only result: +Bad: ```text Sample Specification: ... 2ch 48000Hz Channel Map: front-left,front-right ``` -If Arma creates a stereo-only stream, restart the game with the 5.1 sink selected/default before launch. Moving an already-created stereo stream usually does not make the game renegotiate surround. +If Reforger negotiates stereo, restart the game with the 5.1 sink selected/default before launch. ## Notes -- `up` temporarily routes normal system audio to the 5.1 sink until `restore` is run. -- `restore` does not unload the 5.1 sink; it pins Reforger if running, then gives normal system audio back to the previous default. -- If Reforger follows the default sink when the default changes, run `reforger-surround pin` before switching devices manually. -- `down` unloads the temporary sink created by this tool. -- LFE may be silent in Arma Reforger even when the stream is 6ch. +- Prefer `restore` over manually changing your default output device. +- If you change default output manually, run `reforger-surround expose` afterward. +- `restore` keeps the 5.1 sink alive; `down` unloads it. +- LFE may be silent even when Reforger is outputting 6ch. diff --git a/reforger-surround b/reforger-surround index 90e39ef..5895f81 100755 --- a/reforger-surround +++ b/reforger-surround @@ -14,6 +14,7 @@ usage() { Usage: reforger-surround create reforger-surround up + reforger-surround expose reforger-surround pin reforger-surround restore reforger-surround down @@ -23,8 +24,9 @@ Usage: Commands: create Create the temporary 5.1 sink without changing the default sink. up Create the 5.1 sink, save the current default, and make it default. - pin Move a running Reforger stream to the 5.1 sink. - restore Pin Reforger if running, then restore the saved previous default sink. + expose Create the 5.1 sink and move a running Reforger stream into it. + pin Alias for expose. + restore Restore the saved previous default sink, then expose Reforger if running. down Restore the saved previous default sink and unload the 5.1 sink. status Show default sink, virtual sink state, and detected Reforger stream. check Report whether a running Reforger stream negotiated stereo or surround. @@ -139,8 +141,10 @@ Launch Arma Reforger now. After the game has created its audio stream, run: EOF } -move_app_to_sink() { - local input_id sample_spec +expose_app() { + local input_id sample_spec sink_after + + create_sink input_id="$(find_app_sink_input_id || true)" if [[ -z "${input_id}" ]]; then @@ -148,14 +152,15 @@ move_app_to_sink() { return 1 fi - create_sink sample_spec="$(app_stream_sample_spec "${input_id}")" pactl move-sink-input "${input_id}" "${sink_name}" - printf 'Pinned %s sink-input #%s to %s\n' "${app_name}" "${input_id}" "${sink_name}" + sink_after="$(app_stream_sink_name "${input_id}" || true)" + printf 'Exposed %s sink-input #%s to %s\n' "${app_name}" "${input_id}" "${sink_name}" + printf 'Current stream sink: %s\n' "${sink_after:-unknown}" case "${sample_spec}" in *" 6ch "*) - printf 'Stream is 6ch; restoring the system default should leave Reforger on the 5.1 sink.\n' + printf 'Stream is 6ch; Reforger should now stay on the 5.1 sink.\n' ;; *" 2ch "*) printf 'Warning: stream is already stereo-only. Pinning will not make Reforger renegotiate surround.\n' >&2 @@ -171,7 +176,7 @@ pin_app_if_running() { input_id="$(find_app_sink_input_id || true)" if [[ -n "${input_id}" ]]; then - move_app_to_sink + expose_app else printf 'No %s stream found to pin; restoring only the system default.\n' "${app_name}" fi @@ -196,8 +201,8 @@ restore_default() { } restore_with_pin() { + restore_default || true pin_app_if_running - restore_default } unload_sink() { @@ -384,10 +389,15 @@ main() { require_pulse_connection up ;; + expose) + ensure_dependencies + require_pulse_connection + expose_app + ;; pin) ensure_dependencies require_pulse_connection - move_app_to_sink + expose_app ;; restore) ensure_dependencies