Skip to content

Commit

Permalink
delete guess expected size feature
Browse files Browse the repository at this point in the history
it it doing some really bad guesses for opus files
  • Loading branch information
sentriz committed Apr 20, 2022
1 parent 4658d07 commit 6bebcec
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 526 deletions.
23 changes: 0 additions & 23 deletions iout/copy_range.go

This file was deleted.

42 changes: 0 additions & 42 deletions iout/copy_range_test.go

This file was deleted.

46 changes: 0 additions & 46 deletions iout/countrw.go

This file was deleted.

18 changes: 0 additions & 18 deletions iout/null_reader.go

This file was deleted.

28 changes: 0 additions & 28 deletions iout/tee_closer.go

This file was deleted.

5 changes: 3 additions & 2 deletions server/ctrlsubsonic/ctrl_test.go
@@ -1,3 +1,4 @@
//nolint:deadcode
package ctrlsubsonic

import (
Expand All @@ -16,10 +17,10 @@ import (

jd "github.com/josephburnett/jd/lib"

"go.senan.xyz/gonic/server/ctrlbase"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/mockfs"
"go.senan.xyz/gonic/server/ctrlbase"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/transcode"
)

Expand Down
27 changes: 3 additions & 24 deletions server/ctrlsubsonic/handlers_raw.go
Expand Up @@ -12,12 +12,10 @@ import (
"github.com/disintegration/imaging"
"github.com/jinzhu/gorm"

"go.senan.xyz/gonic/iout"
"go.senan.xyz/gonic/server/ctrlsubsonic/httprange"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/transcode"
)

Expand Down Expand Up @@ -296,30 +294,11 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R

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

transcodeReader, err := c.Transcoder.Transcode(r.Context(), profile, audioPath)
if err != nil {
return spec.NewError(0, "error transcoding: %v", err)
}
defer transcodeReader.Close()

length := transcode.GuessExpectedSize(profile, time.Duration(file.AudioLength())*time.Second) // TODO: if there's no duration?
rreq, err := httprange.Parse(r.Header.Get("Range"), length)
if err != nil {
return spec.NewError(0, "error parsing range: %v", err)
}

w.Header().Set("Content-Type", profile.MIME())
w.Header().Set("Content-Length", fmt.Sprintf("%d", rreq.Length))
w.Header().Set("Accept-Ranges", string(httprange.UnitBytes))

if rreq.Partial {
w.WriteHeader(http.StatusPartialContent)
w.Header().Set("Content-Range", fmt.Sprintf("%s %d-%d/%d", httprange.UnitBytes, rreq.Start, rreq.End, length))
if err := c.Transcoder.Transcode(r.Context(), profile, audioPath, w); err != nil {
return spec.NewError(0, "error transcoding: %v", err)
}

if err := iout.CopyRange(w, transcodeReader, int64(rreq.Start), int64(rreq.Length)); err != nil {
log.Printf("error writing transcoded data: %v", err)
}
if f, ok := w.(http.Flusher); ok {
f.Flush()
}
Expand Down
152 changes: 0 additions & 152 deletions server/ctrlsubsonic/handlers_raw_test.go

This file was deleted.

0 comments on commit 6bebcec

Please sign in to comment.