javascriptpluginsfirebreathportaudio

Error calling method on NPObject! in JavaScript


I've got some Visual C++ code (FireBreath) that wants to open a stream using PortAudio. After having done all the initial operations, I have this code:

err = Pa_OpenStream( &stream, &parametriIngresso, &parametriUscita, SAMPLE_RATE, FRAMES_PER_BUFFER, 0, My_Callback, &myData);
err = Pa_StartStream(stream);

while( ( err = Pa_IsStreamActive( stream ) ) == 1 )
    {
        Pa_Sleep(1000);
    }

err = Pa_CloseStream(stream);

This function is called from JavaScript, and after a certain number of seconds the plugin crashes giving me a Error calling method on NPObject! error on the line where it's called from in the JavaScript.


Solution

  • This is a problem of thread. Thread principal is busy for more time from plugin and since Javascript is single-threading, it crash. The solution is create the new thread.