Sometimes getting: assert on ope_encoder_drain() with enc->streams == NULL in , file src/opusenc.c, line 839.
Not very often, but maybe 1 in 50 times, I get a crash with the above-mentioned log.
assert(enc->buffer_end <= BUFFER_SAMPLES);
encode_buffer(enc);
if (enc->unrecoverable) return enc->unrecoverable;
/* Draining should have called all the streams to complete. */
assert(enc->streams == NULL); /* <-- the line where the crash happens */
return OPE_OK;
}
Of course I'd much rather have this NOT crashing. What can I do in order to prevent this from happening? Can there be a "bad moment" to call the drain() such as immediately after starting to encode (which is how I was able to reproduce the bug if it wasn't a coincidence). Should I check for anything else before draining so I don't run into the assert?
Sorry for the dumb question but is C thread safe in this regard or could calling drain() and a simultaneous ope_encoder_write[/_float] cause this?
It is possible for this assertion to fail when the stream is drained without adding any audio. This should fix that issue: https://gitlab.xiph.org/xiph/libopusenc/-/merge_requests/4 Are you seeing the assertion failure in other cases?
ope_encoder_drain() should be called only after all audio has been written. It is not valid to call ope_encoder_write() or ope_encoder_write_float() after or simultaneously with ope_encoder_drain() on the same stream.