Skip to content

Refactor PCM format handling to use Util methods#3063

Merged
copybara-service[bot] merged 2 commits intoandroidx:mainfrom
nift4:pcmftidyup
Feb 25, 2026
Merged

Refactor PCM format handling to use Util methods#3063
copybara-service[bot] merged 2 commits intoandroidx:mainfrom
nift4:pcmftidyup

Conversation

@nift4
Copy link
Contributor

@nift4 nift4 commented Feb 10, 2026

Tidy up PCM format handling by refactoring a few usages that manually handle all PCM formats to use the Util methods that already exist.

This also adds missing string representations for existing formats (C.ENCODING_PCM_DOUBLE and C.ENCODING_DSD) to EventLogger to complete format coverage.

This is a pure refactoring change and does not alter existing playback behavior.

@rohitjoins
Copy link
Contributor

rohitjoins commented Feb 24, 2026

Hi @nift4,

Thank you for raising this PR! On a closer look, it seems that this PR is actually doing quite a few different things at once. The current commit summary "Tidy up pcm format handling in some places" doesn't quite do justice to changes you've included here. To make this clean and easy to review, could I ask you to please split this up into smaller, separate PRs that handle one logical change at a time (not necessarily in this order)?

  • A pure refactoring PR to switch to the Util methods.
  • A feature PR adding the C.ENCODING_PCM_DOUBLE support, extraction logic, and the ToFloatPcmAudioProcessor format additions.
  • A bug fix PR for the 20-bit ALAC issue.

This will make it much easier for us to safely review and merge each independent change. Thank you! Also, please feel free to assign these PRs directly to me.

@nift4
Copy link
Contributor Author

nift4 commented Feb 24, 2026

Hi @rohitjoins,

thanks for the quick response. It was done this way because the individual parts are quite small and conflict with each other, but I understand it's harder to review this way. I split it up into three parts as you said: The refactor is included in this PR, the bug fix for 20-bit files is #3089 and the feature one is #3090.

}
} else if (bitsPerSample == 32) {
pcmEncoding = Util.getPcmEncoding(bitsPerSample, isBigEndian ? BIG_ENDIAN : LITTLE_ENDIAN);
} else if (!isBigEndian && bitsPerSample == 32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addition of !isBigEndian looks more like a change in logic than pure refactor, was it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad I forgot to split that. It's a bug fix because ENCODING_PCM_FLOAT refers to little endian only and big endian would cause static noise playback. Should we merge this here or in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying! Since it changes behavior, it would ideally be in its own PR. But if creating another one is a pain, no worries at all, I can take care of splitting this change internally on our end. Let me know!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'll be away from my computer for a few days, it'd probably be best if you split this change internally instead. Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug fix was merged as cd19799.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks

- refactor a few usages that manually handle all pcm formats to the
  Util methods that already exist.
@rohitjoins rohitjoins changed the title Tidy up pcm format handling in some places Refactor PCM format handling to use Util methods Feb 25, 2026
copybara-service bot pushed a commit that referenced this pull request Feb 25, 2026
This change adds an explicit endianness check (`!isBigEndian`) when parsing the audio sample entry in `BoxParser.java` to prevent mapping big-endian 32-bit float audio to a little-endian encoding, avoiding static noise during playback.

Issue: #3063
PiperOrigin-RevId: 875133592
@copybara-service copybara-service bot merged commit 42042a1 into androidx:main Feb 25, 2026
1 check passed
@nift4 nift4 deleted the pcmftidyup branch February 25, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants