cleanup: Use io.ReadAll to fully read the buffer
Also don't ignore errors other than io.EOF, but return false for them too
This commit is contained in:
parent
2e92f00374
commit
71afd7b11a
1 changed files with 3 additions and 9 deletions
12
video.go
12
video.go
|
@ -232,16 +232,10 @@ func (video *Video) Read() bool {
|
|||
}
|
||||
}
|
||||
|
||||
total := 0
|
||||
for total < video.width*video.height*video.depth {
|
||||
n, err := video.pipe.Read(video.framebuffer[total:])
|
||||
if err == io.EOF {
|
||||
video.Close()
|
||||
return false
|
||||
}
|
||||
total += n
|
||||
if _, err := io.ReadFull(video.pipe, video.framebuffer); err != nil {
|
||||
video.Close()
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue