Skip to content

Commit

Permalink
Add writer comments and use or instead of and (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
natario1 authored Aug 11, 2024
1 parent d158cd6 commit 3dee237
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 3dee237

Please sign in to comment.