Code example for AudioTrack

Methods: getStatereleasesetPlaybackRate

0
        final int TEST_MODE = AudioTrack.MODE_STREAM;
        final int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
         
        //-------- initialization -------------- 
        int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
        AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF, TEST_FORMAT, 
                minBuffSize, TEST_MODE);
        //--------    test        -------------- 
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_INITIALIZED);
        assertTrue(TEST_NAME, track.setPlaybackRate(0) == AudioTrack.ERROR_BAD_VALUE);
        //-------- tear down      -------------- 
        track.release();
    } 
     
    //Test case 6: setPlaybackRate() accepts values twice the output sample rate 
    @LargeTest 
    public void testSetPlaybackRateTwiceOutputSR() throws Exception { 
        // constants for test 
        final String TEST_NAME = "testSetPlaybackRateTwiceOutputSR";
        final int TEST_SR = 22050;
        final int TEST_CONF = AudioFormat.CHANNEL_OUT_STEREO;