Mercurial > hg > pulseaudio
changeset 88:6dd17faac024
2008-08-19 Omair Majid <omajid@redhat.com>
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
(read): Improved output details of exceptions. currentFramePosition is now
updated as read progresses.
(getBufferSize): Return DEFAULT_BUFFER_SIZE isntead of 0.
(getFramePosition): Return the current frame.
(getLevel): Return AudioSystem.NOT_SPECIFIED isntead of 0.
(getLongFramePosition): Return the frame position.
(getMicrosecondPosition): Return the microsecond position based on estimate.
(getControl): Throw an exception to indicate no controls is found instead.
(getControls): Return an array of size 0.
(getLineInfo): Return a DataLine.Info object instead of just Line.Info.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 19 Aug 2008 10:04:12 -0400 |
parents | 9a23cb09d073 |
children | 52b513a7e5e9 |
files | src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java |
diffstat | 1 files changed, 26 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Mon Aug 18 15:53:50 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java Tue Aug 19 10:04:12 2008 -0400 @@ -37,9 +37,14 @@ package org.classpath.icedtea.pulseaudio; -import java.io.IOException; import java.util.ArrayList; -import javax.sound.sampled.*; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Control; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.TargetDataLine; import javax.sound.sampled.Control.Type; public class PulseAudioTargetDataLine extends PulseAudioDataLine implements @@ -48,6 +53,8 @@ protected boolean isOpen = false; protected boolean isPaused = false; + private long currentFramePosition = 0; + @SuppressWarnings("unused") private long streamPointer; @@ -71,7 +78,7 @@ if (length % frameSize != 0) { throw new IllegalArgumentException( - "amount of data to write does not represent an integral number of frames"); + "amount of data to read does not represent an integral number of frames"); } if (length < 0) { @@ -79,7 +86,8 @@ } if (length + offset > data.length) { - throw new ArrayIndexOutOfBoundsException(length + offset); + throw new ArrayIndexOutOfBoundsException("index: " + + (length + offset) + " array size: " + data.length); } int position = offset; @@ -90,10 +98,13 @@ synchronized (eventLoop.threadLock) { int bytesRead = stream.read(data, remainingLength, position); - + if (bytesRead < 0) { + return sizeRead; + } sizeRead += bytesRead; position += bytesRead; remainingLength -= bytesRead; + currentFramePosition = bytesRead / currentFormat.getFrameSize(); } } @@ -128,8 +139,7 @@ } public int getBufferSize() { - // TODO Auto-generated method stub - return 0; + return DEFAULT_BUFFER_SIZE; } public AudioFormat getFormat() { @@ -137,23 +147,19 @@ } public int getFramePosition() { - // TODO Auto-generated method stub - return 0; + return (int) currentFramePosition; } public float getLevel() { - // TODO Auto-generated method stub - return 0; + return AudioSystem.NOT_SPECIFIED; } public long getLongFramePosition() { - // TODO Auto-generated method stub - return 0; + return currentFramePosition; } public long getMicrosecondPosition() { - // TODO Auto-generated method stub - return 0; + return (long) (currentFramePosition / currentFormat.getFrameRate()); } public boolean isActive() { @@ -167,23 +173,21 @@ } public Control getControl(Type control) { - // TODO Auto-generated method stub - return null; + throw new IllegalArgumentException( + "PulseAudioTargetDataLine does not support any controls"); } public Control[] getControls() { - // TODO Auto-generated method stub - return null; + return new Control[] {}; } public javax.sound.sampled.Line.Info getLineInfo() { - return new Line.Info(SourceDataLine.class); + return new DataLine.Info(TargetDataLine.class, supportedFormats, 0, + DEFAULT_BUFFER_SIZE); } public boolean isControlSupported(Type control) { - // TODO Auto-generated method stub return false; - } } \ No newline at end of file