fix(h700): prevent RG SP speaker pops during audio transitions - #46
Open
cstaavetti wants to merge 1 commit into
Open
cstaavetti wants to merge 1 commit into
cstaavetti wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #25 on the Anbernic RG SP. Game startup, game exit, and sleep/wake are silent in the tested scenarios, while normal playback and volume adjustment continue to work.
Problem
On the tested BaseOS device, the vendor kernel's
sunxi_spk_eventcallback simply returns success without controlling the speaker amplifier. Disassembly of the device's kernel confirmed this, and GPIO readback showed the amplifier still enabled when the SPK DAPM widget was off. Consequently, muting the SPK mixer control did not reliably isolate the speaker from codec transitions; game exit could pop even at volume zero.A diagnostic using the original emulator and library held the device-tree-defined amplifier enable pin, PI5, low. This silenced playback and both startup and exit pops.
Changes
DEVICE=rgspand matching device-tree pin, output function, polarity, and pin-count properties. It uses the vendor debugfs data interface and checks the resulting GPIO state.Alternative considered
Turro75's audio-server solution addresses the same transition noise by keeping ALSA open across application launches and exits. An OSS/DSP preload wrapper redirects application audio into a FIFO, and a persistent server writes it to ALSA. This is compatible with our finding: avoiding codec transitions and disabling the amplifier during those transitions are two ways to keep the transient from reaching the speaker.
The trade-offs are:
The amplifier approach was chosen because physical pin testing directly confirmed that it suppresses the pops on the affected device, and it fits NextUI's existing audio lifecycle, including close-before-suspend. It has passed the hardware checks below. The audio-server alternative has not been tested on this device during this investigation; no comparative latency, power, or audio-quality claim is made. Repairing the kernel amplifier callback remains the cleaner long-term solution.
Validation
Tested on an Anbernic RG SP running BaseOS 1.1.0, vendor kernel 4.9.170, and NextUI 6.14.0-rc9-based binaries.
.asoundrcoverride was used.git diff --checkpassed. The diagnostic harnesses and captures are local investigation artifacts and are not included in this branch.Limitations
This is a userspace workaround for the tested vendor kernel and depends on its debugfs GPIO interface. Repairing the kernel speaker-event callback would provide a cleaner long-term solution.
Hardware validation covers one RG SP and one game/core. Headphones, Bluetooth, HDMI, USB DACs, and other H700 models have not been tested. Although direct PI5 control is restricted to the verified RG SP configuration, the branch also changes shared H700 mute and mixer behavior.
The settings library, emulator, frontend, and volume daemon were built using the project makefiles and upstream GCC 8.3 image
ghcr.io/loveretro/h700-toolchain@sha256:47148fa93d6c3196956aef4f418cb5a2d4f373ce0881e7e8d92c51ac5ef60afc, with the project’s optimization and LTO settings. All four resulting binaries were installed for the hardware test. Existing device runtime libraries and the tested dependency source revisions were retained.