Skip to content

refactor: extract magic numbers into named constants#68

Merged
chrisuthe merged 1 commit intomainfrom
refactor/extract-audio-magic-numbers
Mar 8, 2026
Merged

refactor: extract magic numbers into named constants#68
chrisuthe merged 1 commit intomainfrom
refactor/extract-audio-magic-numbers

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • Replace hardcoded numeric literals in audio and protocol code with named constants from SendSpinProtocol
  • Add BINARY_HEADER_SIZE_BYTES, CHANNELS_MONO, and Artwork.REQUEST_SIZE to the protocol constants object
  • Add OPUS_HEAD_SIZE constant to OpusDecoder for the RFC 7845 OpusHead struct size
  • Update SyncAudioPlayer, AudioDecoderFactory, BinaryMessageParser, BinaryMessageParserExt, and MessageBuilder to reference these constants

Test plan

  • Build compiles successfully (assembleDebug)
  • Existing unit tests pass (3 pre-existing failures unrelated to this change)
  • Verify audio playback still works on device (no behavioral changes expected -- pure refactor)

Replace numeric literals in audio/protocol code with named constants
from SendSpinProtocol for clarity and maintainability:
- Binary header size (9) -> BINARY_HEADER_SIZE_BYTES
- Sample rate (48000) -> AudioFormat.SAMPLE_RATE
- Channel counts (1, 2) -> AudioFormat.CHANNELS_MONO, CHANNELS
- Bit depth (16) -> AudioFormat.BIT_DEPTH
- Artwork dimensions (500) -> Artwork.REQUEST_SIZE
- OpusHead struct size (19) -> OPUS_HEAD_SIZE
@chrisuthe chrisuthe merged commit 117e856 into main Mar 8, 2026
@chrisuthe chrisuthe deleted the refactor/extract-audio-magic-numbers branch March 8, 2026 02:40
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