diff --git a/.gitignore b/.gitignore index 270e6a5..622170c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,15 @@ vendor/ .DS_Store Thumbs.db +# Dev config (has local paths — use config.yaml.example as template) +config.yaml + # Config with secrets config.local.yaml + +# Portable Winamp (extracted locally for dev — not committed) +winamp/ + +# Runtime data files +killist.dat +resume.dat diff --git a/internal/server/server.go b/internal/server/server.go index e12d372..33b574e 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -266,8 +266,13 @@ func (s *Server) statusMsg() ([]byte, error) { msg.State = "stopped" } msg.Title = s.wa.GetTitle() - msg.Position = s.wa.GetPosition() - msg.Length = s.wa.GetLength() + // Winamp returns 0xFFFFFFFF when stopped/no track — clamp to 0. + pos := s.wa.GetPosition() + length := s.wa.GetLength() + if pos > 86400 { pos = 0 } // > 24h → garbage value + if length > 86400 { length = 0 } + msg.Position = pos + msg.Length = length msg.PlaylistPos = s.wa.GetPlaylistPosition() msg.PlaylistLength = s.wa.GetPlaylistLength() msg.Version = s.wa.GetVersion() diff --git a/internal/viz/capture.go b/internal/viz/capture.go index a0c9870..98efb61 100644 --- a/internal/viz/capture.go +++ b/internal/viz/capture.go @@ -72,11 +72,21 @@ type waveFormatEx struct { Size uint16 } +// waveFormatExtensibleEx is a flat representation of WAVEFORMATEXTENSIBLE. +// We cannot embed waveFormatEx because Go pads the struct to 20 bytes +// (alignment of largest field = uint32), but the C layout is 18 bytes — +// so SubFormat would land at the wrong offset if we used struct embedding. type waveFormatExtensibleEx struct { - Format waveFormatEx - Samples uint16 - ChannelMask uint32 - SubFormat windows.GUID + FormatTag uint16 + Channels uint16 + SamplesPerSec uint32 + AvgBytesPerSec uint32 + BlockAlign uint16 + BitsPerSample uint16 + Size uint16 + Samples uint16 // wValidBitsPerSample / wSamplesPerBlock + ChannelMask uint32 + SubFormat windows.GUID // 16 bytes → total 40 bytes, matches C layout } // ── DLL procs ─────────────────────────────────────────────────────────────────