Skip to content

Commit

Permalink
Fix Failed to stop the muxer (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperson authored Aug 11, 2024
1 parent 07ecaed commit d158cd6
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ internal class Writer(
override fun step(state: State.Ok<WriterData>, fresh: Boolean): State<Unit> {
val (buffer, timestamp, flags) = state.value
val eos = state is State.Eos
info.set(
buffer.position(),
buffer.remaining(),
timestamp,
if (eos) {
flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM
} else flags
)
if (eos) {
info.set(0, 0, 0, flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM)
} else {
info.set(
buffer.position(),
buffer.remaining(),
timestamp,
flags
)
}
sink.writeTrack(track, buffer, info)
state.value.release()
return if (eos) State.Eos(Unit) else State.Ok(Unit)
Expand Down

0 comments on commit d158cd6

Please sign in to comment.