From 92541a6f4ec251683a137fe95f20fdc1aeee53e0 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Mon, 3 Oct 2022 15:25:40 +0200 Subject: [PATCH] Revert test function inline, added special case for two channels on shared.go --- audio/replaygain/normalization_test.go | 26 ++++++++++++-------------- vector/audio_nocgo.go | 10 +++++++--- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/audio/replaygain/normalization_test.go b/audio/replaygain/normalization_test.go index 331bbba..ccccd6b 100644 --- a/audio/replaygain/normalization_test.go +++ b/audio/replaygain/normalization_test.go @@ -114,22 +114,20 @@ func TestAlbumReplayGain(t *testing.T) { t.Error(err) return } - func() { - defer fp.Close() - decoders, err := guess.GetDecoders(fp, fullPath) - if err != nil { - t.Error(err) - return - } - source, err := guess.Open(fp, decoders) - if err != nil { - t.Error(err) - return - } - sources = append(sources, source) - }() + defer fp.Close() + decoders, err := guess.GetDecoders(fp, fullPath) + if err != nil { + t.Error(err) + return + } + source, err := guess.Open(fp, decoders) + if err != nil { + t.Error(err) + return + } + sources = append(sources, source) } } diff --git a/vector/audio_nocgo.go b/vector/audio_nocgo.go index d3f5688..83d005c 100644 --- a/vector/audio_nocgo.go +++ b/vector/audio_nocgo.go @@ -30,7 +30,9 @@ func MultipleChannelsToMonoFloat32(buffer []float32, channels int) (buf []float3 // MultipleChannelsToStereoFloat32 bring any number of channels to stereo, using downmix formulas when necessary func MultipleChannelsToStereoFloat32(buffer []float32, channels int) (buf []float32) { - buf = make([]float32, (len(buffer)/channels)*2) + if channels != 2 { + buf = make([]float32, (len(buffer)/channels)*2) + } var samples int surroundMix := 1 / float32(math.Sqrt(2)) @@ -107,7 +109,9 @@ func MultipleChannelsToMonoInt32(buffer []int32, channels int) (buf []int32) { // MultipleChannelsToStereoInt32 bring any number of channels to stereo, using downmix formulas when necessary func MultipleChannelsToStereoInt32(buffer []int32, channels int) (buf []int32) { - buf = make([]int32, (len(buffer)/channels)*2) + if channels != 2 { + buf = make([]int32, (len(buffer)/channels)*2) + } var samples int surroundMix := 1 / float32(math.Sqrt(2)) @@ -120,7 +124,7 @@ func MultipleChannelsToStereoInt32(buffer []int32, channels int) (buf []int32) { } break case 2: //copy - return slices.Clone(buffer) + buf = slices.Clone(buffer) break case 3: //2.1, FL, FR, LFE for i := 0; i < len(buffer); i += 3 {