use of android.media.audiofx.Visualizer in project platform_frameworks_base by android.
the class MediaVisualizerTest method test0_0ConstructorAndRelease.
//-----------------------------------------------------------------
// VISUALIZER TESTS:
//----------------------------------
//-----------------------------------------------------------------
// 0 - constructor
//----------------------------------
//Test case 0.0: test constructor and release
@LargeTest
public void test0_0ConstructorAndRelease() throws Exception {
boolean result = false;
String msg = "test1_0ConstructorAndRelease()";
Visualizer visualizer = null;
try {
visualizer = new Visualizer(0);
assertNotNull(msg + ": could not create Visualizer", visualizer);
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": Visualizer not found");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
} finally {
if (visualizer != null) {
visualizer.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.Visualizer in project android_frameworks_base by ResurrectionRemix.
the class VisualizerTest method getEffect.
private void getEffect(int session) {
synchronized (sInstances) {
if (sInstances.containsKey(session)) {
mVisualizer = sInstances.get(session);
} else {
try {
mVisualizer = new Visualizer(session);
} catch (UnsupportedOperationException e) {
Log.e(TAG, "Visualizer library not loaded");
throw (new RuntimeException("Cannot initialize effect"));
} catch (RuntimeException e) {
throw e;
}
sInstances.put(session, mVisualizer);
}
}
mReleaseButton.setEnabled(false);
mOnOffButton.setEnabled(false);
if (mVisualizer != null) {
mCaptureSize = mVisualizer.getCaptureSize();
mReleaseButton.setChecked(true);
mReleaseButton.setEnabled(true);
mEnabled = mVisualizer.getEnabled();
mOnOffButton.setChecked(mEnabled);
mOnOffButton.setEnabled(true);
mCallbackButton.setEnabled(!mEnabled);
}
}
use of android.media.audiofx.Visualizer in project android_frameworks_base by DirtyUnicorns.
the class MediaVisualizerTest method getVisualizer.
private void getVisualizer(int session) {
if (mVisualizer == null || session != mSession) {
if (session != mSession && mVisualizer != null) {
mVisualizer.release();
mVisualizer = null;
}
try {
mVisualizer = new Visualizer(session);
mSession = session;
} catch (IllegalArgumentException e) {
Log.e(TAG, "getVisualizer() Visualizer not found exception: " + e);
} catch (UnsupportedOperationException e) {
Log.e(TAG, "getVisualizer() Effect library not loaded exception: " + e);
}
}
assertNotNull("could not create mVisualizer", mVisualizer);
}
use of android.media.audiofx.Visualizer in project android_frameworks_base by DirtyUnicorns.
the class VisualizerTest method getEffect.
private void getEffect(int session) {
synchronized (sInstances) {
if (sInstances.containsKey(session)) {
mVisualizer = sInstances.get(session);
} else {
try {
mVisualizer = new Visualizer(session);
} catch (UnsupportedOperationException e) {
Log.e(TAG, "Visualizer library not loaded");
throw (new RuntimeException("Cannot initialize effect"));
} catch (RuntimeException e) {
throw e;
}
sInstances.put(session, mVisualizer);
}
}
mReleaseButton.setEnabled(false);
mOnOffButton.setEnabled(false);
if (mVisualizer != null) {
mCaptureSize = mVisualizer.getCaptureSize();
mReleaseButton.setChecked(true);
mReleaseButton.setEnabled(true);
mEnabled = mVisualizer.getEnabled();
mOnOffButton.setChecked(mEnabled);
mOnOffButton.setEnabled(true);
mCallbackButton.setEnabled(!mEnabled);
}
}
use of android.media.audiofx.Visualizer in project android_packages_apps_DUI by DirtyUnicorns.
the class VisualizerStreamHandler method link.
/**
* Links the visualizer to a player
*
* @param player - MediaPlayer instance to link to
*/
public final void link(int audioSessionId) {
if (mVisualizer != null && audioSessionId != mAudioSessionId) {
mVisualizer.setEnabled(false);
mVisualizer.release();
mVisualizer = null;
}
pause();
resetAnalyzer();
mAudioSessionId = audioSessionId;
if (mVisualizer == null) {
try {
mVisualizer = new Visualizer(audioSessionId);
} catch (Exception e) {
Log.e(TAG, "Error enabling visualizer!", e);
return;
}
mVisualizer.setEnabled(false);
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
Visualizer.OnDataCaptureListener captureListener = new Visualizer.OnDataCaptureListener() {
@Override
public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
if (ENABLE_WAVEFORM) {
analyze(bytes);
if (isValidStream() && !mIsPaused) {
mListener.onWaveFormUpdate(bytes);
}
}
}
@Override
public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
analyze(bytes);
if (isValidStream() && !mIsPaused) {
mListener.onFFTUpdate(bytes);
}
}
};
mVisualizer.setDataCaptureListener(captureListener, (int) (Visualizer.getMaxCaptureRate() * 0.75), true, true);
}
mVisualizer.setEnabled(true);
}
Aggregations