This commit is contained in:
twinaphex 2020-06-29 21:06:21 +02:00
parent 3239576ba1
commit a2f2a882cb

View File

@ -113,25 +113,19 @@ void audio_mix_free_chunk(audio_chunk_t *chunk)
audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate)
{
int sample_size;
int64_t len = 0;
void *buf = NULL;
audio_chunk_t *chunk = (audio_chunk_t*)malloc(sizeof(*chunk));
int64_t len = 0;
void *buf = NULL;
audio_chunk_t *chunk = (audio_chunk_t*)malloc(sizeof(*chunk));
if (!chunk)
return NULL;
if (!filestream_read_file(path, &buf, &len))
{
printf("Could not open WAV file for reading.\n");
goto error;
}
chunk->buf = buf;
chunk->buf = NULL;
chunk->upsample_buf = NULL;
chunk->float_buf = NULL;
chunk->float_resample_buf = NULL;
chunk->resample_buf = NULL;
chunk->len = len;
chunk->len = 0;
chunk->resample_len = 0;
chunk->rwav = (rwav_t*)malloc(sizeof(rwav_t));
chunk->sample_rate = sample_rate;
@ -147,6 +141,15 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate)
chunk->rwav->subchunk2size = 0;
chunk->rwav->samples = NULL;
if (!filestream_read_file(path, &buf, &len))
{
printf("Could not open WAV file for reading.\n");
goto error;
}
chunk->buf = buf;
chunk->len = len;
if (rwav_load(chunk->rwav, chunk->buf, chunk->len) == RWAV_ITERATE_ERROR)
{
printf("error: could not load WAV file\n");