how to convert pymedia.audio.acodec ACString to ctypes.c_char_p
sanket
sanket.s.patel at gmail.com
Fri Dec 19 17:01:40 EST 2008
Hello All Experts,
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.
# /*********
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
# *************/
I am getting error while converting r.data (which is ACstring object)
in to ctypes.c_char_p.
can you help me solving this problem?
any help would be appericiated,
Thank you,
sanket
More information about the Python-list
mailing list