Skip to content

Commit b3acb50

Browse files
system/nxplayer: Parse WAV headers and retain PCM fallback.
Parse RIFF/WAVE headers to obtain the sample rate, channel count, and sample format for PCM S16_LE playback. Keep the whole-file PCM decoder path for devices that parse WAV headers themselves. When WAV parsing fails, rewind seekable input and fall back to the PCM decoder when the input can be safely replayed. Let AUDIOIOC_CONFIGURE report unsupported sample rates instead of interpreting driver-specific capability masks. Assisted-by: ChatGPT:GPT-6 Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
1 parent e40423e commit b3acb50

6 files changed

Lines changed: 828 additions & 33 deletions

File tree

‎include/system/nxplayer.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <mqueue.h>
3333
#include <pthread.h>
34+
#include <stdbool.h>
3435

3536
/****************************************************************************
3637
* Pre-processor Definitions
@@ -97,6 +98,14 @@ struct nxplayer_s
9798

9899
FAR const struct nxplayer_dec_ops_s *ops;
99100
struct nxplayer_tone_s tone;
101+
uint32_t wav_data_remaining;
102+
uint64_t wav_file_remaining;
103+
uint64_t wav_header_size;
104+
uint8_t wav_block_align;
105+
int wav_error;
106+
bool wav_playback;
107+
bool wav_passthrough;
108+
bool wav_fallback_ready;
100109
};
101110

102111
typedef int (*nxplayer_func)(FAR struct nxplayer_s *pplayer, char *pargs);
@@ -599,6 +608,14 @@ int nxplayer_fill_mp3(int fd, FAR struct ap_buffer_s *apb);
599608
int nxplayer_fill_common(FAR struct nxplayer_s *pplayer, int fd,
600609
FAR struct ap_buffer_s *apb);
601610

611+
#if defined(CONFIG_AUDIO_FORMAT_PCM) && \
612+
defined(CONFIG_NXPLAYER_FMT_FROM_EXT)
613+
extern const struct nxplayer_dec_ops_s g_wav_dec_ops;
614+
615+
bool nxplayer_is_wav_file(FAR const char *pfilename);
616+
uint32_t nxplayer_wav_rate_cap(uint32_t rate);
617+
#endif
618+
602619
#ifdef __cplusplus
603620
}
604621
#endif

‎system/nxplayer/CMakeLists.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ if(CONFIG_SYSTEM_NXPLAYER)
3030
target_sources(apps PRIVATE nxplayer.c)
3131

3232
set(CSRCS nxplayer.c nxplayer_common.c nxplayer_mp3.c nxplayer_sbc.c)
33+
if(CONFIG_AUDIO_FORMAT_PCM AND CONFIG_NXPLAYER_FMT_FROM_EXT)
34+
list(APPEND CSRCS nxplayer_wav.c)
35+
endif()
3336

3437
target_sources(apps PRIVATE ${CSRCS})
3538
endif()

‎system/nxplayer/Makefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ CSRCS += nxplayer_common.c
2929
CSRCS += nxplayer_mp3.c
3030
CSRCS += nxplayer_sbc.c
3131

32+
ifneq ($(CONFIG_AUDIO_FORMAT_PCM),)
33+
ifneq ($(CONFIG_NXPLAYER_FMT_FROM_EXT),)
34+
CSRCS += nxplayer_wav.c
35+
endif
36+
endif
37+
3238
ifneq ($(CONFIG_NXPLAYER_COMMAND_LINE),)
3339
PROGNAME = nxplayer
3440
PRIORITY = SCHED_PRIORITY_DEFAULT

0 commit comments

Comments
 (0)