how to convert pymedia.audio.acodec ACString to ctypes.c_char_p

S

sanket

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top