Example #1
0
func (ke keychainError) Error() string {
	errorMessageCFString := C.SecCopyErrorMessageString(C.OSStatus(ke), nil)
	defer C.CFRelease(C.CFTypeRef(errorMessageCFString))

	errorMessageCString := C.CFStringGetCStringPtr(errorMessageCFString, C.kCFStringEncodingASCII)

	if errorMessageCString != nil {
		return C.GoString(errorMessageCString)
	}

	return fmt.Sprintf("keychainError with unknown error code %d", C.OSStatus(ke))
}
Example #2
0
//export go_audiofile_readproc
func go_audiofile_readproc(data unsafe.Pointer, inPosition C.SInt64, requestCount C.UInt32, buffer unsafe.Pointer, actualCount *C.UInt32) C.OSStatus {
	af := (*AudioFile)(data)
	length := int(requestCount)
	hdr := reflect.SliceHeader{
		Data: uintptr(buffer),
		Len:  length,
		Cap:  length,
	}
	bslice := *(*[]byte)(unsafe.Pointer(&hdr))
	n, err := af.target.ReadAt(bslice, int64(inPosition))
	*actualCount = C.UInt32(n)
	if err == io.EOF {
		return C.kAudioFileEndOfFileError
	} else if err != nil {
		return C.kAudioFileUnspecifiedError
	}
	return C.OSStatus(0)
}
Example #3
0
//export go_audiofile_writeproc
func go_audiofile_writeproc(data unsafe.Pointer, inPosition C.SInt64, requestCount C.UInt32, buffer unsafe.Pointer, actualCount *C.UInt32) C.OSStatus {
	af := (*AudioFile)(data)
	length := int(requestCount)
	hdr := reflect.SliceHeader{
		Data: uintptr(buffer),
		Len:  length,
		Cap:  length,
	}
	bslice := *(*[]byte)(unsafe.Pointer(&hdr))
	npos := int64(inPosition)

	n, err := af.target.WriteAt(bslice, npos)
	*actualCount = C.UInt32(n)
	if err != nil {
		return C.kAudioFileUnspecifiedError
	}
	if npos+int64(n) > af.fileSize {
		af.fileSize = npos + int64(n)
	}

	return C.OSStatus(0)
}