Package com.tulskiy.musique.audio.player.io

Examples of com.tulskiy.musique.audio.player.io.Buffer


    private PlayingThread playingThread;
    private BufferingThread bufferingThread;
    private ArrayList<PlayerListener> listeners = new ArrayList<PlayerListener>();

    public Player() {
        Buffer buffer = new Buffer(BUFFER_SIZE);
        playingThread = new PlayingThread(this, buffer);
        Thread t1 = new Thread(playingThread, "Playing Thread");
        t1.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        bufferingThread = new BufferingThread(buffer, playingThread);
View Full Code Here


* Date: 1/15/11
*/
public class BufferTest {
    @Test
    public void testRW() {
        Buffer buffer = new Buffer();
        byte[] buf = new byte[100];
        Track t = new Track();
        Arrays.fill(buf, (byte) 1);
        t.getTrackData().setBitrate(5);
        buffer.addNextTrack(t, null, 0, false);
        buffer.write(buf, 0, buf.length);
        buffer.write(buf, 0, buf.length);

        t = new Track();
        t.getTrackData().setBitrate(10);
        buffer.addNextTrack(t, null, 0, false);
        t = new Track();
        t.getTrackData().setBitrate(20);

        buffer.addNextTrack(t, null, 0, false);
        buffer.write(buf, 0, buf.length);
        t = new Track();
        t.getTrackData().setBitrate(30);
        buffer.addNextTrack(t, null, 0, false);

        assertEquals(-1, buffer.read(buf, 0, 100));
        Buffer.NextEntry nextTrack = buffer.pollNextTrack();
        assertEquals(5, nextTrack.track.getTrackData().getBitrate());

        assertEquals(55, buffer.read(buf, 0, 55));
        assertEquals(100, buffer.read(buf, 0, 100));
        assertEquals(45, buffer.read(buf, 0, 100));

        assertEquals(-1, buffer.read(buf, 0, 100));
        nextTrack = buffer.pollNextTrack();
        assertEquals(10, nextTrack.track.getTrackData().getBitrate());

        assertEquals(-1, buffer.read(buf, 0, 100));
        nextTrack = buffer.pollNextTrack();

        assertEquals(20, nextTrack.track.getTrackData().getBitrate());
        assertEquals(100, buffer.read(buf, 0, 100));
        assertEquals(-1, buffer.read(buf, 0, 100));
    }
View Full Code Here

TOP

Related Classes of com.tulskiy.musique.audio.player.io.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.