Mercurial > hg > pulseaudio
changeset 157:55bb87d31a6f
2008-09-30 Omair Majid <omajid@redhat.com>
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
(open): Initialize variables so reopening a line still leaves it in a
valid state.
(read): Fixed comments.
(flush): Also clear the fragmentBuffer.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 30 Sep 2008 12:17:33 -0400 |
parents | 609dcbe6d5b8 |
children | a6a5ca46e90e |
files | src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Tue Sep 30 11:49:05 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Tue Sep 30 12:17:33 2008 -0400 @@ -90,8 +90,13 @@ super.open(format, bufferSize); + /* initialize all the member variables */ framesSinceOpen = 0; + fragmentBuffer = null; + flushed = false; + drained = false; + /* add this open line to the mixer */ PulseAudioMixer parentMixer = PulseAudioMixer.getInstance(); parentMixer.addTargetLine(this); } @@ -115,6 +120,8 @@ @Override public int read(byte[] data, int offset, int length) { + /* check state and inputs */ + if (!isOpen) { throw new IllegalStateException("must call open() before read()"); } @@ -135,6 +142,8 @@ + (length + offset) + " array size: " + data.length); } + /* everything ok */ + int position = offset; int remainingLength = length; int sizeRead = 0; @@ -246,10 +255,6 @@ // all the data should have been played by now assert (sizeRead == length); - /* - * FIXME when the stream is flushed() etc, instead of returning length - * this should unblock and return the the size of data written so far - */ return sizeRead; } @@ -276,6 +281,7 @@ try { Thread.sleep(100); } catch (InterruptedException e) { + // do nothing } } @@ -287,6 +293,7 @@ throw new IllegalStateException("Line must be open"); } + /* flush the buffer on pulseaudio's side */ Operation operation; synchronized (eventLoop.threadLock) { operation = stream.flush(); @@ -296,6 +303,8 @@ synchronized (this) { flushed = true; + /* flush the partial fragment we stored */ + fragmentBuffer = null; } } @@ -324,7 +333,7 @@ /* * A TargetData starts when we ask it to and continues playing until we ask - * it to stop. there are no buffer underruns/overflows or anything so we + * it to stop. There are no buffer underruns/overflows or anything so we * will just fire the LineEvents manually */