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

◆ stb_vorbis_decode_filename()

int32_t fl::third_party::vorbis::stb_vorbis_decode_filename ( const char * filename,
int32_t * channels,
int32_t * sample_rate,
short ** output )

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

5112{
5113 int32_t data_len, offset, total, limit, error;
5114 short *data;
5115 stb_vorbis *v = stb_vorbis_open_filename(filename, &error, nullptr);
5116 if (v == nullptr) return -1;
5117 limit = v->channels * 4096;
5118 *channels = v->channels;
5119 if (sample_rate)
5120 *sample_rate = v->sample_rate;
5121 offset = data_len = 0;
5122 total = limit;
5123 data = (short *) fl::malloc(total * sizeof(*data));
5124 if (data == nullptr) {
5126 return -2;
5127 }
5128 for (;;) {
5130 if (n == 0) break;
5131 data_len += n;
5132 offset += n * v->channels;
5133 if (offset + limit > total) {
5134 short *data2;
5135 total *= 2;
5136 data2 = (short *) fl::realloc(data, total * sizeof(*data));
5137 if (data2 == nullptr) {
5138 fl::free(data);
5140 return -2;
5141 }
5142 data = data2;
5143 }
5144 }
5145 *output = data;
5147 return data_len;
5148}
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_filename(const char *filename, int32_t *error, const stb_vorbis_alloc *alloc)
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::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_filename().

+ Here is the call graph for this function: