Skip to content

Commit

Permalink
stb_vorbis: sync with stb_vorbis SDL fork
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Dec 13, 2023
1 parent fbdce6b commit 97b02bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/codecs/music_ogg_stb.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define STB_VORBIS_BIG_ENDIAN 1
#endif
#define STBV_CDECL SDLCALL /* for SDL_qsort */
#define STBV_CDECL SDLCALL /* for SDL_qsort() */

#ifdef assert
#undef assert
Expand Down
19 changes: 18 additions & 1 deletion src/codecs/stb_vorbis/stb_vorbis.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ typedef struct
// get general information about the file
extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);

#ifndef STB_VORBIS_NO_COMMENTS
// get ogg comments
extern stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f);
#endif

// get the last error detected (clears it, too)
extern int stb_vorbis_get_error(stb_vorbis *f);
Expand Down Expand Up @@ -557,6 +559,12 @@ enum STBVorbisError
// you'd ever want to do it except for debugging.
// #define STB_VORBIS_NO_DEFER_FLOOR

// STB_VORBIS_NO_COMMENTS
// Disables reading and storing user comments.
// #define STB_VORBIS_NO_COMMENTS




//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -771,7 +779,6 @@ typedef struct

typedef struct
{
// https://github.com/nothings/stb/pull/1312
MappingChannel *chan;
uint16 coupling_steps;
uint8 submaps;
Expand Down Expand Up @@ -812,9 +819,11 @@ struct stb_vorbis
unsigned int temp_memory_required;
unsigned int setup_temp_memory_required;

#ifndef STB_VORBIS_NO_COMMENTS
char *vendor;
int comment_list_length;
char **comment_list;
#endif

// input config
#ifndef STB_VORBIS_NO_STDIO
Expand Down Expand Up @@ -1668,6 +1677,7 @@ static int get8_packet(vorb *f)
return x;
}

#ifndef STB_VORBIS_NO_COMMENTS
static int get32_packet(vorb *f)
{
uint32 x;
Expand All @@ -1677,6 +1687,7 @@ static int get32_packet(vorb *f)
x += (uint32) get8_packet(f) << 24;
return x;
}
#endif

static void flush_packet(vorb *f)
{
Expand Down Expand Up @@ -3736,6 +3747,7 @@ static int start_decoder(vorb *f)

if (!start_packet(f)) return FALSE;

#ifndef STB_VORBIS_NO_COMMENTS
if (!next_segment(f)) return FALSE;

if (get8_packet(f) != VORBIS_packet_comment) return error(f, VORBIS_invalid_setup);
Expand Down Expand Up @@ -3784,6 +3796,7 @@ static int start_decoder(vorb *f)

skip(f, f->bytes_in_seg);
f->bytes_in_seg = 0;
#endif // STB_VORBIS_NO_COMMENTS

do {
len = next_segment(f);
Expand Down Expand Up @@ -4330,11 +4343,13 @@ static void vorbis_deinit(stb_vorbis *p)
{
int i,j;

#ifndef STB_VORBIS_NO_COMMENTS
setup_free(p, p->vendor);
for (i=0; i < p->comment_list_length; ++i) {
setup_free(p, p->comment_list[i]);
}
setup_free(p, p->comment_list);
#endif

if (p->residue_config) {
for (i=0; i < p->residue_count; ++i) {
Expand Down Expand Up @@ -4458,6 +4473,7 @@ stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
return d;
}

#ifndef STB_VORBIS_NO_COMMENTS
stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f)
{
stb_vorbis_comment d;
Expand All @@ -4466,6 +4482,7 @@ stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f)
d.comment_list = f->comment_list;
return d;
}
#endif

int stb_vorbis_get_error(stb_vorbis *f)
{
Expand Down

0 comments on commit 97b02bb

Please sign in to comment.