From 322ad99568389991e8d28a5af7aa8e2a603357e1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 4 May 2024 17:30:15 +0900 Subject: [PATCH] audio/mp3, audio/vorbis, audio/wav: add comments about cache --- audio/mp3/decode.go | 3 +++ audio/vorbis/vorbis.go | 3 +++ audio/wav/decode.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/audio/mp3/decode.go b/audio/mp3/decode.go index 4d43d8b63..05c7a177c 100644 --- a/audio/mp3/decode.go +++ b/audio/mp3/decode.go @@ -87,6 +87,9 @@ func DecodeWithoutResampling(src io.Reader) (*Stream, error) { // // A Stream doesn't close src even if src implements io.Closer. // Closing the source is src owner's responsibility. +// +// Resampling can be a very heavy task. Stream has a cache for resampling, but the size is limited. +// Do not expect that Stream has a resampling cache even after whole data is played. func DecodeWithSampleRate(sampleRate int, src io.Reader) (*Stream, error) { d, err := mp3.NewDecoder(src) if err != nil { diff --git a/audio/vorbis/vorbis.go b/audio/vorbis/vorbis.go index 63cf13ee1..71381ab9d 100644 --- a/audio/vorbis/vorbis.go +++ b/audio/vorbis/vorbis.go @@ -182,6 +182,9 @@ func DecodeWithoutResampling(src io.Reader) (*Stream, error) { // // A Stream doesn't close src even if src implements io.Closer. // Closing the source is src owner's responsibility. +// +// Resampling can be a very heavy task. Stream has a cache for resampling, but the size is limited. +// Do not expect that Stream has a resampling cache even after whole data is played. func DecodeWithSampleRate(sampleRate int, src io.Reader) (*Stream, error) { decoded, channelCount, origSampleRate, err := decode(src) if err != nil { diff --git a/audio/wav/decode.go b/audio/wav/decode.go index 1dc0489b3..abd8593b7 100644 --- a/audio/wav/decode.go +++ b/audio/wav/decode.go @@ -134,6 +134,9 @@ func DecodeWithoutResampling(src io.Reader) (*Stream, error) { // // A Stream doesn't close src even if src implements io.Closer. // Closing the source is src owner's responsibility. +// +// Resampling can be a very heavy task. Stream has a cache for resampling, but the size is limited. +// Do not expect that Stream has a resampling cache even after whole data is played. func DecodeWithSampleRate(sampleRate int, src io.Reader) (*Stream, error) { s, origSampleRate, err := decode(src) if err != nil {