Mercurial > hg > pulseaudio
changeset 149:b4390e330ff7
2008-09-29 Ioana Ivan <iivan@redhat.com>
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java:
removed all references to the boolean variable corked since it was
redundant.
(start) : only send a START event if there's been a call to stop between
the last call to start and this one.
(stop): only send a STOP event if there's been a call to start between
the last call the stop and this one.
(startedListener.update): send a START event the first time data is
being written to the line and after an underflow.
author | Ioana Ivan <iivan@redhat.com> |
---|---|
date | Mon, 29 Sep 2008 14:01:57 -0400 |
parents | f29cbcfbc354 |
children | 5ab54b0ca4ea |
files | ChangeLog src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java |
diffstat | 2 files changed, 42 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Sep 26 13:27:33 2008 -0400 +++ b/ChangeLog Mon Sep 29 14:01:57 2008 -0400 @@ -1,3 +1,14 @@ +2008-09-25 Ioana Ivan <iivan@redhat.com> + * src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java: + removed all references to the boolean variable corked since it was + redundant. + (start) : only send a START event if there's been a call to stop between + the last call to start and this one. + (stop): only send a STOP event if there's been a call to start between + the last call the stop and this one. + (startedListener.update): send a START event the first time data is + being written to the line and after an underflow. + 2008-09-25 Ioana Ivan <iivan@redhat.com> * src/native/org_classpath_icedtea_Stream.c
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Fri Sep 26 13:27:33 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Mon Sep 29 14:01:57 2008 -0400 @@ -58,8 +58,9 @@ // true between start() and stop() protected boolean isStarted = false; + //true between a started and an underflow callback protected boolean dataWritten = false; - protected boolean corked = true; + // true if a stream has been paused // protected boolean isPaused = false; @@ -160,14 +161,14 @@ Stream.UnderflowListener stoppedListener = new Stream.UnderflowListener() { @Override + public void update() { dataWritten = false; - - if (!corked) { - fireLineEvent(new LineEvent(PulseAudioDataLine.this, - LineEvent.Type.STOP, framesSinceOpen)); - } - + System.out.println("underflow"); + // always send a STOP event on an underflow (assumption: + // an underflow can't happen while the stream is corked) + fireLineEvent(new LineEvent(PulseAudioDataLine.this, + LineEvent.Type.STOP, framesSinceOpen)); } }; stream.addUnderflowListener(stoppedListener); @@ -175,13 +176,17 @@ Stream.PlaybackStartedListener startedListener = new Stream.PlaybackStartedListener() { @Override public void update() { - - dataWritten = true; - if (!corked) { + System.out.println("started callback"); + + //only send a START event in the beginning and following + //an underflow + if (!dataWritten) { fireLineEvent(new LineEvent(PulseAudioDataLine.this, LineEvent.Type.START, framesSinceOpen)); } + dataWritten = true; + } }; @@ -308,26 +313,25 @@ "Line must be open()ed before it can be start()ed"); } - if (!corked) { - System.out.println("Already started, returning"); + if (isStarted) { return; + } - corked = false; + Operation op; synchronized (eventLoop.threadLock) { op = stream.unCork(); + if (dataWritten && (!isStarted)) { + fireLineEvent(new LineEvent(PulseAudioDataLine.this, + LineEvent.Type.START, framesSinceOpen)); + } } op.waitForCompletion(); op.releaseReference(); isStarted = true; - /* - * if (dataWritten) { fireLineEvent(new - * LineEvent(PulseAudioDataLine.this, LineEvent.Type.START, - * framesSinceOpen)); } - */ } @@ -337,26 +341,25 @@ "Line must be open()ed before it can be start()ed"); } - if (corked) { + if (!isStarted) { return; } - corked = true; + isStarted = true; Operation op; synchronized (eventLoop.threadLock) { op = stream.cork(); + // if there are no data on the line when stop was called, + // don't send a stop event + if (dataWritten && (isStarted)) { + fireLineEvent(new LineEvent(PulseAudioDataLine.this, + LineEvent.Type.STOP, framesSinceOpen)); + } } op.waitForCompletion(); op.releaseReference(); isStarted = false; - if (dataWritten) { - fireLineEvent(new LineEvent(PulseAudioDataLine.this, - LineEvent.Type.STOP, framesSinceOpen)); - } - - isStarted = false; - } /* @@ -381,7 +384,7 @@ } public boolean isRunning() { - return !corked && dataWritten; + return isStarted && dataWritten; } protected abstract void connectLine(int bufferSize, Stream masterStream)