Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes getting: assert on ope_encoder_drain() with enc->streams == NULL in , file src/opusenc.c, line 839. #24

Open
alexupotsdam opened this issue Jan 11, 2021 · 1 comment

Comments

@alexupotsdam
Copy link

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?

@mark4o
Copy link
Contributor

mark4o commented Jan 11, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants