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
|
if _, err := io.ReadFull(video.pipe, video.framebuffer); err != nil {
|
||||||
for total < video.width*video.height*video.depth {
|
video.Close()
|
||||||
n, err := video.pipe.Read(video.framebuffer[total:])
|
return false
|
||||||
if err == io.EOF {
|
|
||||||
video.Close()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
total += n
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue