Skip to content

Commit

Permalink
Rebase and update stb_vorbis.h to SDL_sound's version :
Browse files Browse the repository at this point in the history
- Keeps the original stb_vorbis as intact as possible so
  that future updates from mainstream would be painless.
- Reduces STB_VORBIS_MAX_CHANNELS from 16 to 6 (objections?)
- Adds several missing libm function overrides,
- SDL_mixer now requires SDL >= 2.0.9 because of SDL_exp()
- Fixes slow loads and leaks in start_decoder:
  nothings/stb#1174
- Fixes submap array out-of-bounds indexing bug:
  nothings/stb#1312
- Replace signed overflow clamps with unsigned overflow:
  nothings/stb#1168
- Replaces alloca() usage with setup_malloc() (from libxmp.)
- Fixes '-Wmaybe-uninitialized' warnings in get_seek_page_info:
  nothings/stb#1172
- A minor UBSan fix and suppression:
  nothings/stb#1168
- Fixes signature of dummy realloc() for STB_VORBIS_NO_CRT:
  nothings/stb#1198
- Renames BUFFER_SIZE macro to STB_BUFFER_SIZE:
  nothings/stb#1078
- Pulls in sample-accurate offset patch of Vitaly Novichkov:
  (stb_vorbis_get_playback_sample_offset, because it's used
  in OGG_Tell and OGG_GetSome):
  nothings/stb#1294
  nothings/stb#1295
- Fixes a few warnings here and there in some environments.
- Replaces two dummy '(void) 0' with 'do {} while(0)'
  • Loading branch information
sezero committed May 21, 2022
1 parent c23adaa commit 8130c51
Show file tree
Hide file tree
Showing 4 changed files with 1,526 additions and 1,430 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -15308,7 +15308,7 @@ find_lib()
done
}

SDL_VERSION=2.0.7
SDL_VERSION=2.0.9

# Check whether --with-sdl-prefix was given.
if test "${with_sdl_prefix+set}" = set; then :
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ find_lib()
}

dnl Check for SDL
SDL_VERSION=2.0.7
SDL_VERSION=2.0.9
AM_PATH_SDL2($SDL_VERSION,
:,
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
Expand Down
42 changes: 39 additions & 3 deletions src/codecs/music_ogg_stb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,46 @@

#include "music_ogg.h"
#include "utils.h"
#include "SDL_assert.h"

#define STB_VORBIS_SDL 1 /* for SDL_mixer-specific stuff. */
#define STB_VORBIS_NO_STDIO 1
#define STB_VORBIS_NO_CRT 1
#define STB_VORBIS_NO_PUSHDATA_API 1
#define STB_VORBIS_MAX_CHANNELS 6
#define STBV_CDECL
#define STB_FORCEINLINE SDL_FORCE_INLINE
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define STB_VORBIS_BIG_ENDIAN 1
#endif

#ifdef assert
#undef assert
#endif
#ifdef memset
#undef memset
#endif
#ifdef memcpy
#undef memcpy
#endif
#define assert SDL_assert
#define memset SDL_memset
#define memcmp SDL_memcmp
#define memcpy SDL_memcpy
#define qsort SDL_qsort
#define malloc SDL_malloc
#define realloc SDL_realloc
#define free SDL_free

#define pow SDL_pow
#define floor SDL_floor
#define ldexp(v, e) SDL_scalbn((v), (e))
#define abs(x) SDL_abs(x)
#define cos(x) SDL_cos(x)
#define sin(x) SDL_sin(x)
#define log(x) SDL_log(x)
#define exp(x) SDL_exp(x)

#define OV_EXCLUDE_STATIC_CALLBACKS
#define STB_VORBIS_NO_STDIO
#define STB_VORBIS_NO_CRT
#include "stb_vorbis/stb_vorbis.h"

typedef struct {
Expand Down
Loading

0 comments on commit 8130c51

Please sign in to comment.