Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:41 +01:00
1 parent 85a9ec684c
commit c5d6137fab
160 files changed
+76293 -387

No files matched your search

+43 -3
View File
@@ -1,11 +1,16 @@
package mpd
import (
"bytes"
"image"
"strings"
"github.com/sirupsen/logrus"
"go.maze.io/harmon/player"
"github.com/BeatGlow/beatglow/player"
_ "image/jpeg"
_ "image/png"
)
type artRequest struct {
@@ -34,11 +39,46 @@ func (d *Player) AlbumArt(track *player.Track) (image.Image, bool) {
}
func (d *Player) artLoop(conn *clientConn) {
loop:
for {
select {
case request := <-d.artRequest:
logrus.WithField("path", request.Path).Debug("requesting album art")
request.Art <- nil
log := conn.log().WithFields(logrus.Fields{
"path": request.Path,
})
log.Debug("requesting album art")
var (
offset, size int
b, chunk []byte
i image.Image
err error
)
for {
if chunk, size, err = d.sendBinaryCommand(conn, "albumart %q %d", request.Path, offset); err != nil {
request.Art <- nil
if !strings.Contains(err.Error(), "No file exists") {
log.WithError(err).Error("error reading album art")
break loop
}
log.WithError(err).Debug("no album art found")
continue loop
}
b = append(b, chunk...)
offset = len(b)
if offset >= size {
break
}
}
if i, _, err = image.Decode(bytes.NewBuffer(b)); err != nil {
request.Art <- nil
log.WithError(err).Warn("image corrupt?")
log.WithField("data", string(b)).Debug("image data")
continue loop
}
request.Art <- i
case <-d.quit:
return