esp32-audio-player 0.1.0
Audio player engine for ESP32
Loading...
Searching...
No Matches
decoder.h File Reference

Audio decoders behind one interface. More...

Include dependency graph for decoder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  decoder_info_t
 
struct  decoder_backend_t
 Backend interface (for implementers of src/decoders/*.c). More...
 

Typedefs

typedef struct decoder decoder_t
 

Enumerations

enum  codec_id_t {
  CODEC_UNKNOWN = 0 , CODEC_WAV , CODEC_AIFF , CODEC_FLAC ,
  CODEC_MP3 , CODEC_VORBIS , CODEC_OPUS , CODEC_AAC ,
  CODEC_ALAC , CODEC_WAVPACK , CODEC_APE , CODEC_DSF ,
  CODEC_DFF , CODEC_COUNT
}
 

Functions

const char * codec_name (codec_id_t id)
 "FLAC", "MP3", ...
 
bool codec_is_lossless (codec_id_t id)
 
codec_id_t codec_from_extension (const char *ext)
 Extension -> codec guess ("flac" -> CODEC_FLAC). Case-insensitive, no dot.
 
bool codec_is_audio_extension (const char *ext)
 True if the file extension is one we list in the browser (supported or planned).
 
codec_id_t decoder_probe (core_stream_t *s, const char *path_hint)
 Probe the stream (position is restored). path_hint may be NULL.
 
decoder_t * decoder_open (core_stream_t *s, const char *path_hint, decoder_info_t *info, int *err)
 Open a decoder.
 
int32_t decoder_read (decoder_t *d, int32_t *out, uint32_t max_frames)
 Decode up to max_frames frames into out (interleaved Q31, info.fmt.channels).
 
int decoder_seek (decoder_t *d, uint64_t frame)
 Seek to an absolute frame (after trimming). Returns CORE_OK or error.
 
uint64_t decoder_tell (decoder_t *d)
 current frame
 
const decoder_info_t * decoder_info (const decoder_t *d)
 
void decoder_close (decoder_t *d)
 

Detailed Description

Audio decoders behind one interface.

Probe by magic bytes first, extension second.

Backends (v0.1): WAV/RF64/W64? (WAV + RF64), AIFF/AIFC(none/sowt), FLAC (dr_flac), MP3 (minimp3, with Xing/LAME/Info gapless trimming), Ogg Vorbis (stb_vorbis), DSF -> DoP64. Later: Opus, ALAC/M4A, AAC (esp_audio_codec on device), WavPack, APE.

Typedef Documentation

◆ decoder_t

typedef struct decoder decoder_t

Enumeration Type Documentation

◆ codec_id_t

enum codec_id_t
Enumerator
CODEC_UNKNOWN 
CODEC_WAV 
CODEC_AIFF 
CODEC_FLAC 
CODEC_MP3 
CODEC_VORBIS 
CODEC_OPUS 
CODEC_AAC 
CODEC_ALAC 
CODEC_WAVPACK 
CODEC_APE 
CODEC_DSF 
CODEC_DFF 
CODEC_COUNT 

Function Documentation

◆ codec_from_extension()

codec_id_t codec_from_extension ( const char *  ext)

Extension -> codec guess ("flac" -> CODEC_FLAC). Case-insensitive, no dot.

◆ codec_is_audio_extension()

bool codec_is_audio_extension ( const char *  ext)

True if the file extension is one we list in the browser (supported or planned).

◆ codec_is_lossless()

bool codec_is_lossless ( codec_id_t  id)

◆ codec_name()

const char * codec_name ( codec_id_t  id)

"FLAC", "MP3", ...

◆ decoder_close()

void decoder_close ( decoder_t *  d)

◆ decoder_info()

const decoder_info_t * decoder_info ( const decoder_t *  d)

◆ decoder_open()

decoder_t * decoder_open ( core_stream_t *  s,
const char *  path_hint,
decoder_info_t *  info,
int *  err 
)

Open a decoder.

Takes ownership of the stream in all cases (closes it on failure). Returns NULL on failure; *err (optional) receives the reason.

◆ decoder_probe()

codec_id_t decoder_probe ( core_stream_t *  s,
const char *  path_hint 
)

Probe the stream (position is restored). path_hint may be NULL.

◆ decoder_read()

int32_t decoder_read ( decoder_t *  d,
int32_t *  out,
uint32_t  max_frames 
)

Decode up to max_frames frames into out (interleaved Q31, info.fmt.channels).

Returns frames written (>0), 0 at end of stream, or a negative core_err_t. Gapless trimming (encoder delay/padding) is applied here.

◆ decoder_seek()

int decoder_seek ( decoder_t *  d,
uint64_t  frame 
)

Seek to an absolute frame (after trimming). Returns CORE_OK or error.

◆ decoder_tell()

uint64_t decoder_tell ( decoder_t *  d)

current frame