TarsosDSP icon indicating copy to clipboard operation
TarsosDSP copied to clipboard

AudioDispatcher stop variable volatile

Open stremlau opened this issue 8 years ago • 2 comments

What is the correct way to stop the dispatcher? I run it in a separate thread and call stop(), but the stop variable is not volatile.

https://github.com/JorenSix/TarsosDSP/blob/master/src/core/be/tarsos/dsp/AudioDispatcher.java#L120 Is it possible to add the volatile modifier? Or is there another way to do it?

stremlau avatar Jun 12 '16 21:06 stremlau

The same question. When I called stop() method the program got crash. How can I fix it?

hoangdado avatar Oct 09 '16 15:10 hoangdado

Hello, I had the same challenge. But i resolved it through using the try catch: try { if (!dispatcher.isStopped()) { dispatcher.stop(); } } catch (Exception ex) { Toast.makeText(Scanning_Page.this, "Error: " + ex, Toast.LENGTH_LONG).show(); }

Instead of: // new Thread(dispatcher, "Audio Dispatcher").stop();

And it works well for me

wilberninsiima avatar Jan 28 '17 16:01 wilberninsiima