Example #1
0
// Close closes the ExtAudioFile and releases the reference to it.
func (eaf *ExtAudioFile) Close() error {
	if eaf.ceaf == nil {
		return nil
	}
	stat := C.ExtAudioFileDispose(eaf.ceaf)
	eaf.ceaf = nil
	eaf.af = nil
	runtime.SetFinalizer(eaf, nil)
	return osStatus(stat)
}
Example #2
0
// ExtAudioFile returns a ExtAudioFile that wraps the CoreAudio AudioFile
func (af *AudioFile) ExtAudioFile() (*ExtAudioFile, error) {
	var eaf = ExtAudioFile{af: af}
	stat := C.ExtAudioFileWrapAudioFileID(af.id, 1, &eaf.ceaf)
	if stat != 0 {
		return nil, osStatus(stat)
	}
	runtime.SetFinalizer(&eaf, func(eaf *ExtAudioFile) {
		if eaf.ceaf != nil {
			C.ExtAudioFileDispose(eaf.ceaf)
		}
	})
	return &eaf, nil
}