Search in sources :

Example 46 with AudioEffect

use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.

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

Example 47 with AudioEffect

use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.

the class MediaAudioEffectTest method test3_7SetParameterAfterRelease.

//Test case 3.7: test setParameter() throws exception after release()
@LargeTest
public void test3_7SetParameterAfterRelease() throws Exception {
    boolean result = false;
    String msg = "test3_7SetParameterAfterRelease()";
    AudioEffect effect = null;
    try {
        effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER, AudioEffect.EFFECT_TYPE_NULL, 0, 0);
        assertNotNull(msg + ": could not create AudioEffect", effect);
        effect.release();
        effect.setParameter(Equalizer.PARAM_CURRENT_PRESET, (short) 0);
    } 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) {
        result = true;
    } finally {
        if (effect != null) {
            effect.release();
        }
    }
    assertTrue(msg, result);
}
Also used : AudioEffect(android.media.audiofx.AudioEffect) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 48 with AudioEffect

use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.

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

Example 49 with AudioEffect

use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.

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

Example 50 with AudioEffect

use of android.media.audiofx.AudioEffect in project android_frameworks_base by ResurrectionRemix.

the class MediaAudioEffectTest method test5_0setEnabledLowerPriority.

//-----------------------------------------------------------------
// 5 priority and listeners
//----------------------------------
//Test case 5.0: test control passed to higher priority client
@LargeTest
public void test5_0setEnabledLowerPriority() throws Exception {
    boolean result = false;
    String msg = "test5_0setEnabledLowerPriority()";
    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);
        assertTrue(msg + ": Effect2 does not have control", effect2.hasControl());
        assertFalse(msg + ": Effect1 has control", effect1.hasControl());
        assertTrue(msg + ": Effect1 can enable", effect1.setEnabled(true) == AudioEffect.ERROR_INVALID_OPERATION);
        assertFalse(msg + ": Effect1 has enabled", effect2.getEnabled());
        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);
}
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