I am quite new to Ctypes. I am using one c library and writing python
bindings for it.
I need to pass a character pointer to one function.
I am reading one mp3 file and decoding it to raw pcm using pymedia.
Now I need to pass this raw data in to a
C function. Here is my code.
Expand|Select|Wrap|Line Numbers
- # /*********
- from ctypes import *
- import pymedia.audio.acodec as codec
- dec = None
- dm = muxer.Demuxer('mp3')
- fp = open('test.mp3', 'rb')
- fingerprinting_done = False
- while not fingerprinting_done:
- s = fp.read(20000)
- frames = dm.parse(s)
- for fr in frames:
- if dec == None:
- dec = codec.Decoder(dm.streams[0])
- r = dec.Decode(fr[1])
- if r and r.data:
- # pass this r.data to the C function.
- # r.data is ACString object
- # I cannot do pcm_audio = c_char_p(r.data) . gives me following error
- # TypeError: string or integer address expected instead of ACString
- # instance
- # *************/
in to ctypes.c_char_p.
can you help me solving this problem?
any help would be appericiated,
Thank you,
sanket