Skip to content

Commit

Permalink
rewrite streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Jul 25, 2024
1 parent 40d02dd commit 0cc9b8f
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 295 deletions.
21 changes: 14 additions & 7 deletions src/codecs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,29 @@ function TranscodingStreams.process(
output :: TranscodingStreams.Memory,
error_ref :: TranscodingStreams.Error,
)
all_in = iszero(input.size)
# @show "proccall" input.size output.size
# done, in2, out2 = main_run!(all_in, input, output, codec.s)
done, in2, out2 = try
main_run!(all_in, input, output, codec.s)
status, Δin, Δout = try
main_run!(input, output, codec.s)
catch e
# rethrow()
e isa InterruptException && rethrow()
error_ref[] = e
return 0, 0, :error
end
Δin::Int = input.size - in2.size
Δout::Int = output.size - out2.size
if done
if status === :done
# done
return Δin, Δout, :end
else
elseif status === :input
# need more input
if iszero(input.size)
error_ref[] = ErrorException("not enough input")
return Δin, Δout, :error
else
return Δin, Δout, :ok
end
elseif status === :output
# need more output space
return Δin, Δout, :ok
end
end
Loading

0 comments on commit 0cc9b8f

Please sign in to comment.