Skip to content

Commit

Permalink
add option to configure queue size
Browse files Browse the repository at this point in the history
  • Loading branch information
stkw0 committed Sep 29, 2024
1 parent b6a082d commit a4a7f31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func StartupApp(appName, displayAppName, appVersionTag, latestReleaseURL string)
}

a.ServerManager = NewServerManager(appName, a.Config, !portableMode /*use keyring*/)
a.PlaybackManager = NewPlaybackManager(a.bgrndCtx, a.ServerManager, a.LocalPlayer, &a.Config.Scrobbling, &a.Config.Transcoding)
a.PlaybackManager = NewPlaybackManager(a.bgrndCtx, a.ServerManager, a.LocalPlayer, &a.Config.Scrobbling, &a.Config.Transcoding, &a.Config.Application)
a.ImageManager = NewImageManager(a.bgrndCtx, a.ServerManager, cacheDir)
a.Config.Application.MaxImageCacheSizeMB = clamp(a.Config.Application.MaxImageCacheSizeMB, 1, 500)
a.ImageManager.SetMaxOnDiskCacheSizeBytes(int64(a.Config.Application.MaxImageCacheSizeMB) * 1_048_576)
Expand Down
2 changes: 2 additions & 0 deletions backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type AppConfig struct {
ShowTrackChangeNotification bool
EnableLrcLib bool
SkipSSLVerify bool
QueueSize int

// Experimental - may be removed in future
FontNormalTTF string
Expand Down Expand Up @@ -173,6 +174,7 @@ func DefaultConfig(appVersionTag string) *Config {
ShowTrackChangeNotification: false,
EnableLrcLib: true,
SkipSSLVerify: false,
QueueSize: 100,
},
AlbumPage: AlbumPageConfig{
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
Expand Down
7 changes: 5 additions & 2 deletions backend/playbackmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type PlaybackManager struct {
engine *playbackEngine
cmdQueue *playbackCommandQueue
cfg *AppConfig
}

func NewPlaybackManager(
Expand All @@ -22,12 +23,14 @@ func NewPlaybackManager(
p player.BasePlayer,
scrobbleCfg *ScrobbleConfig,
transcodeCfg *TranscodingConfig,
appCfg *AppConfig,
) *PlaybackManager {
e := NewPlaybackEngine(ctx, s, p, scrobbleCfg, transcodeCfg)
q := NewCommandQueue()
pm := &PlaybackManager{
engine: e,
cmdQueue: q,
cfg: appCfg,
}
go pm.runCmdQueue(ctx)
return pm
Expand Down Expand Up @@ -231,13 +234,13 @@ func (p *PlaybackManager) PlayTrackAt(idx int) {

func (p *PlaybackManager) PlayRandomSongs(genreName string) {
p.fetchAndPlayTracks(func() ([]*mediaprovider.Track, error) {
return p.engine.sm.Server.GetRandomTracks(genreName, 100)
return p.engine.sm.Server.GetRandomTracks(genreName, p.cfg.QueueSize)
})
}

func (p *PlaybackManager) PlaySimilarSongs(id string) {
p.fetchAndPlayTracks(func() ([]*mediaprovider.Track, error) {
return p.engine.sm.Server.GetSimilarTracks(id, 100)
return p.engine.sm.Server.GetSimilarTracks(id, p.cfg.QueueSize)
})
}

Expand Down

0 comments on commit a4a7f31

Please sign in to comment.