Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: XS callback to mpv_set_wakeup_callback

by MaxPerl (Acolyte)
on Jan 05, 2019 at 06:49 UTC ( [id://1228067]=note: print w/replies, xml ) Need Help??


in reply to Re^2: XS callback to mpv_set_wakeup_callback
in thread XS callback to mpv_set_wakeup_callback

Ok, I found https://www.perlmonks.org/?node_id=867652 and without studying the thread in depth, I tried the following and it seems to work so far:
first ein deleteted #define PERL_NO_GET_CONTEXT in the beginning of my Simple.xs file. then I created a set_ctx function
void set_ctx() { dTHX; mine = Perl_get_context; } (...) MODULE = MPV::Simple PACKAGE = MPV::Simple (...) void _set_context(ctx) MPV::Simple ctx CODE: set_ctx();
and called it in the constructor in Simple.pm
sub new { my ($class) = shift; my $obj = $class->xs_create(); bless $obj; $obj->_set_context(); return $obj; }
Last I set Perl_Context in callp instead of dTHX:
void callp( SV* data) { //dTHX; PERL_SET_CONTEXT(mine); { dMY_CXT; dSP; ENTER; SAVETMPS; PUSHMARK(SP); PUTBACK; perl_call_sv(MY_CXT.callback,G_DISCARD|G_NOARGS); SPAGAIN; PUTBACK;FREETMPS;LEAVE; } }
Does that make any sense? Or is it ugly and bad? To be honest, I don't really understand the linked thread :-) And I am a little bit worried because of deleting PERL_NO_GET_CONTEXT.. I have to do further tests, whether the binding now works as expected.. Max

UPDATE: Unfortunately this doesn't work, too. Sometimes it seems to work and the video is shown. But in other cases there is again the segfault or the thread is closed too early.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-23 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found