예제 #1
0
파일: mpg123.go 프로젝트: Wessie/audec
// NewDecoder returns a new decoder to be used for decoding mp3 audio data
//
// The Close method should be called when finished with the decoder so as to
// not leak resources.
func NewDecoder(r io.Reader) (*Decoder, error) {
	var e C.int
	mh := C.mpg123_new(nil, &e)
	if mh == nil || e != 0 {
		return nil, toError(e)
	}

	err := toError(C.mpg123_open_feed(mh))
	if err != nil {
		return nil, err
	}

	C.mpg123_format_none(mh)
	C.mpg123_format(mh, 44100, C.MPG123_STEREO, C.MPG123_ENC_FLOAT_32)

	buf := make([]byte, ReadBufferSize)
	return &Decoder{mh: mh, src: r, buf: buf}, nil
}
예제 #2
0
// Disable all decoder output formats. Use before specifying supported formats
func (d *Decoder) FormatNone() {
	C.mpg123_format_none(d.handle)
}