Code example for AudioTrack

Methods: getPlayStatewrite

0
        { 
            /* push new data to the hardware */ 
            RockboxPCM pcm = (RockboxPCM)track;
            int result = -1;
            pcm.pcmSamplesToByteArray(buf);
            result = track.write(buf, 0, buf.length);
            if (result >= 0)
            { 
                switch(track.getPlayState())
                { 
                    case AudioTrack.PLAYSTATE_PLAYING:
                    case AudioTrack.PLAYSTATE_PAUSED:
                        /* refill at 25% no matter of how many  
                         * bytes we've written */ 
                        if (setNotificationMarkerPosition(
                                bytes2frames(refill_mark)) 
                                    != AudioTrack.SUCCESS)
                        { 
                            LOG("Error in onMarkerReached: " + 
                            		"Could not set notification marker"); 
                        }