Repository navigation
system/nxplayer: Add WAV file playback support. - #3840
imeghar2408-max wants to merge 2 commits into
Conversation
|
I've pushed the refactor in commit WAV playback now uses Validation completed:
Could you please take another look? |
665cd07 to
243b4a4
Compare
|
Hi @xiaoxiang781216 , thanks for the feedback! I've updated the implementation by moving the WAV-specific RIFF/WAVE parsing, format validation, and PCM buffer-filling logic into a dedicated The existing MP3/SBC decoder paths and raw PCM playback path have been kept separate from the WAV-specific changes. I've also rebuilt and tested the SIM ALSA configuration, including valid WAV playback with odd-sized chunks, raw PCM playback, malformed WAV rejection, and mid-playback truncation handling. Please have another look when you get a chance. Thanks! |
bb8605f to
7a2c7e3
Compare
| CODE int (*pre_parse)(int fd, FAR uint32_t *samplerate, | ||
| FAR uint8_t *chans, FAR uint8_t *bps); | ||
| CODE int (*fill_data)(int fd, FAR struct ap_buffer_s *apb); | ||
| CODE int (*pre_parse)(FAR struct nxplayer_s *pplayer, int fd, |
There was a problem hiding this comment.
why need change the prototype? if the change is really needed, please split the common change to the separated patch, and wave decoder in one and only one patch.
There was a problem hiding this comment.
The prototype change is needed to pass the player context to decoder callbacks and allow pre_parse to return the selected subformat. The WAV decoder needs this to maintain per-player parsing state and select the appropriate PCM subformat.
I'll separate the generic callback-interface change into its own commit, using adapters to preserve the existing MP3/SBC and common PCM behavior. All WAV-specific decoding and integration will be contained in one separate commit.
thanks!
There was a problem hiding this comment.
please remove the adapter and modify the mp3/sbc directly
There was a problem hiding this comment.
I removed the adapters and modified the MP3/SBC callbacks directly to use the shared decoder interface.
I've also split the changes into two commits.. waiting for your review:)
Refactor the decoder callback interface shared by NXPlayer. Update the common, MP3, and SBC implementations to use the common interface, preparing the player for additional decoder formats. Tested: - NuttX SIM build: make -j12 Assisted-by: Copilot Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
Add RIFF/WAV parsing and PCM buffer filling through decoder callbacks. Validate WAV format and data chunks, maintain per-player playback state, and clean up resources. Integrate the WAV decoder into the build while preserving raw PCM playback behavior. Tested: - NuttX SIM build: make -j12 - checkpatch.sh: C style checks passed; cmake-format unavailable. Assisted-by: Copilot Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
7a2c7e3 to
ad73730
Compare
Parse RIFF/WAVE headers and play supported PCM 16-bit mono and stereo WAV files through the existing audio playback path.
Validate chunk boundaries, format parameters, and data length before playback. Preserve the existing raw PCM playback path and report read errors during WAV playback cleanup.
Assisted-by: OpenAI:GPT-6
Summary
Add WAV file playback support to
system/nxplayer.The implementation parses RIFF/WAVE headers and supports 16-bit PCM mono and stereo WAV files. It validates chunk boundaries, format parameters, and data length before playback.
Changes
Impact
This change adds WAV playback support to
nxplayerwhile preserving existing raw PCM playback throughplayraw. Invalid or unsupported WAV files are rejected.Validation
SIM ALSA Build
Command:
Result: Build completed successfully, including linking
nuttx.WAV Playback
Tested a valid WAV file:
Result: Audio playback was audible.
Tested a WAV file containing an odd-sized
JUNKchunk.Result: Audio playback was audible.
Malformed WAV Files
Tested a truncated WAV header and an invalid RIFF length.
Observed output for the truncated header:
Result: Malformed WAV files were rejected.
Raw PCM Playback
Command:
Result: Audio playback was audible.
Read Error During WAV Playback
Truncated the WAV file while playback was in progress.
Observed output:
After entering
q, the application returned to the NSH prompt.Checkpatch
Command:
~/nuttx-work/nuttx-sim-alsa/tools/checkpatch.sh -g HEADOutput: