<NME> VisualizerWrapper.java
<BEF> package com.cleveroad.audiovisualization;

import android.media.audiofx.Visualizer;
import android.support.annotation.NonNull;

/**
 * Wrapper for visualizer.
/**
 * Wrapper for visualizer.
 */
class VisualizerWrapper {

	public VisualizerWrapper(int audioSessionId, @NonNull final OnFftDataCaptureListener onFftDataCaptureListener) {
		visualizer = new Visualizer(audioSessionId);
		visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
		visualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
			@Override

	public VisualizerWrapper(@NonNull Context context, int audioSessionId, @NonNull final OnFftDataCaptureListener onFftDataCaptureListener) {
        initTunnelPlayerWorkaround(context);
		visualizer = new Visualizer(audioSessionId);
        visualizer.setEnabled(false);
		visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
        captureRate = Visualizer.getMaxCaptureRate();
        captureListener = new Visualizer.OnDataCaptureListener() {
            @Override
            public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {

            }

		visualizer = null;
	}

	public void setEnabled(boolean enabled) {
		visualizer.setEnabled(enabled);
	}

	public interface OnFftDataCaptureListener {
            }
        };
        visualizer.setEnabled(true);
	}

    private void initTunnelPlayerWorkaround(@NonNull Context context) {
        // Read "tunnel.decode" system property to determine
        // the workaround is needed
        if (TunnelPlayerWorkaround.isTunnelDecodeEnabled(context)) {
            mSilentPlayer = TunnelPlayerWorkaround.createSilentMediaPlayer(context);
        }
    }

	public void release() {
        visualizer.setEnabled(false);
        visualizer.release();
        visualizer = null;
        if (mSilentPlayer != null) {
            mSilentPlayer.release();
            mSilentPlayer = null;
        }
	}

	public void setEnabled(final boolean enabled) {
        if(visualizer == null) return;
        visualizer.setEnabled(false);
        if (enabled) {
            visualizer.setDataCaptureListener(captureListener, captureRate, false, true);
        } else {
            visualizer.setDataCaptureListener(null, captureRate, false, false);
        }
        visualizer.setEnabled(true);
	}

	public interface OnFftDataCaptureListener {
		void onFftDataCapture(byte[] fft);
	}
}

<MSG> + added renderer builder

* fixed releasing resources issue

<DFF> @@ -1,7 +1,9 @@
 package com.cleveroad.audiovisualization;
 
 import android.media.audiofx.Visualizer;
+import android.os.Handler;
 import android.support.annotation.NonNull;
+import android.util.Log;
 
 /**
  * Wrapper for visualizer.
@@ -12,6 +14,7 @@ class VisualizerWrapper {
 
 	public VisualizerWrapper(int audioSessionId, @NonNull final OnFftDataCaptureListener onFftDataCaptureListener) {
 		visualizer = new Visualizer(audioSessionId);
+        visualizer.setEnabled(false);
 		visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
 		visualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
 			@Override
@@ -31,8 +34,16 @@ class VisualizerWrapper {
 		visualizer = null;
 	}
 
-	public void setEnabled(boolean enabled) {
-		visualizer.setEnabled(enabled);
+	public void setEnabled(final boolean enabled) {
+        if (visualizer.getEnabled() != enabled) {
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    int res = visualizer.setEnabled(enabled);
+                    Log.d("TEST", "result: " + res);
+                }
+            }, 500);
+        }
 	}
 
 	public interface OnFftDataCaptureListener {

+ added renderer builder