From e499463c125724fb033c4674a554d988980591e5 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 13 Dec 2023 08:00:28 +0300
Subject: [PATCH] stb_vorbis: sync with stb_vorbis SDL fork
---
src/codecs/music_ogg_stb.c | 2 +-
src/codecs/stb_vorbis/stb_vorbis.h | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/codecs/music_ogg_stb.c b/src/codecs/music_ogg_stb.c
index 02441c6c..756b86f3 100644
--- a/src/codecs/music_ogg_stb.c
+++ b/src/codecs/music_ogg_stb.c
@@ -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
diff --git a/src/codecs/stb_vorbis/stb_vorbis.h b/src/codecs/stb_vorbis/stb_vorbis.h
index d767cc37..8686bdf8 100644
--- a/src/codecs/stb_vorbis/stb_vorbis.h
+++ b/src/codecs/stb_vorbis/stb_vorbis.h
@@ -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);
@@ -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
+
+
+
//////////////////////////////////////////////////////////////////////////////
@@ -771,7 +779,6 @@ typedef struct
typedef struct
{
- // https://github.com/nothings/stb/pull/1312
MappingChannel *chan;
uint16 coupling_steps;
uint8 submaps;
@@ -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
@@ -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;
@@ -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)
{
@@ -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);
@@ -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);
@@ -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) {
@@ -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;
@@ -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)
{