Fix libopus decoding, optimize vorbis nocgo decoding allocations
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
713602c748
commit
439ad19af8
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.gammaspectra.live/S.O.N.G/Kirika/audio/filter"
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio/filter"
|
||||||
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format"
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format"
|
||||||
libopus "git.gammaspectra.live/S.O.N.G/go-pus"
|
libopus "git.gammaspectra.live/S.O.N.G/go-pus"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -68,7 +69,7 @@ func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
source.IngestFloat32(buf[:n*channelCount])
|
source.IngestFloat32(slices.Clone(buf[:n*channelCount]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"git.gammaspectra.live/S.O.N.G/Kirika/audio"
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio"
|
||||||
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format"
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format"
|
||||||
libvorbis "github.com/jfreymuth/oggvorbis"
|
libvorbis "github.com/jfreymuth/oggvorbis"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,9 +37,9 @@ func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||||
go func() {
|
go func() {
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
||||||
for {
|
buffer := make([]float32, 8192)
|
||||||
|
|
||||||
buffer := make([]float32, 8192)
|
for {
|
||||||
|
|
||||||
n, err := reader.Read(buffer)
|
n, err := reader.Read(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,7 +47,7 @@ func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
source.IngestFloat32(buffer[:n])
|
source.IngestFloat32(slices.Clone(buffer[:n]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in a new issue