use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test5_4ParameterChangedListener.
//Test case 5.4: test parameter changed listener
@LargeTest
public void test5_4ParameterChangedListener() throws Exception {
boolean result = false;
String msg = "test5_4ParameterChangedListener()";
mEffect = null;
AudioEffect effect2 = null;
try {
createListenerLooper(false, false, true);
synchronized (lock) {
try {
lock.wait(1000);
} catch (Exception e) {
Log.e(TAG, "Looper creation: wait was interrupted.");
}
}
assertTrue(mInitialized);
effect2 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 1, 0);
assertNotNull(msg + ": could not create AudioEffect", effect2);
synchronized (lock) {
try {
mParameterChanged = -1;
effect2.setParameter(Equalizer.PARAM_CURRENT_PRESET, (short) 0);
lock.wait(1000);
} catch (Exception e) {
Log.e(TAG, "Create second effect: wait was interrupted.");
}
}
assertEquals(msg + ": parameter change not received", Equalizer.PARAM_CURRENT_PRESET, mParameterChanged);
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": Equalizer not found");
loge(msg, ": Equalizer not found");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
loge(msg, ": Effect library not loaded");
} catch (Exception e) {
loge(msg, "Could not create media player:" + e);
} finally {
terminateListenerLooper();
if (effect2 != null) {
effect2.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test4_7GetParameterAfterRelease.
//Test case 4.7: test getParameter() throws exception after release()
@LargeTest
public void test4_7GetParameterAfterRelease() throws Exception {
boolean result = false;
String msg = "test4_7GetParameterAfterRelease()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
effect.release();
short[] value = new short[1];
effect.getParameter(Equalizer.PARAM_CURRENT_PRESET, value);
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": getParameter() rejected");
loge(msg, "getParameter() rejected");
} catch (IllegalStateException e) {
result = true;
} finally {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test5_1setParameterLowerPriority.
//Test case 5.1: test control passed to higher priority client
@LargeTest
public void test5_1setParameterLowerPriority() throws Exception {
boolean result = false;
String msg = "test5_1setParameterLowerPriority()";
AudioEffect effect1 = null;
AudioEffect effect2 = null;
try {
effect1 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
effect2 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 1, 0);
assertNotNull(msg + ": could not create AudioEffect", effect1);
assertNotNull(msg + ": could not create AudioEffect", effect2);
int status = effect2.setParameter(Equalizer.PARAM_CURRENT_PRESET, (short) 0);
assertEquals(msg + ": Effect2 setParameter failed", AudioEffect.SUCCESS, status);
status = effect1.setParameter(Equalizer.PARAM_CURRENT_PRESET, (short) 1);
assertEquals(msg + ": Effect1 setParameter did not fail", AudioEffect.ERROR_INVALID_OPERATION, status);
short[] value = new short[1];
status = effect2.getParameter(Equalizer.PARAM_CURRENT_PRESET, value);
assertFalse(msg + ": Effect2 getParameter failed", AudioEffect.isError(status));
assertEquals(msg + ": Effect1 changed parameter", (short) 0, value[0]);
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": Effect not found");
result = false;
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
result = false;
} finally {
if (effect1 != null) {
effect1.release();
}
if (effect2 != null) {
effect2.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test5_0setEnabledLowerPriority.
//-----------------------------------------------------------------
// 5 priority and listeners
//----------------------------------
//Test case 5.0: test control passed to higher priority client
@LargeTest
public void test5_0setEnabledLowerPriority() throws Exception {
boolean result = false;
String msg = "test5_0setEnabledLowerPriority()";
AudioEffect effect1 = null;
AudioEffect effect2 = null;
try {
effect1 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
effect2 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 1, 0);
assertNotNull(msg + ": could not create AudioEffect", effect1);
assertNotNull(msg + ": could not create AudioEffect", effect2);
assertTrue(msg + ": Effect2 does not have control", effect2.hasControl());
assertFalse(msg + ": Effect1 has control", effect1.hasControl());
assertTrue(msg + ": Effect1 can enable", effect1.setEnabled(true) == AudioEffect.ERROR_INVALID_OPERATION);
assertFalse(msg + ": Effect1 has enabled", effect2.getEnabled());
result = true;
} catch (IllegalArgumentException e) {
msg = msg.concat(": Effect not found");
result = false;
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
result = false;
} finally {
if (effect1 != null) {
effect1.release();
}
if (effect2 != null) {
effect2.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test4_0GetParameterByteArrayByteArray.
//-----------------------------------------------------------------
// 4 - get parameters
//----------------------------------
//Test case 4.0: test getParameter(byte[], byte[])
@LargeTest
public void test4_0GetParameterByteArrayByteArray() throws Exception {
boolean result = false;
String msg = "test4_0GetParameterByteArrayByteArray()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
byte[] param = intToByteArray(Equalizer.PARAM_CURRENT_PRESET);
byte[] value = new byte[2];
if (!AudioEffect.isError(effect.getParameter(param, value))) {
result = true;
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": getParameter() rejected");
loge(msg, "getParameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("getParameter() called in wrong state");
loge(msg, "getParameter() called in wrong state");
} finally {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
Aggregations