public synchronized void stopSong() { terminate = true; if (thread == null) return; try { thread.join(); } catch (InterruptedException e) { } thread = null; track.stop(); MS98NativeInterface.ms98Close(); PMDWinNativeInterface.pmdwinClose(); // nm.cancel(NID_PMD_PLAYING); stopForeground(true); }
public void run() { while (!terminate) { try { int ret = MS98NativeInterface.ms98Render(buffer, buffer.length); if (ret == 0) { track.stop(); Log.d(TAG, "stream terminated"); MS98NativeInterface.ms98Close(); break; } track.write(buffer, 0, buffer.length); Thread.sleep(WAIT_PER_BLOCK); } catch (InterruptedException e) { // thru } } }