Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:41 +01:00
1 parent b8a493b93d
commit 85a9ec684c
54 files changed
+6855 -526

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
package mpd
import (
"image"
"github.com/sirupsen/logrus"
"go.maze.io/harmon/player"
)
type artRequest struct {
Path string
Art chan image.Image
}
func (d *Player) AlbumArt(track *player.Track) (image.Image, bool) {
if track == nil || track.Path == "" {
return nil, false
}
if cached, ok := d.artCache.Load(track.Path); ok {
return cached.(image.Image), true
}
// Not in cache, request artwork through the art connection.
art := make(chan image.Image)
d.artRequest <- &artRequest{Path: track.Path, Art: art}
// Respond with image.
if image := <-art; image != nil {
return image, true
}
return nil, false
}
func (d *Player) artLoop(conn *clientConn) {
for {
select {
case request := <-d.artRequest:
logrus.WithField("path", request.Path).Debug("requesting album art")
request.Art <- nil
case <-d.quit:
return
}
}
}