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

Fix EOS flag not sent #201

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ internal class Writer(

override fun step(state: State.Ok<WriterData>, fresh: Boolean): State<Unit> {
val (buffer, timestamp, flags) = state.value
// Note: flags does NOT include BUFFER_FLAG_END_OF_STREAM. That's passed via State.Eos.
val eos = state is State.Eos
if (eos) {
info.set(0, 0, 0, flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM)
// Note: it may happen that at this point, buffer has some data. but creating an extra writeTrack() call
// can cause some crashes that were not properly debugged, probably related to wrong timestamp.
// I think if we could ensure that timestamp is valid (> previous, > 0) and buffer.hasRemaining(), there should
// be an extra call here. See #159. Reluctant to do so without a repro test.
info.set(0, 0, 0, flags or MediaCodec.BUFFER_FLAG_END_OF_STREAM)
} else {
info.set(
buffer.position(),
Expand Down