use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.
the class MediaAudioEffectTest method test1_7AuxiliaryOnAudioTrack.
//Test case 1.7: test auxiliary effect attachement on AudioTrack
@LargeTest
public void test1_7AuxiliaryOnAudioTrack() throws Exception {
boolean result = false;
String msg = "test1_7AuxiliaryOnAudioTrack()";
try {
AudioTrack track = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT), AudioTrack.MODE_STREAM);
assertNotNull(msg + ": could not create AudioTrack", track);
AudioEffect effect = new AudioEffect(AudioEffect.EFFECT_TYPE_ENV_REVERB, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
track.attachAuxEffect(effect.getId());
track.setAuxEffectSendLevel(1.0f);
result = true;
effect.release();
track.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 platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class MediaAudioEffectTest method test1_2ConstructorUnknownType.
//Test case 1.2: test constructor failure from unknown type
@LargeTest
public void test1_2ConstructorUnknownType() throws Exception {
boolean result = false;
String msg = "test1_2ConstructorUnknownType()";
try {
AudioEffect effect = new AudioEffect(UUID.randomUUID(), AudioEffect.EFFECT_TYPE_NULL, 0, 0);
msg = msg.concat(": could create random AudioEffect");
if (effect != null) {
effect.release();
}
} catch (IllegalArgumentException e) {
result = true;
} catch (UnsupportedOperationException e) {
msg = msg.concat(": Effect library not loaded");
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.
the class MediaAudioEffectTest method test6_0Command.
//-----------------------------------------------------------------
// 6 command method
//----------------------------------
//Test case 6.0: test command method
@LargeTest
public void test6_0Command() throws Exception {
boolean result = false;
String msg = "test6_0Command()";
AudioEffect effect = null;
try {
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
assertNotNull(msg + ": could not create AudioEffect", effect);
try {
byte[] cmd = new byte[0];
byte[] reply = new byte[4];
int status = effect.command(3, cmd, reply);
assertFalse(msg + ": command failed", AudioEffect.isError(status));
assertTrue(msg + ": effect not enabled", effect.getEnabled());
result = true;
} catch (IllegalStateException e) {
msg = msg.concat(": command in illegal state");
}
} 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 {
if (effect != null) {
effect.release();
}
}
assertTrue(msg, result);
}
use of android.media.audiofx.AudioEffect in project android_frameworks_base by ParanoidAndroid.
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