Skip to content

Commit 3dee237

Browse files
authored
Add writer comments and use or instead of and (#201)
1 parent d158cd6 commit 3dee237

File tree

1 file changed

+6
-1
lines changed
  • lib/src/main/java/com/otaliastudios/transcoder/internal/data

1 file changed

+6
-1
lines changed

lib/src/main/java/com/otaliastudios/transcoder/internal/data/Writer.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ internal class Writer(
3838

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

0 commit comments

Comments
 (0)