mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-31 22:11:38 +00:00
Fix lint warnings
This commit is contained in:
parent
d5bb271469
commit
65b6e3208f
9 changed files with 27 additions and 66 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -13,8 +13,6 @@ import (
|
|||
)
|
||||
|
||||
type pngStream struct {
|
||||
videoStream
|
||||
|
||||
dir string
|
||||
e *png.Encoder
|
||||
id uint32
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue