Fix libopus decoding, optimize vorbis nocgo decoding allocations
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2023-01-29 14:21:11 +01:00
parent 713602c748
commit 439ad19af8
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
2 changed files with 6 additions and 4 deletions

View file

@ -10,6 +10,7 @@ import (
"git.gammaspectra.live/S.O.N.G/Kirika/audio/filter"
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format"
libopus "git.gammaspectra.live/S.O.N.G/go-pus"
"golang.org/x/exp/slices"
"io"
"time"
)
@ -68,7 +69,7 @@ func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
}
if n > 0 {
source.IngestFloat32(buf[:n*channelCount])
source.IngestFloat32(slices.Clone(buf[:n*channelCount]))
}
}
}()

View file

@ -7,6 +7,7 @@ import (
"git.gammaspectra.live/S.O.N.G/Kirika/audio"
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format"
libvorbis "github.com/jfreymuth/oggvorbis"
"golang.org/x/exp/slices"
"io"
)
@ -36,9 +37,9 @@ func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
go func() {
defer source.Close()
for {
buffer := make([]float32, 8192)
buffer := make([]float32, 8192)
for {
n, err := reader.Read(buffer)
if err != nil {
@ -46,7 +47,7 @@ func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
}
if n > 0 {
source.IngestFloat32(buffer[:n])
source.IngestFloat32(slices.Clone(buffer[:n]))
}
}
}()