use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class MediaAudioEffectTest method test1_6AuxiliaryOnMediaPlayerFailure.
//Test case 1.6: test auxiliary effect attachement failure before setDatasource
@LargeTest
public void test1_6AuxiliaryOnMediaPlayerFailure() throws Exception {
boolean result = false;
String msg = "test1_6AuxiliaryOnMediaPlayerFailure()";
try {
createMediaPlayerLooper();
synchronized (lock) {
try {
lock.wait(1000);
} catch (Exception e) {
Log.e(TAG, "Looper creation: wait was interrupted.");
}
}
// mMediaPlayer has been initialized?
assertTrue(mInitialized);
mError = 0;
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
synchronized (lock) {
try {
mMediaPlayer.attachAuxEffect(effect.getId());
lock.wait(1000);
} catch (Exception e) {
Log.e(TAG, "Attach effect: wait was interrupted.");
}
}
assertTrue(msg + ": no error on attachAuxEffect", mError != 0);
result = true;
effect.release();
terminateMediaPlayerLooper();
} 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);
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class MediaAudioEffectTest method test2_1SetEnabledAfterRelease.
//Test case 2.1: test setEnabled() throws exception after release
@LargeTest
public void test2_1SetEnabledAfterRelease() throws Exception {
boolean result = false;
String msg = "test2_1SetEnabledAfterRelease()";
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.setEnabled(true);
} catch (IllegalStateException e) {
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");
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by DirtyUnicorns.
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);
}
Aggregations