Skip to content

Commit

Permalink
feat(subsonic): skip transcoding if request bitrate is the same as tr…
Browse files Browse the repository at this point in the history
…ack bitrate

fixes #241
  • Loading branch information
sentriz committed Sep 21, 2022
1 parent 03df207 commit f41dd08
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/ctrlsubsonic/handlers_raw.go
Expand Up @@ -264,7 +264,10 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
}()
}

if format, _ := params.Get("format"); format == "raw" {
maxBitRate, _ := params.GetInt("maxBitRate")
format, _ := params.Get("format")

if format == "raw" || maxBitRate >= file.AudioBitrate() {
http.ServeFile(w, r, audioPath)
return nil
}
Expand All @@ -282,8 +285,8 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
if !ok {
return spec.NewError(0, "unknown transcode user profile %q", pref.Profile)
}
if max, _ := params.GetInt("maxBitRate"); max > 0 && int(profile.BitRate()) > max {
profile = transcode.WithBitrate(profile, transcode.BitRate(max))
if maxBitRate > 0 && int(profile.BitRate()) > maxBitRate {
profile = transcode.WithBitrate(profile, transcode.BitRate(maxBitRate))
}

log.Printf("trancoding to %q with max bitrate %dk", profile.MIME(), profile.BitRate())
Expand Down

0 comments on commit f41dd08

Please sign in to comment.