Code example for SourceDataLine

Methods: write

0
        public void play(DirectAudioPlayer mediaPlayer, Pointer samples, int sampleCount, long pts) {
            // There may be more efficient ways to do this... 
            int bufferSize = sampleCount * BLOCK_SIZE;
            // You could process these samples in some way before playing them... 
            byte[] data = samples.getByteArray(0, bufferSize);
            dataLine.write(data, 0, bufferSize);
        } 
 
        @Override 
        public void drain(DirectAudioPlayer mediaPlayer) {
            Logger.info("drain()"); 
            dataLine.drain();
        } 
 
        @Override 
        public void finished(MediaPlayer mediaPlayer) {
            Logger.info("finished()"); 
            sync.release();
        } 
    }