Search in sources :

Example 11 with AudioEffect

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

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

Example 12 with AudioEffect

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

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

Example 13 with AudioEffect

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

the class MediaAudioEffectTest method test3_4SetParameterIntArrayIntArray.

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

Example 14 with AudioEffect

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

the class MediaAudioEffectTest method test5_2ControlStatusListener.

//Test case 5.2: test control status listener
@LargeTest
public void test5_2ControlStatusListener() throws Exception {
    boolean result = false;
    String msg = "test5_2ControlStatusListener()";
    mEffect = null;
    AudioEffect effect2 = null;
    try {
        mHasControl = true;
        createListenerLooper(true, false, false);
        synchronized (lock) {
            try {
                lock.wait(1000);
            } catch (Exception e) {
                Log.e(TAG, "Looper creation: wait was interrupted.");
            }
        }
        assertTrue(mInitialized);
        synchronized (lock) {
            try {
                effect2 = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 1, 0);
                assertNotNull(msg + ": could not create AudioEffect", effect2);
                lock.wait(1000);
            } catch (Exception e) {
                Log.e(TAG, "Create second effect: wait was interrupted.");
            }
        }
        assertFalse(msg + ": effect control not lost by effect1", mHasControl);
        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 15 with AudioEffect

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

the class MediaAudioEffectTest method test4_6GetParameterIntArrayByteArray.

//Test case 4.6: test getParameter(int[], byte[])
@LargeTest
public void test4_6GetParameterIntArrayByteArray() throws Exception {
    boolean result = false;
    String msg = "test4_6GetParameterIntArrayByteArray()";
    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];
        byte[] value = new byte[2];
        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);
}
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