ref: d64f56dd9b3ce3765ee6559aee107c0328d0ec6f
parent: 99365e9922e6516dbd63b084de996573c5f5a767
parent: eba24c59a94e7d53e118f744a18002c38ae6563a
author: Paul Brossier <piem@piem.org>
date: Wed Dec 19 10:47:31 EST 2018
Merge branch 'feature/sink_flac' into feature/autosink
--- a/src/io/sink_flac.c
+++ b/src/io/sink_flac.c
@@ -63,7 +63,7 @@
FILE *fid; // file id
FLAC__StreamEncoder* encoder;
FLAC__int32 *buffer;
- FLAC__StreamMetadata *metadata[2];
+ FLAC__StreamMetadata **metadata;
};
typedef struct _aubio_sink_flac_t aubio_sink_flac_t;
@@ -167,6 +167,12 @@
goto failure;
}
+ s->metadata = AUBIO_ARRAY(FLAC__StreamMetadata*, 2);
+ if (!s->metadata) {
+ AUBIO_ERR("sink_flac: failed allocating memory for %s\n", s->path);
+ goto failure;
+ }
+
s->metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
if (!s->metadata[0]) {
AUBIO_ERR("sink_flac: failed allocating vorbis comment %s\n", s->path);
@@ -323,8 +329,11 @@
if (s->metadata) {
// clean up metadata after stream finished
- FLAC__metadata_object_delete(s->metadata[0]);
- FLAC__metadata_object_delete(s->metadata[1]);
+ if (s->metadata[0])
+ FLAC__metadata_object_delete(s->metadata[0]);
+ if (s->metadata[1])
+ FLAC__metadata_object_delete(s->metadata[1]);
+ AUBIO_FREE(s->metadata);
}
if (s->fid && fclose(s->fid)) {