Fix data race in drivers

This commit is contained in:
Atsushi Watanabe
2020-02-19 15:38:51 +09:00
committed by Lukas Herman
parent 2bac44aa8a
commit 33b2964733
4 changed files with 14 additions and 7 deletions
+2 -1
View File
@@ -66,10 +66,11 @@ func (s *screen) VideoRecord(p prop.Media) (video.Reader, error) {
s.tick = time.NewTicker(time.Duration(float32(time.Second) / p.FrameRate))
var dst image.RGBA
reader := s.reader
r := video.ReaderFunc(func() (image.Image, error) {
<-s.tick.C
return s.reader.Read().ToRGBA(&dst), nil
return reader.Read().ToRGBA(&dst), nil
})
return r, nil
}