Skip to content

Commit

Permalink
Fix writers for MJPEG and ASCII
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 17, 2024
1 parent f432e72 commit d428a89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions pkg/ascii/ascii.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ func (a *writer) Write(p []byte) (n int, err error) {

a.buf = append(a.buf, "\033[0m"...)

if n, err = a.wr.Write(a.buf); err == nil {
a.wr.(http.Flusher).Flush()
if _, err = a.wr.Write(a.buf); err != nil {
return 0, err
}

return
a.wr.(http.Flusher).Flush()

return len(p), nil
}

func gray(r, g, b uint32, k float32) uint8 {
Expand Down
8 changes: 5 additions & 3 deletions pkg/mjpeg/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ func (w *writer) Write(p []byte) (n int, err error) {

// Chrome bug: mjpeg image always shows the second to last image
// https://bugs.chromium.org/p/chromium/issues/detail?id=527446
if n, err = w.wr.Write(w.buf); err == nil {
w.wr.(http.Flusher).Flush()
if _, err = w.wr.Write(w.buf); err != nil {
return 0, err
}

return
w.wr.(http.Flusher).Flush()

return len(p), nil
}

0 comments on commit d428a89

Please sign in to comment.