# HG changeset patch # User Omair Majid # Date 1223580927 14400 # Node ID ea894778a6d0327ab9c242335b3160d809bae2a3 # Parent 5108fc37a89050de8f8f0b3d7beb793cf685fea9 2008-10-09 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java (getSupportedFormats): Moved stuff around. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java (PulseAudioPort): Open the port on construction. (open): Doesnt throw any exceptions, so no throws clause. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java (open): Let the mixer know that the line is open. (close): Let the mixer know the the line is closed. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java (open): Let the mixer know that the line is open. (close): Let the mixer konw that hte line is closed. diff -r 5108fc37a890 -r ea894778a6d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Oct 08 16:06:00 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Thu Oct 09 15:35:27 2008 -0400 @@ -136,22 +136,6 @@ * */ int[] channelSizes = new int[] { 1, 2, 3, 4, 5, 6 }; - for (int channelSize : channelSizes) { - properties = new HashMap(); - properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_U8"); - - int sampleSize = 8; // in bits - AudioFormat PA_SAMPLE_U8 = new AudioFormat(Encoding.PCM_UNSIGNED, // encoding - AudioSystem.NOT_SPECIFIED, // sample rate - sampleSize, // sample size - channelSize, // channels - sampleSize / 8 * channelSize, // frame size in bytes - AudioSystem.NOT_SPECIFIED, // frame rate - false, // big endian? - properties); - - supportedFormats.add(PA_SAMPLE_U8); - } for (int channelSize : channelSizes) { properties = new HashMap(); @@ -259,6 +243,23 @@ supportedFormats.add(PA_SAMPLE_S32LE); } + for (int channelSize : channelSizes) { + properties = new HashMap(); + properties.put(PULSEAUDIO_FORMAT_KEY, "PA_SAMPLE_U8"); + + int sampleSize = 8; // in bits + AudioFormat PA_SAMPLE_U8 = new AudioFormat(Encoding.PCM_UNSIGNED, // encoding + AudioSystem.NOT_SPECIFIED, // sample rate + sampleSize, // sample size + channelSize, // channels + sampleSize / 8 * channelSize, // frame size in bytes + AudioSystem.NOT_SPECIFIED, // frame rate + false, // big endian? + properties); + + supportedFormats.add(PA_SAMPLE_U8); + } + return supportedFormats.toArray(new AudioFormat[0]); } diff -r 5108fc37a890 -r ea894778a6d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java Wed Oct 08 16:06:00 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioPort.java Thu Oct 09 15:35:27 2008 -0400 @@ -39,7 +39,6 @@ import javax.sound.sampled.AudioSystem; import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.Port; public abstract class PulseAudioPort extends PulseAudioLine implements Port, @@ -79,6 +78,16 @@ controls.add(muteControl); isOpen = true; + /* + * unlike other lines, Ports must either be open or close + * + * close = no sound. open = sound + * + * so we set it to be open by default + */ + + open(); + // System.out.println("Opened Target Port " + name); } @@ -95,6 +104,8 @@ } public float getVolume() { + + // FIXME need to query system for volume return this.volume; } @@ -130,7 +141,7 @@ public abstract javax.sound.sampled.Line.Info getLineInfo(); @Override - public void open() throws LineUnavailableException { + public void open() { native_setVolume(volume); isOpen = true; fireLineEvent(new LineEvent(this, LineEvent.Type.OPEN, diff -r 5108fc37a890 -r ea894778a6d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Wed Oct 08 16:06:00 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourcePort.java Thu Oct 09 15:35:27 2008 -0400 @@ -41,6 +41,8 @@ public class PulseAudioSourcePort extends PulseAudioPort { + /* aka mic */ + static { System.loadLibrary("pulse-java"); } @@ -49,6 +51,21 @@ super(name, eventLoop); } + public void open() { + super.open(); + + PulseAudioMixer parent = PulseAudioMixer.getInstance(); + parent.addSourceLine(this); + } + + public void close() { + + PulseAudioMixer parent = PulseAudioMixer.getInstance(); + parent.removeSourceLine(this); + + super.close(); + } + public native byte[] native_setVolume(float newValue); public synchronized native byte[] native_updateVolumeInfo(); @@ -57,5 +74,7 @@ public javax.sound.sampled.Line.Info getLineInfo() { return new Port.Info(Port.class, getName(), false); } + + } diff -r 5108fc37a890 -r ea894778a6d0 src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Wed Oct 08 16:06:00 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetPort.java Thu Oct 09 15:35:27 2008 -0400 @@ -41,6 +41,8 @@ public class PulseAudioTargetPort extends PulseAudioPort { + /* aka speaker */ + static { System.loadLibrary("pulse-java"); } @@ -49,6 +51,21 @@ super(name, eventLoop); } + public void open() { + super.open(); + + PulseAudioMixer parent = PulseAudioMixer.getInstance(); + parent.addTargetLine(this); + } + + public void close() { + + PulseAudioMixer parent = PulseAudioMixer.getInstance(); + parent.removeTargetLine(this); + + super.close(); + } + public native byte[] native_setVolume(float newValue); public synchronized native byte[] native_updateVolumeInfo();