use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.
the class MediaAudioEffectTest method test2_0SetEnabledGetEnabled.
//-----------------------------------------------------------------
// 2 - enable/ disable
//----------------------------------
//Test case 2.0: test setEnabled() and getEnabled() in valid state
@LargeTest
public void test2_0SetEnabledGetEnabled() throws Exception {
boolean result = false;
String msg = "test2_0SetEnabledGetEnabled()";
try {
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
try {
effect.setEnabled(true);
assertTrue(msg + ": invalid state from getEnabled", effect.getEnabled());
effect.setEnabled(false);
assertFalse(msg + ": invalid state to getEnabled", effect.getEnabled());
result = true;
} catch (IllegalStateException e) {
msg = msg.concat(": setEnabled() in wrong state");
} finally {
effect.release();
}
} 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");
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.
the class MediaAudioEffectTest method test4_5GetParameterIntArrayShortArray.
//Test case 4.5: test getParameter(int[], short[])
@LargeTest
public void test4_5GetParameterIntArrayShortArray() throws Exception {
boolean result = false;
String msg = "test4_5GetParameterIntArrayShortArray()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
int[] param = new int[1];
short[] value = new short[1];
param[0] = Equalizer.PARAM_CURRENT_PRESET;
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);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
the class MediaAudioEffectTest method test4_2GetParameterIntShortArray.
//Test case 4.2: test getParameter(int, short[])
@LargeTest
public void test4_2GetParameterIntShortArray() throws Exception {
boolean result = false;
String msg = "test4_2GetParameterIntShortArray()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
short[] value = new short[1];
if (!AudioEffect.isError(effect.getParameter(Equalizer.PARAM_CURRENT_PRESET, 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);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.
the class MediaAudioEffectTest method test1_3GetEnabledAfterRelease.
//Test case 1.3: test getEnabled() failure when called on released effect
@LargeTest
public void test1_3GetEnabledAfterRelease() throws Exception {
boolean result = false;
String msg = "test1_3GetEnabledAfterRelease()";
try {
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
effect.release();
try {
effect.getEnabled();
} catch (IllegalStateException e) {
result = true;
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Equalizer not found");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
}
assertTrue(msg, result);
}
Aggregations