I've further narrowed it down to not reading from the variables is what crashes it, but the "sv_setpvn" that _writes_ to the perl variable is what doesn't work. I verified this by adding a sv_setpvn (intbundle->isv, "foo", 3); to it, which also caused it to crash with the "access violation reading..." error.#!/ASPerl/bin/perl use strict; use Inline 'INFO'; use Inline (C => 'DATA', DIRECTORY => '/tmp', FORCE_BUILD => 1, CLEAN_AFTER_BUILD => 1, CCFLAGS => '-GF -MDd -Zi /W3 -DWIN32 -D_CONSOLE -DNO_STRICT -D +_DEBUG' . ' -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_ +SYS' . ' -DUSE_PERLIO -DPERL_MSVCRT_READFIX', LIBS => 'winmm.lib PAStaticWMMED.lib', ); sub my_simpcb { my $in = shift; my $out = $in; return $out; } registercb (\&my_simpcb); portinit (44100, 256); portstart (); pasleep (3000); portstop (); portclose (); exit (0); __DATA__ __C__ #include <portaudio.h> #include <memory.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> static int pacback (void *, void *, unsigned long, PaTimestamp, void * +); static PortAudioStream *pa_stream; typedef struct { SV *isv; SV *cbfn; int runcount; } mybundle; mybundle bundle; void portinit (double sps, int buflen) { bundle.isv = newSVpvn (NULL, buflen); sv_setpvn (bundle.isv, "foo", 3); Pa_Initialize (); Pa_OpenDefaultStream (&pa_stream, 1, 1, paUInt8, sps, buflen, 0, pacback, &bundle); } void registercb (SV *cbfname) { bundle.cbfn = newSVsv (cbfname); } SV * whatiscb () { return bundle.cbfn; } void pasleep (int milisec) { Pa_Sleep (milisec); } void portstart () { bundle.runcount = 0; Pa_StartStream (pa_stream); } void portstop () { warn ("runcount == %d\n", bundle.runcount); Pa_StopStream (pa_stream); } void portclose () { Pa_CloseStream (pa_stream); Pa_Terminate (); } static int pacback (void *invoid, void *outvoid, unsigned long nsamps, PaTimestamp outTime, void *user) { mybundle *intbundle = (mybundle *)user; intbundle->runcount += nsamps; if (!invoid) return 0; sv_setpvn (intbundle->isv, (unsigned char *) invoid, nsamps); memcpy ((unsigned char *)outvoid, (unsigned char *)invoid, nsamps) +; return 0; }
I've uploaded the portaudio libraries I link against as well as winmm.lib (which is from the platform sdk) to http://web.mit.edu/fustflum/etcetera/portaudio, incase you care to look.
Thanks for any insights you might have.
In reply to Re^6: perl->c->perl (Inline::C)
by jpollack
in thread perl->c->perl
by jpollack
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |