Unverified Commit ac6b2112 authored by miv's avatar miv Committed by Jean-Marc Valin
Browse files

Fix pull_api mode



ope_encoder_create_pull calls ope_encoder_create_callbacks with a
NULL callbacks argument, which causes the function to crash. Test
for NULL to prevent this.

As well, we try and call the close callback when flushing the stream,
which also leads to a crash when the callbacks are not set. Don't call
the callback in pull mode.
Signed-off-by: Jean-Marc Valin's avatarJean-Marc Valin <jmvalin@jmvalin.ca>
parent 17f9d3da
......@@ -344,7 +344,10 @@ OggOpusEnc *ope_encoder_create_callbacks(const OpusEncCallbacks *callbacks, void
}
enc->buffer_start = enc->buffer_end = 0;
enc->st = st;
enc->callbacks = *callbacks;
if (callbacks != NULL)
{
enc->callbacks = *callbacks;
}
enc->streams->user_data = user_data;
if (error) *error = OPE_OK;
return enc;
......@@ -473,7 +476,7 @@ static void encode_buffer(OggOpusEnc *enc) {
if (e_o_s) {
EncStream *tmp;
tmp = enc->streams->next;
if (enc->streams->close_at_end) enc->callbacks.close(enc->streams->user_data);
if (enc->streams->close_at_end && !enc->pull_api) enc->callbacks.close(enc->streams->user_data);
stream_destroy(enc->streams);
enc->streams = tmp;
if (!tmp) enc->last_stream = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment