in reply to XS callback to mpv_set_wakeup_callback
I suspect your problem lies in some random foreign thread calling the callback. The dTHX macro in your callback function expands (depending on platform and configuration) to something like
This means that it attempts to set the current interpreter (my_perl) to whatever value is stored in thread-local storage for that thread. For a perl thread, that value will point to the interpreter associated with that thread. For a foreign thread, it's likely to be NULL.PerlInterpreter* my_perl = pthread_getspecific(PL_thr_key);
The question is, if a foreign thread calls the callback, what interpreter structure should it use? Once you have decided that, then you'll need to do
at some point. See perlguts and perlembed.PERL_SET_CONTEXT(some_perl);
The question of what interpreter to use depends on your setup - how threads are created and managed - but in any case, you need to avoid two separate threads sharing the same interpreter.
Dave.
In Section
Seekers of Perl Wisdom