use of android.media.audiofx.AudioEffect in project android_frameworks_base by AOSPA.
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);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by AOSPA.
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 AOSPA.
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 AOSPA.
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);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test3_5SetParameterIntArrayShortArray.
//Test case 3.5: test setParameter(int[], short[])
@LargeTest
public void test3_5SetParameterIntArrayShortArray() throws Exception {
boolean result = false;
String msg = "test3_5SetParameterIntArrayShortArray()";
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;
value[0] = (short) 0;
if (effect.setParameter(param, value) == AudioEffect.SUCCESS) {
result = true;
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Bad parameter value");
loge(msg, "Bad parameter value");
} catch (UnsupportedOperationException e) {
msg = msg.concat(": setParameter() rejected");
loge(msg, "setParameter() rejected");
} catch (IllegalStateException e) {
msg = msg.concat("setParameter() called in wrong state");
loge(msg, "setParameter() called in wrong state");
} finally {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
Aggregations