Compare commits

..
27 changed files with 789 additions and 226 deletions

No files matched your search

+2
View File
@@ -16,6 +16,8 @@
!README.md !README.md
!LICENSE !LICENSE
!/AGENTS.md
!/docs/agents/*.md
# README screenshots and wiring illustrations # README screenshots and wiring illustrations
!/asset/image/beatglow-*.gif !/asset/image/beatglow-*.gif
+100
View File
@@ -0,0 +1,100 @@
# BeatGlow agent guide
BeatGlow is a Go music visualizer for embedded Linux audio players, especially
Raspberry Pi systems. Read the relevant code and these guides before changing it:
- [Coding conventions](docs/agents/CodingConventions.md)
- [Operational guidance](docs/agents/OperationalDoctrine.md)
- [Go documentation](docs/agents/GoDocs.md)
## Git and Gitea workflow
- Create and switch to a feature branch before editing files or making commits.
- Never commit directly on `main` or `master`.
- Use descriptive branch names, such as `feature/mpd-fifo-output-monitoring`,
`fix/readme-images`, or `chore/agent-instructions`.
- Continue on an existing feature branch when working on the same task. Create a
separate branch from the target branch for unrelated work.
- If changes already exist on `main` or `master`, create a feature branch that
preserves those changes before committing them.
- Open pull requests against the target branch; do not merge or push changes
directly to `main` or `master` unless the user explicitly requests it.
- Base new work on `main` (normally `origin/main`); fetch when remote state matters.
Do not discard local changes or rewrite unrelated commits to update the base.
- Make focused commits with concise, descriptive subjects.
- Use the configured remote; this project uses Gitea. MR and PR refer to the same
review workflow here. Do not assume GitHub tooling works with Gitea.
- PR descriptions should explain the problem, resulting behavior, verification,
and remaining limitations. Reference an issue only when one exists, and mark it
closed only if the change completes it. Target the branch the work is based on.
- When API authentication is unavailable, push the requested feature branch and
provide the creation link; distinguish a pushed branch from a submitted PR.
## Project map
| Location | Responsibility |
| --- | --- |
| `cmd/beatglow/` | CLI, configuration discovery, installation and startup |
| `controller.go`, `context.go`, `hardware.go` | Component setup, events, rendering and audio processing |
| `config/` | HCL configuration and user settings; examples in `beatglow.conf` |
| `app/layout/`, `app/widget/`, `app/shader/`, `app/font/` | Screens, widgets, visual effects and embedded fonts |
| `player/` | Player contracts, registration and automatic detection |
| `player/mpd/` | MPD connections, commands, metadata and artwork |
| `player/raudio/`, `player/volumio/`, `player/moode/`, `player/runeaudio/` | Distribution-specific integrations; inspect implementation completeness |
| `player/all/` | Side-effect imports that load player drivers |
| `sound/` | PCM file/FIFO sources and audio diagnostics |
| `hardware/` | Display setup, combined displays, Linux network information and inputs |
| `internal/`, `testdata/` | Internal helpers and test fixtures |
| `asset/image/`, `doc/hardware/` | README illustrations and hardware references |
Player detection runs in ascending priority order. Register distribution-specific
detectors ahead of generic MPD and import new drivers through `player/all/`.
Keep PCM sample format, channels and rate consistent with the configured producer.
## Build and verification
Use the Go version required by `go.mod` or newer. The display dependency currently
resolves to `../display`; check that checkout exists before diagnosing dependencies.
Do not silently remove the replacement or upgrade dependencies for unrelated work.
```sh
# Existing Makefile target: Linux ARM binary, written to ./beatglow
make beatglow
# Linux ARM64 binary without overwriting the repository's local executable
GOOS=linux GOARCH=arm64 go build -o /tmp/beatglow ./cmd/beatglow
# Execute on Linux; narrow package paths for focused changes
go test ./...
go vet ./...
# On macOS: compile Linux tests only; /usr/bin/true does not execute them
GOOS=linux GOARCH=arm64 go test -exec /usr/bin/true ./player/...
git diff --check
```
Run `goimports` on changed Go files. The Makefile has no test, lint, integration-test,
or generation targets. Linux wireless helpers prevent some packages from building
natively on macOS. Report cross-compilation separately from executed tests and
hardware verification. Use race tests on Linux when changing shared state.
Known failures observed during setup include a log-format vet error in
`app/font/font.go` and a float32/float64 test mismatch in `internal/calc/calc_test.go`.
Recheck their current status; report unrelated failures without hiding them or
expanding scope automatically.
## Assets and dependencies
The repository uses an allowlist `.gitignore`. Verify new docs and assets appear
in Git; add narrow exceptions when needed. README images belong in `asset/image/`.
Check that all Markdown image targets exist and are tracked.
PDF, BDF and TTF filters are configured in local `.gitattributes`; check the actual
attributes and Git LFS availability before adding or changing these files. Preserve
real assets and LFS objects. Never substitute placeholders to pass a build.
## Sources
Structure inspired by [Flow's AGENTS.md](https://github.com/onflow/flow-go/blob/master/AGENTS.md).
The linked local guides are project-specific adaptations, not verbatim imports.
-10
View File
@@ -59,16 +59,6 @@ During the shader, running various shader effects, running 44.1kHz stereo audio:
## Setup ## Setup
When the audio source uses `type = "fifo"`, MPD-based players check the output
status after connecting and every 15 seconds. BeatGlow logs a warning if the
matching output is disabled or missing, and reports when it becomes enabled.
It does not enable outputs automatically. A single FIFO output is selected
automatically. If MPD has multiple FIFO outputs, set `output = "BeatGlow"` in
the `audio` block, using the name of the MPD output that writes to your FIFO.
Older MPD versions that omit the output plugin also require this name.
MPD does not expose FIFO paths through its output status, so the configured
output must write to the same path as the audio source.
Minimal requirements: Minimal requirements:
- Linux Computer (Raspberry Pi 3B+) - Linux Computer (Raspberry Pi 3B+)
- Supported display - Supported display
+3 -1
View File
@@ -78,7 +78,7 @@ func (l *settings) HandleButtonPress(ctx app.Context) {
return return
} }
l.menu = menu l.menu = menu
} else { } else if item.IsEditable() {
log.Debug("enter edit mode") log.Debug("enter edit mode")
l.menu.ToggleEdit() l.menu.ToggleEdit()
} }
@@ -90,12 +90,14 @@ func (l *settings) HandleButtonPress(ctx app.Context) {
func (l *settings) HandleButtonLongPress(ctx app.Context) { func (l *settings) HandleButtonLongPress(ctx app.Context) {
// Rewind to root menu // Rewind to root menu
for { for {
l.menu.Editing = false
parent := l.menu.Parent parent := l.menu.Parent
if parent == nil { if parent == nil {
break break
} }
l.menu = parent l.menu = parent
} }
l.menuWidget.Update(l.menu)
// Close settings layout. // Close settings layout.
ctx.Show(nil) ctx.Show(nil)
+118
View File
@@ -0,0 +1,118 @@
package layout
import (
"image"
"testing"
"github.com/BeatGlow/beatglow/app"
"github.com/BeatGlow/beatglow/app/menu"
"github.com/BeatGlow/beatglow/app/widget"
"github.com/BeatGlow/beatglow/config"
)
type settingsTestContext struct {
app.Context
closed bool
}
func (c *settingsTestContext) Show(layout app.Layout) { c.closed = layout == nil }
func TestSettingsBackAndInformation(t *testing.T) {
data := config.DefaultSettings
root, err := menu.New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
l := &settings{menu: root, menuWidget: widget.NewMenu(image.Pt(256, 64), root)}
ctx := &settingsTestContext{}
root.Position = 4 // System
l.HandleButtonPress(ctx)
if l.menu.Parent != root {
t.Fatal("did not enter System submenu")
}
for _, position := range []int{1, 2} {
l.menu.Position = position
l.HandleButtonPress(ctx)
if l.menu.IsEditing() {
t.Fatal("system information entered edit mode")
}
}
l.HandleRotary(ctx, -2)
l.HandleButtonPress(ctx)
if l.menu != root || l.menuWidget.Root != root {
t.Fatal("Back did not restore the root menu")
}
if root.Position != 4 {
t.Fatal("parent selection was lost")
}
root.Position = 0
l.HandleButtonPress(ctx)
if !ctx.closed {
t.Fatal("root Back did not close settings")
}
}
func TestSettingsLongPressSynchronizesMenu(t *testing.T) {
data := config.DefaultSettings
root, err := menu.New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
root.Position = 1 // Display
child := root.EnterSubMenu()
child.Position = 1
child.ToggleEdit()
l := &settings{menu: child, menuWidget: widget.NewMenu(image.Pt(256, 64), child)}
ctx := &settingsTestContext{}
l.HandleButtonLongPress(ctx)
if !ctx.closed || l.menu != root || l.menuWidget.Root != root {
t.Fatal("long press left the rendered menu out of sync")
}
if child.IsEditing() || root.IsEditing() {
t.Fatal("long press left an item in edit mode")
}
l.HandleButtonPress(ctx)
if l.menu != child || l.menu.IsEditing() {
t.Fatal("reopening submenu did not restore navigation mode")
}
}
func TestBooleanSelectionSurvivesConfirmation(t *testing.T) {
data := config.DefaultSettings
data.Player.ShowArt = true
root, err := menu.New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
root.Position = 2 // Player
l := &settings{settings: &data, menu: root, menuWidget: widget.NewMenu(image.Pt(256, 64), root)}
ctx := &settingsTestContext{}
l.HandleButtonPress(ctx)
l.HandleRotary(ctx, 2) // Show album art
l.HandleButtonPress(ctx)
for _, delta := range []int{-1, -1, -3} {
l.HandleRotary(ctx, delta)
}
if data.Player.ShowArt {
t.Fatal("left did not keep checkbox unchecked")
}
l.HandleButtonPress(ctx)
if l.menu.IsEditing() || data.Player.ShowArt {
t.Fatal("press did not confirm unchecked value")
}
l.HandleRotary(ctx, -2)
l.HandleButtonPress(ctx) // Back to root
l.HandleButtonPress(ctx) // Reopen Player
l.HandleRotary(ctx, 2) // Show album art
l.HandleButtonPress(ctx) // Edit selected Show album art
if data.Player.ShowArt {
t.Fatal("reopening checkbox reset its value")
}
for _, delta := range []int{1, 1, 3} {
l.HandleRotary(ctx, delta)
}
l.HandleButtonPress(ctx)
if l.menu.IsEditing() || !data.Player.ShowArt {
t.Fatal("press did not confirm checked value")
}
}
+46 -14
View File
@@ -26,6 +26,9 @@ type Menu struct {
pageSize int pageSize int
} }
// New builds a menu over the exported fields of a struct pointer. It returns an
// error for non-struct or unaddressable data, unsupported fields, or invalid tags.
// Values remain owned by the caller; menu edits and reads must be serialized.
func New(data any, pageSize int, parent *Menu) (*Menu, error) { func New(data any, pageSize int, parent *Menu) (*Menu, error) {
ref := reflect.ValueOf(data) ref := reflect.ValueOf(data)
@@ -41,6 +44,9 @@ func New(data any, pageSize int, parent *Menu) (*Menu, error) {
if ref.Kind() != reflect.Struct { if ref.Kind() != reflect.Struct {
return nil, fmt.Errorf("menu: %T is not a struct", data) return nil, fmt.Errorf("menu: %T is not a struct", data)
} }
if !ref.CanAddr() {
return nil, fmt.Errorf("menu: %T must be a pointer to a struct", data)
}
menu := &Menu{ menu := &Menu{
Parent: parent, Parent: parent,
@@ -51,16 +57,20 @@ func New(data any, pageSize int, parent *Menu) (*Menu, error) {
Value: Back, Value: Back,
}}, }},
} }
menu.SetPageSize(pageSize)
typ := ref.Type() typ := ref.Type()
for i, n := 0, ref.NumField(); i < n; i++ { for i, n := 0, ref.NumField(); i < n; i++ {
field := typ.Field(i)
if field.Tag.Get("menu") == "-" || !field.IsExported() {
continue
}
var ( var (
field = typ.Field(i)
fieldRef = ref.Field(i) fieldRef = ref.Field(i)
value = ref.Field(i).Addr().Interface() value = ref.Field(i).Addr().Interface()
icon = field.Tag.Get("icon") icon = field.Tag.Get("icon")
label = field.Tag.Get("menu") label = field.Tag.Get("menu")
options = strings.Split(field.Tag.Get("options"), ",") options []string
step = 1 step = 1
min, max int min, max int
err error err error
@@ -68,8 +78,9 @@ func New(data any, pageSize int, parent *Menu) (*Menu, error) {
if len(label) == 0 { if len(label) == 0 {
label = field.Name label = field.Name
} else if label == "-" { }
continue if tag := field.Tag.Get("options"); tag != "" {
options = strings.Split(tag, ",")
} }
if stepTag := field.Tag.Get("step"); stepTag != "" { if stepTag := field.Tag.Get("step"); stepTag != "" {
@@ -89,10 +100,10 @@ func New(data any, pageSize int, parent *Menu) (*Menu, error) {
} }
if !fieldRef.CanAddr() { if !fieldRef.CanAddr() {
panic(fmt.Sprintf("fieldref %T for %T is not addressable", fieldRef, value)) return nil, fmt.Errorf("menu: field %s is not addressable", field.Name)
} }
if !fieldRef.CanSet() { if !fieldRef.CanSet() {
panic(fmt.Sprintf("fieldref %T for %T is not settable", fieldRef, value)) return nil, fmt.Errorf("menu: field %s is not settable", field.Name)
} }
switch field.Type.Kind() { switch field.Type.Kind() {
@@ -198,9 +209,9 @@ func (m *Menu) edit(delta int) {
// Adjust the value if editing // Adjust the value if editing
switch v := item.Value.(type) { switch v := item.Value.(type) {
case *uint8: case *uint8:
newValue := *v + uint8(delta*item.Step) newValue := int(*v) + delta*item.Step
if newValue >= uint8(item.Min) && newValue <= uint8(item.Max) { if newValue >= item.Min && newValue <= item.Max {
*v = newValue *v = uint8(newValue)
} }
case *int: case *int:
newValue := *v + (delta * item.Step) newValue := *v + (delta * item.Step)
@@ -209,13 +220,13 @@ func (m *Menu) edit(delta int) {
} }
case *bool: case *bool:
if delta != 0 { if delta != 0 {
*v = !*v *v = delta > 0
} }
case *string: case *string:
if len(item.Options) > 0 { if len(item.Options) > 0 {
currentIndex := indexOf(*v, item.Options) currentIndex := indexOf(*v, item.Options)
if currentIndex != -1 { if currentIndex != -1 {
newIndex := (currentIndex + delta + len(item.Options)) % len(item.Options) newIndex := (currentIndex + delta%len(item.Options) + len(item.Options)) % len(item.Options)
*v = item.Options[newIndex] *v = item.Options[newIndex]
} }
} }
@@ -254,8 +265,11 @@ func (m *Menu) PageSize() int {
return m.pageSize return m.pageSize
} }
// SetPageSize updates the page size. // SetPageSize updates this menu and its submenus, with a minimum of one item.
func (m *Menu) SetPageSize(pageSize int) { func (m *Menu) SetPageSize(pageSize int) {
if pageSize < 1 {
pageSize = 1
}
m.pageSize = pageSize m.pageSize = pageSize
for _, item := range m.Items { for _, item := range m.Items {
if item.SubMenu != nil { if item.SubMenu != nil {
@@ -269,9 +283,14 @@ func (m *Menu) IsEditing() bool {
return m.Editing return m.Editing
} }
// ToggleEdit switches between navigation and editing modes. // ToggleEdit exits editing or starts editing an editable item. Informational
// items, submenu entries and Back remain in navigation mode.
func (m *Menu) ToggleEdit() { func (m *Menu) ToggleEdit() {
m.Editing = !m.Editing if m.Editing {
m.Editing = false
} else if m.ActiveItem().IsEditable() {
m.Editing = true
}
} }
func (m *Menu) IsSubMenu() bool { func (m *Menu) IsSubMenu() bool {
@@ -324,6 +343,19 @@ type Item struct {
Options []string Options []string
} }
// IsEditable reports whether the item accepts rotary input. Strings without
// enumerated options are informational and remain read-only.
func (item Item) IsEditable() bool {
switch item.Value.(type) {
case *bool, *uint8, *int:
return true
case *string:
return len(item.Options) > 0
default:
return false
}
}
// indexOf returns the index of a value in a slice, or -1 if not found // indexOf returns the index of a value in a slice, or -1 if not found
func indexOf(needle string, haystack []string) int { func indexOf(needle string, haystack []string) int {
for i, opt := range haystack { for i, opt := range haystack {
+146 -4
View File
@@ -49,10 +49,152 @@ func TestMenuNil(t *testing.T) {
func TestMenuNotPointer(t *testing.T) { func TestMenuNotPointer(t *testing.T) {
var settings testSettings var settings testSettings
menu, err := New(settings, 4, nil) _, err := New(settings, 4, nil)
if err == nil {
t.Fatal("expected error for an unaddressable struct")
}
}
func TestInformationalItemsRemainNavigable(t *testing.T) {
data := struct {
LoadAverage string
LocalTime string
}{LoadAverage: "0.12 0.10 0.08", LocalTime: "12:00"}
m, err := New(&data, 4, nil)
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
}
for _, position := range []int{1, 2} {
m.Position = position
m.ToggleEdit()
if m.IsEditing() {
t.Fatal("informational item entered edit mode")
}
m.Change(-position)
if m.ActiveItem().Value != Back {
t.Fatal("cannot navigate back after selecting information")
}
}
if data.LoadAverage != "0.12 0.10 0.08" || data.LocalTime != "12:00" {
t.Fatal("informational values changed")
}
}
func TestSubmenuBackPreservesParentPosition(t *testing.T) {
var data testSettings
root, err := New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
root.Position = 2
child := root.EnterSubMenu()
if child == nil {
t.Fatal("missing submenu")
}
if child.ActiveItem().Value != Back {
t.Fatal("submenu should initially select Back")
}
if got := child.ExitSubMenu(); got != root || got.Position != 2 {
t.Fatal("Back did not restore parent selection")
}
root.Position = 0
root.ToggleEdit()
if root.IsEditing() {
t.Fatal("Back entered edit mode")
}
if root.ExitSubMenu() != nil {
t.Fatal("root should exit settings")
}
}
func TestStringOptionsLargeNegativeDelta(t *testing.T) {
data := struct {
Sleep string `options:"5min,15min,hour,day"`
}{Sleep: "hour"}
m, err := New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
m.Position = 1
m.ToggleEdit()
if !m.IsEditing() {
t.Fatal("option item should be editable")
}
m.Change(-11)
if data.Sleep != "day" {
t.Fatalf("got %q, want day", data.Sleep)
}
}
func TestUint8DoesNotWrap(t *testing.T) {
data := struct{ Contrast uint8 }{Contrast: 255}
m, err := New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
m.Position = 1
m.ToggleEdit()
m.Change(1)
if data.Contrast != 255 {
t.Fatal("contrast wrapped above maximum")
}
data.Contrast = 0
m.Change(-1)
if data.Contrast != 0 {
t.Fatal("contrast wrapped below minimum")
}
}
func TestMinimumPageSize(t *testing.T) {
var data testSettings
m, err := New(&data, 0, nil)
if err != nil {
t.Fatal(err)
}
if m.PageSize() != 1 {
t.Fatal("page size must be positive")
}
m.SetPageSize(-1)
if m.Items[1].SubMenu.PageSize() != 1 {
t.Fatal("submenu page size must be positive")
}
}
func TestBooleanEditingUsesDirection(t *testing.T) {
for _, initial := range []bool{false, true} {
data := struct{ Enabled bool }{Enabled: initial}
m, err := New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
m.Position = 1
m.ToggleEdit()
for _, delta := range []int{1, 1, 3, 0, -1, -1, -4, 0, 1} {
before := data.Enabled
m.Change(delta)
want := delta > 0
if delta == 0 {
want = before
}
if data.Enabled != want {
t.Fatalf("initial=%v delta=%d: got %v, want %v", initial, delta, data.Enabled, want)
}
if m.Position != 1 || !m.IsEditing() {
t.Fatal("rotating left boolean edit mode")
}
}
m.ToggleEdit()
if m.IsEditing() || !data.Enabled {
t.Fatal("confirming did not preserve the selected value")
}
m.Change(-1)
if m.Position != 0 || !data.Enabled {
t.Fatal("navigation changed the confirmed value")
}
m.Change(1)
m.ToggleEdit()
if !data.Enabled {
t.Fatal("reopening edit mode reset the value")
}
} }
t.Logf("menu: %#+v", menu)
} }
+7 -2
View File
@@ -22,6 +22,7 @@ func NewMenu(size image.Point, root *menu.Menu) *Menu {
w := new(Menu) w := new(Menu)
w.Extend(w) w.Extend(w)
w.Resize(size) w.Resize(size)
w.Update(root)
return w return w
} }
@@ -44,7 +45,7 @@ func (w *Menu) Redraw() {
} }
func (w *Menu) Refresh(ctx app.Context) bool { func (w *Menu) Refresh(ctx app.Context) bool {
if !w.IsVisible() { if !w.IsVisible() || w.Root == nil {
return false return false
} }
@@ -54,7 +55,7 @@ func (w *Menu) Refresh(ctx app.Context) bool {
) )
if w.changed.CompareAndSwap(true, false) || w.buffer == nil || (w.curr != w.next && w.next != nil) { if w.changed.CompareAndSwap(true, false) || w.buffer == nil || (w.curr != w.next && w.next != nil) {
if w.buffer == nil { if w.buffer == nil || w.buffer.Bounds().Size() != size {
w.buffer = app.BufferFor(ctx.Display().ColorModel(), size) w.buffer = app.BufferFor(ctx.Display().ColorModel(), size)
w.Root.SetPageSize(size.Y / 16) w.Root.SetPageSize(size.Y / 16)
} }
@@ -63,6 +64,8 @@ func (w *Menu) Refresh(ctx app.Context) bool {
w.curr, w.next = w.next, nil w.curr, w.next = w.next, nil
} }
w.curr.SetPageSize(size.Y / 16)
// Clear the buffer. // Clear the buffer.
app.ImageClear(w.buffer) app.ImageClear(w.buffer)
@@ -101,6 +104,8 @@ func (w *Menu) Refresh(ctx app.Context) bool {
y := size.Y / len(menu.Items) * menu.Position y := size.Y / len(menu.Items) * menu.Position
draw.Box(w.buffer, image.Rect(size.X-3, y, size.X, y+size.Y/len(menu.Items)), color.Gray{Y: 0x7f}) draw.Box(w.buffer, image.Rect(size.X-3, y, size.X, y+size.Y/len(menu.Items)), color.Gray{Y: 0x7f})
} }
} else {
return false
} }
app.ImageCopyBounds(ctx.Display(), w.buffer, bounds.Add(w.position.Load())) app.ImageCopyBounds(ctx.Display(), w.buffer, bounds.Add(w.position.Load()))
+57
View File
@@ -0,0 +1,57 @@
package widget
import (
"image"
"image/color"
"testing"
"github.com/BeatGlow/beatglow/app"
"github.com/BeatGlow/beatglow/app/menu"
"github.com/BeatGlow/display"
"github.com/BeatGlow/display/pixel"
)
type menuTestDisplay struct {
display.Display
image *image.RGBA
}
func (d *menuTestDisplay) Bounds() image.Rectangle { return d.image.Bounds() }
func (d *menuTestDisplay) ColorModel() color.Model { return pixel.Gray4Model }
func (d *menuTestDisplay) At(x, y int) color.Color { return d.image.At(x, y) }
func (d *menuTestDisplay) Set(x, y int, c color.Color) { d.image.Set(x, y, c) }
type menuTestContext struct {
app.Context
display display.Display
}
func (c *menuTestContext) Display() display.Display { return c.display }
func TestMenuRefreshOnlyOnChanges(t *testing.T) {
data := struct{ Enabled bool }{}
root, err := menu.New(&data, 4, nil)
if err != nil {
t.Fatal(err)
}
ctx := &menuTestContext{display: &menuTestDisplay{image: image.NewRGBA(image.Rect(0, 0, 256, 48))}}
w := NewMenu(image.Pt(256, 48), root)
w.SetStyles(*app.StylesFor(pixel.Gray4Model))
w.Show(ctx)
if !w.Refresh(ctx) {
t.Fatal("initial menu was not drawn")
}
if w.Refresh(ctx) {
t.Fatal("unchanged menu requested another hardware refresh")
}
root.Change(1)
w.Redraw()
if !w.Refresh(ctx) || w.Refresh(ctx) {
t.Fatal("menu change should trigger exactly one refresh")
}
w.Hide(ctx)
w.Show(ctx)
if !w.Refresh(ctx) {
t.Fatal("reopened menu was not drawn")
}
}
-4
View File
@@ -161,10 +161,6 @@ audio {
# Path to the audio stream. # Path to the audio stream.
path = "/tmp/beatglow.fifo" path = "/tmp/beatglow.fifo"
# MPD output name (optional when MPD has exactly one FIFO output).
# Must match the name of the output writing to the path above.
# output = "BeatGlow"
# Rate is the sampling rate. # Rate is the sampling rate.
rate = 44100 rate = 44100
-1
View File
@@ -88,7 +88,6 @@ type Encoder struct {
// Audio source provides PCM samples. // Audio source provides PCM samples.
type Audio struct { type Audio struct {
Output string `hcl:"output,optional"`
Type string `hcl:"type"` Type string `hcl:"type"`
Path string `hcl:"path,optional"` Path string `hcl:"path,optional"`
Host string `hcl:"host,optional"` Host string `hcl:"host,optional"`
+2 -2
View File
@@ -41,8 +41,8 @@ type SpectrumSettings struct {
} }
type SystemSettings struct { type SystemSettings struct {
LoadAverage string `label:"Load average"` LoadAverage string `menu:"Load average"`
LocalTime string `label:"Local time"` LocalTime string `menu:"Local time"`
} }
var DefaultSettings = Settings{ var DefaultSettings = Settings{
+6 -12
View File
@@ -115,8 +115,7 @@ func (c *controllerContext) Show(layout app.Layout) {
for _, other := range c.layouts { for _, other := range c.layouts {
if other == layout { if other == layout {
if layout != c.settingsLayout { if layout != c.active {
// Only store a "previous" screen if the active screen isn't the settings.
c.previous, c.active = c.active, layout c.previous, c.active = c.active, layout
} }
log.WithField("layout", layout).Debug("show layout") log.WithField("layout", layout).Debug("show layout")
@@ -174,37 +173,32 @@ func (c *controllerContext) handleInput(event hardware.InputEvent) {
if handler, ok := layout.(app.RotaryInputHandler); ok { if handler, ok := layout.(app.RotaryInputHandler); ok {
log.WithField("layout", layout.String()).Debug("dispatch rotary input") log.WithField("layout", layout.String()).Debug("dispatch rotary input")
handler.HandleRotary(c, event.Delta) handler.HandleRotary(c, event.Delta)
return
} }
} }
} }
case hardware.RotaryPressEvent: case hardware.RotaryPressEvent:
var handled bool
for _, layout := range c.layouts { for _, layout := range c.layouts {
if layout.IsVisible() { if layout.IsVisible() {
if handler, ok := layout.(app.ButtonInputHandler); ok { if handler, ok := layout.(app.ButtonInputHandler); ok {
log.WithField("layout", layout.String()).Debug("dispatch button press") log.WithField("layout", layout.String()).Debug("dispatch button press")
handler.HandleButtonPress(c) handler.HandleButtonPress(c)
handled = true return
} }
} }
} }
if !handled { c.handleRotaryPress()
c.handleRotaryPress()
}
case hardware.RotaryLongPressEvent: case hardware.RotaryLongPressEvent:
var handled bool
for _, layout := range c.layouts { for _, layout := range c.layouts {
if layout.IsVisible() { if layout.IsVisible() {
if handler, ok := layout.(app.ButtonInputHandler); ok { if handler, ok := layout.(app.ButtonInputHandler); ok {
log.WithField("layout", layout.String()).Debug("dispatch button long press") log.WithField("layout", layout.String()).Debug("dispatch button long press")
handler.HandleButtonLongPress(c) handler.HandleButtonLongPress(c)
handled = true return
} }
} }
} }
if !handled { c.handleRotaryLongPress()
c.handleRotaryLongPress()
}
default: default:
log.Warn("unhandled input event") log.Warn("unhandled input event")
} }
+70
View File
@@ -0,0 +1,70 @@
package beatglow
import (
"testing"
"github.com/BeatGlow/beatglow/app"
"github.com/BeatGlow/beatglow/hardware"
)
type navigationTestLayout struct {
app.Layout
name string
visible bool
}
func (l *navigationTestLayout) String() string { return l.name }
func (l *navigationTestLayout) Show(app.Context) { l.visible = true }
func (l *navigationTestLayout) Hide(app.Context) { l.visible = false }
func (l *navigationTestLayout) IsVisible() bool { return l.visible }
func TestSettingsReturnsToActiveLayout(t *testing.T) {
settings := &navigationTestLayout{name: "settings"}
playing := &navigationTestLayout{name: "playing"}
analyzer := &navigationTestLayout{name: "analyzer"}
c := &controllerContext{settingsLayout: settings, layouts: []app.Layout{settings, playing, analyzer}}
c.Show(playing)
c.Show(analyzer)
for i := 0; i < 2; i++ {
c.Show(settings)
if c.active != settings || c.previous != analyzer {
t.Fatal("settings did not remember the active screen")
}
c.Show(nil)
if c.active != analyzer || !analyzer.visible || settings.visible {
t.Fatal("exiting settings did not restore analyzer")
}
}
}
type inputTestLayout struct {
navigationTestLayout
onPress func(app.Context)
presses int
}
func (l *inputTestLayout) HandleButtonPress(ctx app.Context) {
l.presses++
if l.onPress != nil {
l.onPress(ctx)
}
}
func (l *inputTestLayout) HandleButtonLongPress(ctx app.Context) { l.HandleButtonPress(ctx) }
func TestButtonEventIsNotRedispatchedAfterScreenChange(t *testing.T) {
for _, long := range []bool{false, true} {
first := &inputTestLayout{navigationTestLayout: navigationTestLayout{name: "first"}}
second := &inputTestLayout{navigationTestLayout: navigationTestLayout{name: "second"}}
c := &controllerContext{layouts: []app.Layout{first, second}}
c.Show(first)
first.onPress = func(ctx app.Context) { ctx.Show(second) }
if long {
c.handleInput(hardware.RotaryLongPressEvent{})
} else {
c.handleInput(hardware.RotaryPressEvent{})
}
if first.presses != 1 || second.presses != 0 {
t.Fatalf("event was redispatched: first=%d second=%d", first.presses, second.presses)
}
}
}
-7
View File
@@ -30,10 +30,6 @@ type Controller struct {
recorderPalette color.Palette recorderPalette color.Palette
} }
type audioSourceConfigurator interface {
SetAudioSource(config.Audio)
}
func New(config *config.Config) (*Controller, error) { func New(config *config.Config) (*Controller, error) {
log := logrus.NewEntry(logrus.StandardLogger()) log := logrus.NewEntry(logrus.StandardLogger())
@@ -63,9 +59,6 @@ func New(config *config.Config) (*Controller, error) {
c.teardown(log) c.teardown(log)
return nil, err return nil, err
} }
if p, ok := c.ctx.player.(audioSourceConfigurator); ok {
p.SetAudioSource(config.Audio)
}
if err := c.configureInputs(log, &config.Input); err != nil { if err := c.configureInputs(log, &config.Input); err != nil {
log.WithError(err).Error("fatal error setting up inputs") log.WithError(err).Error("fatal error setting up inputs")
c.teardown(log) c.teardown(log)
+19
View File
@@ -0,0 +1,19 @@
# Coding conventions
- Use idiomatic Go, `goimports`, and the surrounding package's naming and import style.
Extend existing contracts instead of introducing parallel registries or layers.
- Wrap propagated errors with useful context and `%w`. Use `errors.Is` or
`errors.As` when callers need to recognize them.
- Decide recovery at the caller: a disconnected MPD server can be retried, while
unusable startup configuration should return an error. Explain intentional
recovery; avoid silent failures and unnecessary process termination.
- Use structured Logrus fields for component, device, connection and path context.
Keep frame/sample loops quiet; log meaningful transitions and actionable failures.
- Keep display refreshes and controller event handling responsive. Close owned
connections, files and tickers; make goroutine shutdown explicit. Review channel
ownership and synchronization when changing lifecycle behavior.
- Validate protocol responses, HCL values, dimensions and PCM formats before use.
Respect Linux build constraints and hardware-specific dependencies.
- Put focused tests beside implementations. Cover parsing, malformed input,
detection precedence, failures and recovery with temporary files or fake servers.
Unit tests should run without physical GPIO, displays or a live MPD instance.
+19
View File
@@ -0,0 +1,19 @@
# Go documentation
- Document new or changed exported APIs and interfaces. Explain private code when
its lifecycle, protocol behavior or invariants are not clear from the code.
- Start API comments with the declared name and write complete sentences. Use
paragraphs and Go doc links such as `[Player]` for relevant Go identifiers.
- Describe the contract: parameter constraints, units, defaults, return values,
blocking behavior and resource ownership when they matter to callers.
- For error returns, explain actionable failure conditions and recognizable
sentinel errors that the implementation actually returns. Do not invent error
types, guarantees or recovery behavior.
- State concurrency restrictions explicitly. Do not assume a type is safe for
concurrent use simply because no warning exists.
- Keep interface contracts and implementations consistent. Explain meaningful
deviations rather than copying comments mechanically.
- For documentation-only tasks, preserve runtime behavior. Correct inaccurate
documentation after checking the implementation; keep separate logic fixes scoped.
- Wrap prose around 100 characters where practical. Avoid documenting obvious
implementation steps or adding repetitive boilerplate.
+18
View File
@@ -0,0 +1,18 @@
# Operational guidance
- Follow the user's task and established preferences. Continue authorized work
without repeatedly asking for confirmation; clarify genuinely missing decisions.
- Inspect the code, branch, diff and relevant documentation before making changes.
Verify external protocol behavior against upstream documentation when needed.
- Keep changes within scope and preserve unrelated work. Explain a necessary
scope change instead of silently bundling cleanup or dependency updates.
- Communicate directly and briefly. Explain findings, behavior changes and remaining
uncertainty; avoid flattery and unsupported claims.
- Review the surrounding component after editing, including configuration,
registration, lifecycle and callers affected by an interface change.
- Test the behavior that changed. State which tests ran, which checks only
compiled, and what requires Linux, hardware, network access or authentication.
- Describe recoverable device/server failures realistically. Do not label an issue
critical without evidence or claim a fix is verified on hardware without testing it.
- Finish with concise results, links to changed files or the PR, and material
limitations. Never report a PR created when only its branch was pushed.
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"github.com/BeatGlow/beatglow/hardware" "github.com/BeatGlow/beatglow/hardware"
) )
var LongPressDuration = 350 * time.Millisecond var LongPressDuration = 750 * time.Millisecond
type Encoder interface { type Encoder interface {
hardware.Driver hardware.Driver
+72
View File
@@ -0,0 +1,72 @@
package input
import (
"encoding/binary"
"fmt"
"io"
"time"
)
// linuxInputEvent holds a decoded evdev record, independent of native word size.
type linuxInputEvent struct {
Secs, USecs int64
Type, Code uint16
Value int32
}
func (e linuxInputEvent) String() string {
return fmt.Sprintf("time=%s type=%#04x code=%#04x value=%d", e.Time(), e.Type, e.Code, e.Value)
}
func (e linuxInputEvent) Time() time.Time {
return time.Unix(e.Secs, e.USecs*int64(time.Microsecond))
}
// readLinuxInputEvent reads one little-endian Linux event for a 4- or 8-byte
// native word. Short records return the error from io.ReadFull.
func readLinuxInputEvent(r io.Reader, wordSize int) (linuxInputEvent, error) {
var e linuxInputEvent
if wordSize != 4 && wordSize != 8 {
return e, fmt.Errorf("input: unsupported word size %d", wordSize)
}
var data [24]byte
if _, err := io.ReadFull(r, data[:2*wordSize+8]); err != nil {
return e, err
}
if wordSize == 4 {
e.Secs = int64(int32(binary.LittleEndian.Uint32(data[:4])))
e.USecs = int64(binary.LittleEndian.Uint32(data[4:8]))
} else {
e.Secs = int64(binary.LittleEndian.Uint64(data[:8]))
e.USecs = int64(binary.LittleEndian.Uint64(data[8:16]))
}
offset := 2 * wordSize
e.Type = binary.LittleEndian.Uint16(data[offset:])
e.Code = binary.LittleEndian.Uint16(data[offset+2:])
e.Value = int32(binary.LittleEndian.Uint32(data[offset+4:]))
return e, nil
}
// buttonState pairs one press with one release and ignores contact bounce.
// Access is confined to the button's event-reading goroutine.
type buttonState struct {
pressedAt, releasedAt time.Time
pressed bool
}
func (b *buttonState) press(at time.Time) {
if b.pressed || (!b.releasedAt.IsZero() && at.Sub(b.releasedAt) < 30*time.Millisecond) {
return
}
b.pressedAt, b.pressed = at, true
}
func (b *buttonState) release(at time.Time) (time.Duration, bool) {
if !b.pressed {
return 0, false
}
b.pressed = false
b.releasedAt = at
duration := at.Sub(b.pressedAt)
return duration, duration >= 0
}
+85
View File
@@ -0,0 +1,85 @@
package input
import (
"bytes"
"encoding/binary"
"errors"
"io"
"testing"
"time"
)
func TestInputEventRecordSizes(t *testing.T) {
for _, wordSize := range []int{4, 8} {
var stream bytes.Buffer
for _, value := range []int32{1, 0} {
if wordSize == 4 {
binary.Write(&stream, binary.LittleEndian, uint32(100))
binary.Write(&stream, binary.LittleEndian, uint32(950000))
} else {
binary.Write(&stream, binary.LittleEndian, uint64(100))
binary.Write(&stream, binary.LittleEndian, uint64(950000))
}
binary.Write(&stream, binary.LittleEndian, uint16(1))
binary.Write(&stream, binary.LittleEndian, uint16(28))
binary.Write(&stream, binary.LittleEndian, value)
}
for _, value := range []int32{1, 0} {
event, err := readLinuxInputEvent(&stream, wordSize)
if err != nil {
t.Fatal(err)
}
if event.Type != 1 || event.Code != 28 || event.Value != value {
t.Fatalf("wordSize=%d: misaligned event %+v", wordSize, event)
}
if !event.Time().Equal(time.Unix(100, 950000000)) {
t.Fatal("microseconds decoded incorrectly")
}
}
if _, err := readLinuxInputEvent(&stream, wordSize); !errors.Is(err, io.EOF) {
t.Fatalf("got %v, want EOF", err)
}
}
}
func TestButtonShortPressAcrossSecondBoundary(t *testing.T) {
var b buttonState
b.press((linuxInputEvent{Secs: 100, USecs: 950000}).Time())
duration, ok := b.release((linuxInputEvent{Secs: 101, USecs: 50000}).Time())
if !ok || duration != 100*time.Millisecond {
t.Fatalf("got %s, %v, want 100ms short press", duration, ok)
}
}
func TestButtonIgnoresDuplicateAndBouncedEvents(t *testing.T) {
var b buttonState
start := time.Unix(100, 0)
if _, ok := b.release(start); ok {
t.Fatal("unpaired release produced a click")
}
b.press(start)
b.press(start.Add(200 * time.Millisecond))
if duration, ok := b.release(start.Add(500 * time.Millisecond)); !ok || duration != 500*time.Millisecond {
t.Fatal("repeated press reset the long-press timer")
}
if _, ok := b.release(start.Add(501 * time.Millisecond)); ok {
t.Fatal("duplicate release produced a second click")
}
b.press(start.Add(505 * time.Millisecond))
if _, ok := b.release(start.Add(510 * time.Millisecond)); ok {
t.Fatal("contact bounce produced another click")
}
b.press(start.Add(time.Second))
if duration, ok := b.release(start.Add(1100 * time.Millisecond)); !ok || duration != 100*time.Millisecond {
t.Fatal("subsequent intentional click lost")
}
}
func TestTruncatedInputEvent(t *testing.T) {
for _, wordSize := range []int{4, 8} {
_, err := readLinuxInputEvent(bytes.NewReader(make([]byte, 2*wordSize+7)), wordSize)
if !errors.Is(err, io.ErrUnexpectedEOF) {
t.Fatalf("got %v, want unexpected EOF", err)
}
}
}
+18 -32
View File
@@ -1,13 +1,11 @@
package input package input
import ( import (
"encoding/binary"
"errors" "errors"
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"strconv"
"strings" "strings"
"time"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@@ -168,32 +166,16 @@ func linuxPheripherals() (ps []*linuxPheripheral, err error) {
return ps, nil return ps, nil
} }
type linuxInputEvent struct {
Secs uint32
USecs uint32
Type uint16
Code uint16
Value int32
}
func (e linuxInputEvent) String() string {
return fmt.Sprintf("time=%s type=%#04x code=%#04x value=%d", e.Time(), e.Type, e.Code, e.Value)
}
func (e linuxInputEvent) Time() time.Time {
return time.Unix(int64(e.Secs), int64(e.USecs))
}
func readLinuxInputEvents(name string, cb func(linuxInputEvent) error) error { func readLinuxInputEvents(name string, cb func(linuxInputEvent) error) error {
f, err := os.Open(name) f, err := os.Open(name)
if err != nil { if err != nil {
return err return err
} }
var raw linuxInputEvent defer f.Close()
for { for {
if err := binary.Read(f, binary.LittleEndian, &raw); err != nil { raw, err := readLinuxInputEvent(f, strconv.IntSize/8)
_ = f.Close() if err != nil {
return err return err
} }
if err := cb(raw); err != nil { if err := cb(raw); err != nil {
@@ -232,24 +214,28 @@ func (s *linuxButton) readEvents(events chan<- hardware.InputEvent) {
WithField("input", "button"). WithField("input", "button").
WithField("path", s.p.path) WithField("path", s.p.path)
var last time.Time var button buttonState
err := readLinuxInputEvents(s.p.path, func(ev linuxInputEvent) error { err := readLinuxInputEvents(s.p.path, func(ev linuxInputEvent) error {
if ev.Code == 0 { if ev.Type != 1 || ev.Code == 0 { // EV_KEY only; ignore synchronization events.
return nil // Ignore return nil
} }
log.WithField("data", ev).Trace("button event")
var event hardware.InputEvent var event hardware.InputEvent
switch ev.Value { switch ev.Value {
case 0: // Released case 1: // Pressed; repeated presses must not restart the timer.
if ev.Time().Sub(last) > LongPressDuration { button.press(ev.Time())
return nil
case 0: // Released.
duration, ok := button.release(ev.Time())
if !ok {
return nil
}
if duration >= LongPressDuration {
event = hardware.RotaryLongPressEvent{Time: ev.Time()} event = hardware.RotaryLongPressEvent{Time: ev.Time()}
} else { } else {
event = hardware.RotaryPressEvent{Time: ev.Time()} event = hardware.RotaryPressEvent{Time: ev.Time()}
} }
case 1: // Pressed default: // Ignore key autorepeat and unknown values.
last = ev.Time()
return nil return nil
} }
@@ -297,7 +283,7 @@ func (s *linuxRotary) readEvents(events chan<- hardware.InputEvent) {
WithField("path", s.p.path) WithField("path", s.p.path)
err := readLinuxInputEvents(s.p.path, func(ev linuxInputEvent) error { err := readLinuxInputEvents(s.p.path, func(ev linuxInputEvent) error {
if ev.Value == 0 { if ev.Type != 2 || ev.Value == 0 { // EV_REL only.
return nil // Ignore return nil // Ignore
} }
-29
View File
@@ -1,29 +0,0 @@
package mpd
import "github.com/BeatGlow/beatglow/config"
// SetAudioSource configures FIFO output monitoring before Events is called.
func (p *Player) SetAudioSource(source config.Audio) {
p.audioSource = source
}
func (p *Player) checkFIFOOutput(conn *clientConn) {
lines, err := p.sendDataCommand(conn, "outputs")
if err == nil {
err = fifoOutputState(parseOutputs(lines), p.audioSource.Output)
}
state := "enabled"
if err != nil {
state = err.Error()
}
if state == p.fifoState {
return
}
p.fifoState = state
log := conn.log().WithField("fifo", p.audioSource.Path).WithField("output", p.audioSource.Output)
if err != nil {
log.WithError(err).Warn("FIFO audio source may not receive samples")
} else {
log.Info("MPD FIFO output is enabled")
}
}
-61
View File
@@ -1,61 +0,0 @@
package mpd
import (
"fmt"
"strings"
)
type output struct {
name, plugin string
enabled bool
}
func parseOutputs(lines []string) []output {
var outputs []output
for _, line := range lines {
key, value, ok := strings.Cut(line, ": ")
if !ok {
continue
}
if key == "outputid" {
outputs = append(outputs, output{})
}
if len(outputs) == 0 {
continue
}
o := &outputs[len(outputs)-1]
switch key {
case "outputname":
o.name = value
case "plugin":
o.plugin = value
case "outputenabled":
o.enabled = value == "1"
}
}
return outputs
}
func fifoOutputState(outputs []output, name string) error {
var matches []output
for _, o := range outputs {
if name != "" {
if o.name == name && (o.plugin == "fifo" || o.plugin == "") {
matches = append(matches, o)
}
} else if o.plugin == "fifo" {
matches = append(matches, o)
}
}
switch len(matches) {
case 0:
return fmt.Errorf("no matching MPD FIFO output; check MPD configuration and audio.output")
case 1:
if !matches[0].enabled {
return fmt.Errorf("MPD FIFO output %q is disabled", matches[0].name)
}
return nil
default:
return fmt.Errorf("multiple matching MPD FIFO outputs; set audio.output to the output name")
}
}
-33
View File
@@ -1,33 +0,0 @@
package mpd
import (
"strings"
"testing"
)
func TestFIFOOutputState(t *testing.T) {
for _, tt := range []struct {
name, response, output, want string
}{
{"enabled", "outputid: 0\noutputname: DAC\nplugin: alsa\noutputenabled: 0\noutputid: 1\noutputname: Visualizer\nplugin: fifo\noutputenabled: 1", "", ""},
{"disabled", "outputid: 2\noutputname: Visualizer\nplugin: fifo\noutputenabled: 0", "", "disabled"},
{"missing", "outputid: 0\noutputname: DAC\nplugin: alsa\noutputenabled: 1", "", "no matching"},
{"ambiguous", "outputid: 1\noutputname: One\nplugin: fifo\noutputenabled: 1\noutputid: 2\noutputname: Two\nplugin: fifo\noutputenabled: 0", "", "multiple"},
{"select named disabled", "outputid: 1\noutputname: One\nplugin: fifo\noutputenabled: 1\noutputid: 2\noutputname: Two\nplugin: fifo\noutputenabled: 0", "Two", "disabled"},
{"legacy named", "outputid: 1\noutputname: Visualizer\noutputenabled: 1", "Visualizer", ""},
{"legacy unidentified", "outputid: 1\noutputname: Visualizer\noutputenabled: 1", "", "no matching"},
{"wrong plugin", "outputid: 1\noutputname: Visualizer\nplugin: alsa\noutputenabled: 1", "Visualizer", "no matching"},
{"empty", "", "", "no matching"},
} {
t.Run(tt.name, func(t *testing.T) {
err := fifoOutputState(parseOutputs(strings.Split(tt.response, "\n")), tt.output)
if tt.want == "" {
if err != nil {
t.Fatal(err)
}
} else if err == nil || !strings.Contains(err.Error(), tt.want) {
t.Fatalf("got %v, want error containing %q", err, tt.want)
}
})
}
}
-11
View File
@@ -33,8 +33,6 @@ type Player struct {
Version Version Version Version
name string name string
audioSource config.Audio
fifoState string
addr string addr string
password string password string
idleSubsystems []string idleSubsystems []string
@@ -228,10 +226,6 @@ func (p *Player) sendDataCommand(conn *clientConn, format string, args ...interf
if line == "OK" { if line == "OK" {
break break
} }
if strings.HasPrefix(line, "ACK ") {
err = textproto.ProtocolError(line)
break
}
lines = append(lines, line) lines = append(lines, line)
} }
@@ -449,7 +443,6 @@ func (p *Player) mainLoop(conn *clientConn, events chan player.Event) {
defer ticker.Stop() defer ticker.Stop()
var err error var err error
var outputCheck time.Time
loop: loop:
for { for {
select { select {
@@ -476,10 +469,6 @@ loop:
} }
case <-ticker.C: case <-ticker.C:
if p.audioSource.Type == "fifo" && time.Since(outputCheck) >= 15*time.Second {
outputCheck = time.Now()
p.checkFIFOOutput(conn)
}
var status map[string]string var status map[string]string
if status, err = p.sendMapCommand(conn, "status"); err != nil { if status, err = p.sendMapCommand(conn, "status"); err != nil {
log.WithError(err).Error("error retrieving status") log.WithError(err).Error("error retrieving status")
-2
View File
@@ -67,8 +67,6 @@ func (p *Player) Events() (<-chan player.Event, error) {
return p.mpd.Events() return p.mpd.Events()
} }
func (p *Player) SetAudioSource(source config.Audio) { p.mpd.SetAudioSource(source) }
func (p *Player) AlbumArt(t *player.Track) (image.Image, bool) { func (p *Player) AlbumArt(t *player.Track) (image.Image, bool) {
log := p.log() log := p.log()