Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
ObjcBlock restype problem.
-
using objcblock define a callback function.and need return a objc obj(<AVAudioCompressedBuffer@0x170210290: 0/12288 bytes>). but had error.
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 339, in 'converting callback result'
TypeError: cannot be converted to pointerdef conv_block(self,inNumberOfPackets,buffstat): # buffstat: 0-have data 1-no data 2-endOfStream 3-error print '@1',inNumberOfPackets,buffstat.contents.value buffstat.contents.value = 2 print '@2',inNumberOfPackets,buffstat.contents.value print inBuffer #<AVAudioPCMBuffer@0x174217ae0: 8192/8192 bytes> return inBuffer # if using return c_void_p(inBuffer) Error:cannot be converted to pointer convblock=ObjCBlock(conv_block,restype=c_void_p,argtypes=[c_void_p,c_int32,POINTER(c_long)])
-
the restype is a pointer. you have a structure. you want to return a pointer to the structure.
pointer(inBuffer)
You may need to cast(pointer(inBuffer), c_void_p)