Sure,
#!/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 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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.