code: public void restart() {
          sync.lock();
  
          try {
  
              stop();
              Thread.sleep(1000); // allow some time to release native resources
              start();
  
          } catch (InterruptedException e) {
              // ignore
          } finally {
              sync.unlock();
          }
      }
docs: This method blocks for at least a second plus the time
  needed to destroy the native session, don't call it from the UI thread.