Mercurial > hg > pulseaudio
changeset 172:0a46fbaa018e
2008-10-08 Omair Majid <omajid@redhat.com>
* src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java
(PulseAudioMixer): Call refreshSourceAndTargetLines to initialize
sourceLines and targetLines.
(getLine): Check that a line is supported before worrying about whether
the mixer is open.
* unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java
New variable aNotSupportedFormat that represents a known format that does
not work with PulseAudio*DataLine.
(testLineSupportedWorksWithoutOpeningMixer): New test. Checks that
isLineSupported works without depending on the mixer to be open.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Wed, 08 Oct 2008 12:30:00 -0400 |
parents | a3a8e9e19967 |
children | 6ac2c3df7588 |
files | src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java |
diffstat | 2 files changed, 24 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Oct 08 10:38:29 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Oct 08 12:30:00 2008 -0400 @@ -103,6 +103,8 @@ formats, StreamBufferAttributes.MIN_VALUE, StreamBufferAttributes.MAX_VALUE)); + refreshSourceAndTargetLines(); + } synchronized public static PulseAudioMixer getInstance() { @@ -252,17 +254,16 @@ } @Override - public Line getLine(javax.sound.sampled.Line.Info info) - throws LineUnavailableException { + public Line getLine(Line.Info info) throws LineUnavailableException { + + if (!isLineSupported(info)) { + throw new IllegalArgumentException("Line unsupported: " + info); + } if (!isOpen) { throw new LineUnavailableException("The mixer isnt open"); } - if (!isLineSupported(info)) { - throw new IllegalArgumentException("Line unsupported: " + info); - } - AudioFormat[] formats = null; AudioFormat defaultFormat = null; @@ -324,7 +325,7 @@ if (isLineSupported(info)) { return AudioSystem.NOT_SPECIFIED; } - + return 0; }
--- a/unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java Wed Oct 08 10:38:29 2008 -0400 +++ b/unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java Wed Oct 08 12:30:00 2008 -0400 @@ -39,6 +39,7 @@ import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; import javax.sound.sampled.Line; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineListener; @@ -60,6 +61,8 @@ AudioFormat aSupportedFormat = new AudioFormat( AudioFormat.Encoding.PCM_UNSIGNED, 44100f, 8, 1, 1, 44100f, true); + AudioFormat aNotSupportedFormat = new AudioFormat( + AudioFormat.Encoding.ULAW, 44100, 32, 10, 10, 44100f, true); @Before public void setUp() throws Exception { @@ -367,6 +370,19 @@ } @Test + public void testLineSupportedWorksWithoutOpeningMixer() { + + Assert.assertFalse(selectedMixer.isOpen()); + + Assert.assertFalse(selectedMixer.isLineSupported(new DataLine.Info( + SourceDataLine.class, aNotSupportedFormat))); + + Assert.assertTrue(selectedMixer.isLineSupported(new DataLine.Info( + SourceDataLine.class, aSupportedFormat))); + + } + + @Test public void testSynchronizationNotSupported() throws LineUnavailableException { selectedMixer.open();