FastLED 3.9.15
Loading...
Searching...
No Matches

◆ stb_vorbis_decode_memory() [1/2]

int32_t fl::third_party::vorbis::stb_vorbis_decode_memory ( const uint8 * mem,
int32_t len,
int32_t * channels,
int32_t * sample_rate,
short ** output )

Definition at line 5151 of file stb_vorbis.cpp.hpp.

5152{
5153 int32_t data_len, offset, total, limit, error;
5154 short *data;
5155 stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, nullptr);
5156 if (v == nullptr) return -1;
5157 limit = v->channels * 4096;
5158 *channels = v->channels;
5159 if (sample_rate)
5160 *sample_rate = v->sample_rate;
5161 offset = data_len = 0;
5162 total = limit;
5163 data = (short *) fl::malloc(total * sizeof(*data));
5164 if (data == nullptr) {
5166 return -2;
5167 }
5168 for (;;) {
5170 if (n == 0) break;
5171 data_len += n;
5172 offset += n * v->channels;
5173 if (offset + limit > total) {
5174 short *data2;
5175 total *= 2;
5176 data2 = (short *) fl::realloc(data, total * sizeof(*data));
5177 if (data2 == nullptr) {
5178 fl::free(data);
5180 return -2;
5181 }
5182 data = data2;
5183 }
5184 }
5185 *output = data;
5187 return data_len;
5188}
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
static int32_t error(vorb *f, enum STBVorbisError e) FL_NOEXCEPT
stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int32_t len, int32_t *error, const stb_vorbis_alloc *alloc) FL_NOEXCEPT
void stb_vorbis_close(stb_vorbis *p) FL_NOEXCEPT
int32_t stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int32_t num_c, short *buffer, int32_t num_shorts) FL_NOEXCEPT
fl::i32 int32_t
Definition coder.h:220
void * malloc(size_t size)
Definition malloc.cpp.hpp:9
void free(void *ptr)
void * realloc(void *ptr, size_t new_size)

References fl::third_party::vorbis::stb_vorbis::channels, error(), FL_NOEXCEPT, fl::free(), fl::malloc(), offset(), fl::realloc(), fl::third_party::vorbis::stb_vorbis::sample_rate, stb_vorbis_close(), stb_vorbis_get_frame_short_interleaved(), and stb_vorbis_open_memory().

+ Here is the call graph for this function: