Search in sources :

Example 6 with AudioEffect

use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.

the class MediaAudioEffectTest method test5_4ParameterChangedListener.

//Test case 5.4: test parameter changed listener
@LargeTest
public void test5_4ParameterChangedListener() throws Exception {
    boolean result = false;
    String msg = "test5_4ParameterChangedListener()";
    mEffect = null;
    AudioEffect effect2 = null;
    try {
        createListenerLooper(false, false, true);
        synchronized (lock) {
            try {
                lock.wait(1000);
            } catch (Exception e) {
                Log.e(TAG, "Looper creation: wait was interrupted.");
            }
        }
        assertTrue(mInitialized);
        effect2 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 1, 0);
        assertNotNull(msg + ": could not create AudioEffect", effect2);
        synchronized (lock) {
            try {
                mParameterChanged = -1;
                effect2.setParameter(Equalizer.PARAM_CURRENT_PRESET, (short) 0);
                lock.wait(1000);
            } catch (Exception e) {
                Log.e(TAG, "Create second effect: wait was interrupted.");
            }
        }
        assertEquals(msg + ": parameter change not received", Equalizer.PARAM_CURRENT_PRESET, mParameterChanged);
        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");
    } catch (Exception e) {
        loge(msg, "Could not create media player:" + e);
    } finally {
        terminateListenerLooper();
        if (effect2 != null) {
            effect2.release();
        }
    }
    assertTrue(msg, result);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 7 with AudioEffect

use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.

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);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 8 with AudioEffect

use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.

the class MediaAudioEffectTest method test4_4GetParameterIntArrayIntArray.

//Test case 4.4: test getParameter(int[], int[])
@LargeTest
public void test4_4GetParameterIntArrayIntArray() throws Exception {
    boolean result = false;
    String msg = "test4_4GetParameterIntArrayIntArray()";
    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);
        int[] param = new int[1];
        int[] value = new int[1];
        param[0] = EnvironmentalReverb.PARAM_DECAY_TIME;
        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);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 9 with AudioEffect

use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.

the class MediaAudioEffectTest method test4_3GetParameterIntByteArray.

//Test case 4.3: test getParameter(int, byte[])
@LargeTest
public void test4_3GetParameterIntByteArray() throws Exception {
    boolean result = false;
    String msg = "test4_3GetParameterIntByteArray()";
    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[] value = new byte[2];
        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);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 10 with AudioEffect

use of android.media.audiofx.AudioEffect in project platform_frameworks_base by android.

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);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

AudioEffect (android.media.audiofx.AudioEffect)235 LargeTest (android.test.suitebuilder.annotation.LargeTest)234 MediaPlayer (android.media.MediaPlayer)54 AudioManager (android.media.AudioManager)42 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 AssetFileDescriptor (android.content.res.AssetFileDescriptor)12 AudioRecord (android.media.AudioRecord)12 AudioTrack (android.media.AudioTrack)6 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 ActionBar (android.support.v7.app.ActionBar)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 SeekBar (android.widget.SeekBar)1 TextView (android.widget.TextView)1 SystemBarTintManager (com.readystatesoftware.systembartint.SystemBarTintManager)1 SizableSeekBar (com.simplecity.amp_library.ui.views.SizableSeekBar)1