diff --git a/pkg/com/map_test.go b/pkg/com/map_test.go index 3a4d89bf..fb2b19f7 100644 --- a/pkg/com/map_test.go +++ b/pkg/com/map_test.go @@ -21,7 +21,7 @@ func TestMap_Base(t *testing.T) { if v != 0 && !ok { t.Errorf("should have the key %v and ok, %v %v", k, ok, m.m) } - v, ok = m.Find(k + 1) + _, ok = m.Find(k + 1) if ok { t.Errorf("should not find anything, %v %v", ok, m.m) } diff --git a/pkg/config/emulator_test.go b/pkg/config/emulator_test.go index a466783a..09afd2d4 100644 --- a/pkg/config/emulator_test.go +++ b/pkg/config/emulator_test.go @@ -29,9 +29,9 @@ func TestGetEmulator(t *testing.T) { }, { rom: "nes", - path: "test/game.nes", + path: "test2/game.nes", config: map[string]LibretroCoreConfig{ - "snes": {Roms: []string{"nes"}}, + "snes": {Roms: []string{"snes"}}, "nes": {Roms: []string{"nes"}}, }, emulator: "nes", diff --git a/pkg/games/launcher.go b/pkg/games/launcher.go index c0b1e478..af5be8df 100644 --- a/pkg/games/launcher.go +++ b/pkg/games/launcher.go @@ -32,7 +32,7 @@ func (gl GameLauncher) FindAppByName(name string) (AppMeta, error) { if game.Path == "" { return AppMeta{}, fmt.Errorf("couldn't find game info for the game %v", name) } - return AppMeta{Name: game.Name, Base: game.Base, Type: game.Type, Path: game.Path, System: game.System}, nil + return AppMeta(game), nil } func (gl GameLauncher) ExtractAppNameFromUrl(name string) string { return ExtractGame(name) } diff --git a/pkg/worker/emulator/image/canvas.go b/pkg/worker/emulator/image/canvas.go index 3c1636c6..6e8eda17 100644 --- a/pkg/worker/emulator/image/canvas.go +++ b/pkg/worker/emulator/image/canvas.go @@ -86,12 +86,13 @@ func (c *Canvas) Draw(encoding uint32, rot *Rotate, w, h, packedW, bpp int, data // rescale if dst.Rect.Dx() != c.w || dst.Rect.Dy() != c.h { - ww, hh := c.w, c.h + ww := c.w + hh := c.h // w, h supposedly have been swapped before if c.vertical { - ww, hh = hh, ww + ww, hh = c.h, c.w } - out := c.Get(c.w, c.h) + out := c.Get(ww, hh) Resize(ScaleNearestNeighbour, dst.RGBA, out.RGBA) c.Put(dst) return out diff --git a/pkg/worker/encoder/vpx/libvpx.go b/pkg/worker/encoder/vpx/libvpx.go index 23ca371a..e0370926 100644 --- a/pkg/worker/encoder/vpx/libvpx.go +++ b/pkg/worker/encoder/vpx/libvpx.go @@ -162,9 +162,9 @@ func (vpx *Vpx) IntraRefresh() { } func (vpx *Vpx) Shutdown() error { - if &vpx.image != nil { - C.vpx_img_free(&vpx.image) - } + //if &vpx.image != nil { + C.vpx_img_free(&vpx.image) + //} C.vpx_codec_destroy(&vpx.codecCtx) return nil } diff --git a/pkg/worker/encoder/yuv/yuv_test.go b/pkg/worker/encoder/yuv/yuv_test.go index 1bbe47b7..fbf53efe 100644 --- a/pkg/worker/encoder/yuv/yuv_test.go +++ b/pkg/worker/encoder/yuv/yuv_test.go @@ -246,18 +246,12 @@ func TestGen24bitFull(t *testing.T) { } } - f, err := os.Create("outimage.png") - if err != nil { - // Handle error - } + f, _ := os.Create("out_image.png") defer func() { _ = f.Close() }() // Encode to `PNG` with `DefaultCompression` level // then save to file - err = png.Encode(f, img) - if err != nil { - // Handle error - } + _ = png.Encode(f, img) } func linear(a, b, x float64) float64 { return (x - a) / (b - a) } diff --git a/pkg/worker/recorder/draw.go b/pkg/worker/recorder/draw.go deleted file mode 100644 index e3f6d4f8..00000000 --- a/pkg/worker/recorder/draw.go +++ /dev/null @@ -1,39 +0,0 @@ -package recorder - -import ( - "fmt" - "image" - "image/color" - "image/draw" - "time" - - "golang.org/x/image/font" - "golang.org/x/image/font/basicfont" - "golang.org/x/image/math/fixed" -) - -func AddLabel(img *image.RGBA, x, y int, label string) { - draw.Draw(img, image.Rect(x, y, x+len(label)*7+3, y+12), &image.Uniform{C: color.RGBA{}}, image.Point{}, draw.Src) - (&font.Drawer{ - Dst: img, - Src: image.NewUniform(color.RGBA{R: 255, G: 255, B: 255, A: 255}), - Face: basicfont.Face7x13, - Dot: fixed.Point26_6{X: fixed.Int26_6((x + 2) * 64), Y: fixed.Int26_6((y + 10) * 64)}, - }).DrawString(label) -} - -func clone(src image.Image) *image.RGBA { - b := src.Bounds() - dst := image.NewRGBA(b) - draw.Draw(dst, b, src, b.Min, draw.Src) - return dst -} - -func TimeFormat(d time.Duration) string { - mms := int(d.Milliseconds()) - ms := mms % 1000 - s := (mms / 1000) % 60 - m := (mms / (1000 * 60)) % 60 - h := (mms / (1000 * 60 * 60)) % 24 - return fmt.Sprintf("%02d:%02d:%02d.%03d", h, m, s, ms) -} diff --git a/pkg/worker/recorder/pngstream.go b/pkg/worker/recorder/pngstream.go index 39fee7bb..1cb0cf88 100644 --- a/pkg/worker/recorder/pngstream.go +++ b/pkg/worker/recorder/pngstream.go @@ -13,8 +13,6 @@ import ( ) type pngStream struct { - videoStream - dir string e *png.Encoder id uint32 diff --git a/pkg/worker/recorder/wavstream.go b/pkg/worker/recorder/wavstream.go index c445a6d5..f63ea70e 100644 --- a/pkg/worker/recorder/wavstream.go +++ b/pkg/worker/recorder/wavstream.go @@ -1,10 +1,11 @@ package recorder -import "encoding/binary" +import ( + "encoding/binary" + "errors" +) type wavStream struct { - audioStream - frequency int wav *file } @@ -33,14 +34,20 @@ func (w *wavStream) Close() (err error) { err = w.wav.Flush() size, er := w.wav.Size() if er != nil { - err = er + err = errors.Join(err, er) } if size > 0 { // write an actual RIFF header - err = w.wav.WriteAtStart(rIFFWavHeader(uint32(size), w.frequency)) - err = w.wav.Flush() + if er = w.wav.WriteAtStart(rIFFWavHeader(uint32(size), w.frequency)); er != nil { + err = errors.Join(err, er) + } + if er = w.wav.Flush(); er != nil { + err = errors.Join(err, er) + } + } + if er = w.wav.Close(); er != nil { + err = errors.Join(err, er) } - err = w.wav.Close() return }