Code example for Equalizer

Methods: getProperties, release, setProperties

0
    public void test1_3Properties() throws Exception { 
        boolean result = false;
        String msg = "test1_3Properties()";
        getEqualizer(0); 
        try { 
            Equalizer.Settings settings = mEqualizer.getProperties();
            String str = settings.toString();
            settings = new Equalizer.Settings(str);
            mEqualizer.setProperties(settings);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");
            loge(msg, "get parameter() called in wrong state");
        } finally { 
            releaseEqualizer(); 
        } 
        assertTrue(msg, result);
    } 
 
    //----------------------------------------------------------------- 
    // private methods 
    //---------------------------------- 
 
    private void getEqualizer(int session) {
         if (mEqualizer == null || session != mSession) {
             if (session != mSession && mEqualizer != null) {
                 mEqualizer.release();
                 mEqualizer = null;
             } 
             try { 
                mEqualizer = new Equalizer(0, session);
                mSession = session;
            } catch (IllegalArgumentException e) {
                Log.e(TAG, "getEqualizer() Equalizer not found exception: "+e);
            } catch (UnsupportedOperationException e) {
                Log.e(TAG, "getEqualizer() Effect library not loaded exception: "+e);
            } 
         } 
         assertNotNull("could not create mEqualizer", mEqualizer);
    } 
 
    private void releaseEqualizer() { 
        if (mEqualizer != null) {
            mEqualizer.release();
            mEqualizer = null;
        } 
   } 
 
}