ref: 00053b2a3f6db71f330a4795419c27d9e999e87b
parent: 93dd7c4319367ab8f8cbc6452131ed8e287193f8
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Fri May 5 17:04:55 EDT 2017
Properly cleanup even when ope_drain() isn't called
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,5 @@
Copyright (c) 1994-2013 Xiph.Org Foundation and contributors
+Copyright (c) 2017 Jean-Marc Valin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -596,6 +596,8 @@
}
int ope_drain(OggOpusEnc *enc) {
+ /* Check if it's already been drained. */
+ if (enc->streams == NULL) return OPE_TOO_LATE;
/* FIXME: Use a better value. */
int pad_samples = 3000;
if (!enc->streams->stream_is_init) init_stream(enc);
@@ -611,7 +613,14 @@
}
void ope_destroy(OggOpusEnc *enc) {
- /* FIXME: cleanup non-closed streams if any remain. */
+ EncStream *stream;
+ stream = enc->streams;
+ while (stream != NULL) {
+ EncStream *tmp = stream;
+ stream = stream->next;
+ if (tmp->close_at_end) enc->callbacks.close(tmp->user_data);
+ stream_destroy(tmp);
+ }
if (enc->chaining_keyframe) free(enc->chaining_keyframe);
free(enc->buffer);
#ifdef USE_OGGP