AudioTrack release - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AudioTrack release method.

This code example shows how to use the following methods:release, stop
thread = null;
		 
 
		if(oTrack!=null){
			oTrack.stop();
			oTrack.release();
			oTrack = null;
		} 
		if(iTrack!=null){
			iTrack.release();
			iTrack = null;
		} 
		 
	} 
 
	@Override 
	protected void appPause() { 
		if(broadcastReceiver != null){
			try{ 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, stop
 
    public int deinitAudio() 
    { 
        if( mAudio != null )
        { 
            mAudio.stop();
            mAudio.release();
            mAudio = null;
        } 
        mAudioBuffer = null;
        return 1; 
    } 
 
    public int initAudioThread() 
    { 
        // Make audio thread priority higher so audio thread won't get underrun 
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        return 1; 
    } 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getState, release, write
        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, 
                2*minBuffSize, TEST_MODE);
        byte data[] = new byte[minBuffSize];
        //--------    test        -------------- 
        assumeTrue(TEST_NAME, track.getState() == AudioTrack.STATE_INITIALIZED);
        assertTrue(TEST_NAME,
                track.write(data, 0, data.length) == data.length);
        //-------- tear down      -------------- 
        track.release();
    } 
     
    //Test case 12: write() succeeds and returns the size that was written for 8bit 
    @LargeTest 
    public void testWriteShort8bit() throws Exception { 
        // constants for test 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, stop
		track.play();
		latency = minSize / (isMono?1:2);
	} 
 
	@Override public void dispose () { 
		track.stop();
		track.release();
	} 
 
	@Override public boolean isMono () { 
		return isMono;
	} 
 
	@Override public void writeSamples (short[] samples, int offset, int numSamples) {
		int writtenSamples = track.write(samples, offset, numSamples);
		while (writtenSamples != numSamples)
			writtenSamples += track.write(samples, offset + writtenSamples, numSamples - writtenSamples);
	} 
 
	@Override public void writeSamples (float[] samples, int offset, int numSamples) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, stop
	 
	public int deinitAudio() 
	{ 
		if( mAudio != null )
		{ 
			mAudio.stop();
			mAudio.release();
			mAudio = null;
		} 
		mAudioBuffer = null;
		return 1; 
	} 
	 
	public int initAudioThread() 
	{ 
		// Make audio thread priority higher so audio thread won't get underrun 
		Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
		return 1; 
	} 
	 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, stop
        }).start();
    } 
 
    private void stopPlayer(boolean reinit) {
        if(audiotrack != null) {
            try { audiotrack.stop(); } catch(Exception e) { e.printStackTrace(); }
            audiotrack.release();
            audiotrack = null;
            audio = null;
        } 
        if(reinit) {
            initializeAudioTrack(); 
        } 
    } 
 
    private void pausePlayer() { 
        if(audiotrack != null) {
            audiotrack.pause();
        } 
    } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:flush, play, release, write
    } 
 
    private void playSound() { 
 
//        Log.i("BFV_samples","" + numSamples ) ; 
        AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
                sampleRate, AudioFormat.CHANNEL_OUT_MONO,
                AudioFormat.ENCODING_PCM_16BIT, numSamples,
                AudioTrack.MODE_STATIC);
        audioTrack.write(generatedSnd, 0, generatedSnd.length);
        audioTrack.play();
        audioTrack.flush();
        audioTrack.release();
 
    } 
} 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, stop
    	if ( pipe != null ) {
    		Log.i( TAG , "[ shutdown() ] closing pipe");
    		pipe.close();
    	} 
    	if ( audioTrack != null ) {
    		audioTrack.stop();
    		audioTrack.release();
    	} 
         
    } 
 
     
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getState, play, release, write
 
    private void create(String path) {//НЕ РАБОТАЕТ
        try { 
            Debug.trace(" player, path:" + path);
            if (data == null) return;
            player = new AudioTrack(AudioManager.STREAM_MUSIC, 48000, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT /*CHANNEL_OUT_DEFAULT api > 8*/, AudioFormat.ENCODING_PCM_16BIT, data.length(), AudioTrack.MODE_STREAM);
            player.write(data.getArray(), 0, data.length());
            filename = path;
            isPlayed = false;
 
            player.release();
            Debug.trace("Prepared." + toString()); 
            play(); 
        } catch (IllegalArgumentException e) {
            Debug.trace(e.toString() + " " + toString());
        } catch (Exception e) {
            Debug.logEx(e);
        } 
    } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:release, stop
            if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
                audioRecord.stop();
            } 
            audioRecord.release();
            if (isLiveMode) {
                audioTrack.stop();
                audioTrack.release();
            } 
            if (instrumentalReader != null) {
                try { 
                    Resample.close(); 
                    instrumentalReader.closeWaveFile();
                } catch (IOException e) {
                    // no recovery possible here 
                    e.printStackTrace();
                } 
            } 
            // close file 
            try { 
                writer.closeWaveFile();
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related AudioTrack release Questions & Answers:

release Method Overview
Releases the native AudioTrack resources.
See Code Examples for other Android AudioTrack Methods: