mirror of https://bitbucket.org/ausocean/av.git
codec/mjpeg/lex.go: return error if io.EOF is encountered
This commit is contained in:
parent
a26777b697
commit
e45f51a31f
|
@ -63,10 +63,7 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
|
|||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return fmt.Errorf("can't read source: %w", err)
|
||||
}
|
||||
if !bytes.Equal(buf, []byte{0xff, 0xd8}) {
|
||||
return fmt.Errorf("parser: not MJPEG frame start: %#v", buf)
|
||||
|
@ -75,10 +72,7 @@ func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
|
|||
for {
|
||||
b, err := r.ReadByte()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return fmt.Errorf("can't read byte: %w", err)
|
||||
}
|
||||
buf = append(buf, b)
|
||||
if last == 0xff && b == 0xd9 {
|
||||
|
|
Loading…
Reference in New Issue