diff --git a/pkg/io/broadcast_test.go b/pkg/io/broadcast_test.go index 5d14df5..01fefb9 100644 --- a/pkg/io/broadcast_test.go +++ b/pkg/io/broadcast_test.go @@ -107,12 +107,14 @@ func TestBroadcast(t *testing.T) { fps := float64(count) / duration.Seconds() if fps < pauseCond.expectedFPS-2 || fps > pauseCond.expectedFPS+2 { - t.Fatal("Unexpected average FPS") + t.Error("Unexpected average FPS") + return } droppedFramesPerSecond := float64(droppedFrames) / duration.Seconds() if droppedFramesPerSecond < pauseCond.expectedDrop-2 || droppedFramesPerSecond > pauseCond.expectedDrop+2 { - t.Fatal("Unexpected drop count") + t.Error("Unexpected drop count") + return } fpsChan <- []float64{fps, droppedFramesPerSecond, float64(lastFrameCount)} diff --git a/pkg/wave/decoder.go b/pkg/wave/decoder.go index 6861e35..79773ec 100644 --- a/pkg/wave/decoder.go +++ b/pkg/wave/decoder.go @@ -144,9 +144,11 @@ func newInt16InterleavedDecoder() (Decoder, Format) { container := NewInt16Interleaved(chunkInfo) if endian == hostEndian { + data := container.Data + dst := *(*[]byte)(unsafe.Pointer(&data)) + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) n := len(chunk) - h := reflect.SliceHeader{Data: uintptr(unsafe.Pointer(&container.Data[0])), Len: n, Cap: n} - dst := *(*[]byte)(unsafe.Pointer(&h)) + hdr.Len, hdr.Cap = n, n copy(dst, chunk) return container, nil } @@ -188,9 +190,11 @@ func newInt16NonInterleavedDecoder() (Decoder, Format) { if endian == hostEndian { for ch := 0; ch < channels; ch++ { + data := container.Data[ch] + dst := *(*[]byte)(unsafe.Pointer(&data)) + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + hdr.Len, hdr.Cap = chunkLen, chunkLen offset := ch * chunkLen - h := reflect.SliceHeader{Data: uintptr(unsafe.Pointer(&container.Data[ch][0])), Len: chunkLen, Cap: chunkLen} - dst := *(*[]byte)(unsafe.Pointer(&h)) copy(dst, chunk[offset:offset+chunkLen]) } return container, nil @@ -228,9 +232,11 @@ func newFloat32InterleavedDecoder() (Decoder, Format) { container := NewFloat32Interleaved(chunkInfo) if endian == hostEndian { + data := container.Data + dst := *(*[]byte)(unsafe.Pointer(&data)) + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) n := len(chunk) - h := reflect.SliceHeader{Data: uintptr(unsafe.Pointer(&container.Data[0])), Len: n, Cap: n} - dst := *(*[]byte)(unsafe.Pointer(&h)) + hdr.Len, hdr.Cap = n, n copy(dst, chunk) return container, nil } @@ -272,9 +278,11 @@ func newFloat32NonInterleavedDecoder() (Decoder, Format) { if endian == hostEndian { for ch := 0; ch < channels; ch++ { + data := container.Data[ch] + dst := *(*[]byte)(unsafe.Pointer(&data)) + hdr := (*reflect.SliceHeader)(unsafe.Pointer(&dst)) + hdr.Len, hdr.Cap = chunkLen, chunkLen offset := ch * chunkLen - h := reflect.SliceHeader{Data: uintptr(unsafe.Pointer(&container.Data[ch][0])), Len: chunkLen, Cap: chunkLen} - dst := *(*[]byte)(unsafe.Pointer(&h)) copy(dst, chunk[offset:offset+chunkLen]) } return container, nil