#include "timidity.h"
#include "common.h"
#include "controls.h"
+#include "instrum.h"
#include "decode.h"
#ifdef HAVE_LIBVORBIS
extern int load_vorbisfile_dll(void); // w32g_vorbisfile_dll.c
#endif
+static sample_t DummySampleData[128];
+
static size_t oggvorbis_read_callback(void *ptr, size_t size, size_t nmemb, void *datasource)
{
struct timidity_file *tf = (struct timidity_file *)datasource;
SampleDecodeResult decode_oggvorbis(struct timidity_file *tf)
{
- SampleDecodeResult sdr = {0};
+ SampleDecodeResult sdr = {.data = DummySampleData, .data_type = SAMPLE_TYPE_INT16};
OggVorbis_File vf;
if (load_vorbis_dll() != 0) {
data_length = (data_length > 0 ? data_length : 4096);
ptr_size_t current_size = 0;
sdr.data = (sample_t *)safe_large_malloc(data_length);
+ sdr.data_alloced = 1;
while (1) {
int bitstream = 0;
cleanup:
ov_clear(&vf);
- if (sdr.data) {
+ if (sdr.data_alloced) {
safe_free(sdr.data);
- sdr.data = NULL;
}
+ sdr.data = DummySampleData;
+ sdr.data_alloced = 0;
+
return sdr;
}
SampleDecodeResult decode_oggvorbis(struct timidity_file *tf)
{
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "ogg vorbis decoder support is disabled");
- return (SampleDecodeResult){.data = NULL, .data_type = 0};
+ return (SampleDecodeResult){.data = DummySampleData, .data_type = SAMPLE_TYPE_INT16};
}
#endif // HAVE_LIBVORBIS
SampleDecodeResult sdr = decode_oggvorbis(ctf);
close_file(ctf);
sample->data = sdr.data;
- sample->data_alloced = 1;
- sample->data_type = SAMPLE_TYPE_INT16;
+ sample->data_alloced = sdr.data_alloced;
+ sample->data_type = sdr.data_type;
sample->data_length = sdr.data_length;
if (!(sample->modes & MODES_LOOPING)) {