audio: Comment about ownership

This behavior might be changed at version 2 though (#837).
This commit is contained in:
Hajime Hoshi 2019-04-01 01:32:11 +09:00
parent 200c3b80a9
commit df2604c221
3 changed files with 6 additions and 0 deletions

View File

@ -77,6 +77,8 @@ func (s *Stream) Size() int64 {
// Decode returns error when decoding fails or IO error happens.
//
// Decode automatically resamples the stream to fit with the audio context if necessary.
//
// Decode takes the ownership of src, and Stream's Close function closes src.
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
d, err := mp3.NewDecoder(src)
if err != nil {

View File

@ -169,6 +169,8 @@ func decode(in audio.ReadSeekCloser) (*decoded, int, int, error) {
// Decode returns error when decoding fails or IO error happens.
//
// Decode automatically resamples the stream to fit with the audio context if necessary.
//
// Decode takes the ownership of src, and Stream's Close function closes src.
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
decoded, channelNum, sampleRate, err := decode(src)
if err != nil {

View File

@ -124,6 +124,8 @@ func (s *stream) Length() int64 {
// Decode returns error when decoding fails or IO error happens.
//
// Decode automatically resamples the stream to fit with the audio context if necessary.
//
// Decode takes the ownership of src, and Stream's Close function closes src.
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
buf := make([]byte, 12)
n, err := io.ReadFull(src, buf)