Skip to content

Fix SamplePool::Reassign reporting a loaded print as failed - #291

Open
peterswimm wants to merge 1 commit into
djdiskmachine:masterfrom
peterswimm:fix/sample-pool-reassign
Open

peterswimm wants to merge 1 commit into
djdiskmachine:masterfrom
peterswimm:fix/sample-pool-reassign

Conversation

@peterswimm

Copy link
Copy Markdown

Description

SamplePool::Reassign checked the result of loadSample() as a bool, but loadSample() returns SLOAD_OK, which is 0, on success. So every print that loaded returned -1, and FxPrinter::Run assigned that -1 to the instrument while reporting "OK!": the instrument was left without its printed sample.

It also unloaded the old copy whenever the file was already on disk, even when that file was not in the pool, which called unload(-1). Now it unloads only a sample the pool holds.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Built from master with this change and run on the device below.

Test Configuration:

  • Hardware: Anbernic RG35XX SP
  • Test steps: print an IR on a sample instrument. Before the fix the instrument is left without a sample after "OK!"; after it, the instrument plays the printed sample.

Checklist:

  • I have performed a self-review of my code
  • I have commented particularly in hard-to-understand areas
  • I have updated CHANGELOG (left for the maintainer to place under the next build)
  • I have updated docs/wiki/What-is-LittlePiggyTracker.md reflecting my changes (no user-facing change to document)
  • I have version bumped in sources/Application/Model/Project.h (will bump if asked)
  • My changes generate no new warnings (compiled SamplePool.cpp before and after on macOS: 20 warnings both times)

An LLM (Claude) was used to help find the bug and write the patch; I read the diff and tested it myself.

Reassign treated loadSample's result as a bool, but loadSample returns
SLOAD_OK, which is 0, on success. So every print that loaded returned
-1, and FxPrinter::Run assigned that -1 to the instrument while saying
"OK!": the instrument was left without its printed sample.

It also unloaded the old copy whenever the file was already on disk,
even when that file was not in the pool, which called unload(-1). Now
it unloads only a sample the pool holds.

Assisted-by: Claude (LLM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant