use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test1_1ConstructorFromUuid.
//Test case 1.1: test constructor from effect uuid
@LargeTest
public void test1_1ConstructorFromUuid() throws Exception {
boolean result = true;
String msg = "test1_1ConstructorFromUuid()";
AudioEffect.Descriptor[] desc = AudioEffect.queryEffects();
assertTrue(msg + "no effects found", (desc.length != 0));
try {
int sessionId;
AudioRecord ar = null;
if (AudioEffect.EFFECT_PRE_PROCESSING.equals(desc[0].connectMode)) {
ar = getAudioRecord();
sessionId = ar.getAudioSessionId();
} else {
sessionId = 0;
}
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_NULL, desc[0].uuid, 0, sessionId);
assertNotNull(msg + ": could not create AudioEffect", effect);
effect.release();
if (ar != null) {
ar.release();
}
} catch (IllegalArgumentException e) {
msg = msg.concat(": Effect not found: " + desc[0].name);
result = false;
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
result = false;
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test1_5AuxiliaryOnMediaPlayer.
//Test case 1.5: test auxiliary effect attachement on MediaPlayer
@LargeTest
public void test1_5AuxiliaryOnMediaPlayer() throws Exception {
boolean result = false;
String msg = "test1_5AuxiliaryOnMediaPlayer()";
try {
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(MediaNames.SHORTMP3);
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
mp.attachAuxEffect(effect.getId());
mp.setAuxEffectSendLevel(1.0f);
result = true;
effect.release();
mp.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");
} 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 crdroidandroid.
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 crdroidandroid.
the class MediaAudioEffectTest method test3_1SetParameterIntInt.
//Test case 3.1: test setParameter(int, int)
@LargeTest
public void test3_1SetParameterIntInt() throws Exception {
boolean result = false;
String msg = "test3_1SetParameterIntInt()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
if (effect.setParameter(EnvironmentalReverb.PARAM_DECAY_TIME, 0) == 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);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by crdroidandroid.
the class MediaAudioEffectTest method test1_4InsertOnMediaPlayer.
//Test case 1.4: test contructor on mediaPlayer audio session
@LargeTest
public void test1_4InsertOnMediaPlayer() throws Exception {
boolean result = false;
String msg = "test1_4InsertOnMediaPlayer()";
try {
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(MediaNames.SHORTMP3);
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, mp.getAudioSessionId());
assertNotNull(msg + ": could not create AudioEffect", effect);
try {
loge(msg, ": effect.setEnabled");
effect.setEnabled(true);
} catch (IllegalStateException e) {
msg = msg.concat(": AudioEffect not initialized");
}
result = true;
effect.release();
mp.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");
} catch (Exception e) {
loge(msg, "Could not create media player:" + e);
}
assertTrue(msg, result);
}
Aggregations