func decode(in audio.ReadSeekCloser) (*decoded, int, int, error) {
	r, err := newDecoder(in)
	if err != nil {
		return nil, 0, 0, err
	}
	d := &decoded{
		// TODO: r.Length() returns 0 when the format is unknown.
		// Should we check that?
		totalBytes: int(r.Length()) * r.Channels() * 2, // 2 means 16bit per sample.
		posInBytes: 0,
		source:     in,
		decoder:    r,
	}
	runtime.SetFinalizer(d, (*decoded).Close)
	if _, err := d.Read(make([]byte, 65536)); err != nil && err != io.EOF {
		return nil, 0, 0, err
	}
	if _, err := d.Seek(0, io.SeekStart); err != nil {
		return nil, 0, 0, err
	}
	return d, r.Channels(), r.SampleRate(), nil
}
func decode(in audio.ReadSeekCloser) (*decoded, int, int, error) {
	r, err := newDecoder(in)
	if err != nil {
		return nil, 0, 0, err
	}
	d := &decoded{
		
		
		totalBytes: int(r.Length()) * r.Channels() * 2, 
		posInBytes: 0,
		source:     in,
		decoder:    r,
	}
	runtime.SetFinalizer(d, (*decoded).Close)
	if _, err := d.Read(make([]byte, 65536)); err != nil && err != io.EOF {
		return nil, 0, 0, err
	}
	if _, err := d.Seek(0, io.SeekStart); err != nil {
		return nil, 0, 0, err
	}
	return d, r.Channels(), r.SampleRate(), nil
}
func decode ( in audio . ReadSeekCloser ) ( * decoded , int , int , error ) { r , err := newDecoder ( in ) if err != nil { return nil , 0 , 0 , err } d := & decoded { // TODO: r.Length() returns 0 when the format is unknown. // Should we check that? totalBytes : int ( r . Length ( ) ) * r . Channels ( ) * 2 , // 2 means 16bit per sample. posInBytes : 0 , source : in , decoder : r , } runtime . SetFinalizer ( d , ( * decoded ) . Close ) if _ , err := d . Read ( make ( [ ] byte , 65536 ) ) ; err != nil && err != io . EOF { return nil , 0 , 0 , err } if _ , err := d . Seek ( 0 , io . SeekStart ) ; err != nil { return nil , 0 , 0 , err } return d , r . Channels ( ) , r . SampleRate ( ) , nil }
// decode accepts an ogg stream and returns a decorded stream.
decode accepts an ogg stream and returns a decorded stream .