# HG changeset patch # User Omair Majid # Date 1223494011 14400 # Node ID 4e6c0e204d2927f867ad354d2d2329e813bc7d1e # Parent 6ac2c3df7588002d5f69f56367e27039b176f936 2008-10-08 Omair Majid * src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java (createStream): Pick a random sample rate if none given. * src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java (getSupportedFormats): New channel numbers. These numbers actually have a source. * unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java (testSourceLinesOpenAndClose): Removed debug output. (testTargetLinesOpenAndClose): Likewise. diff -r 6ac2c3df7588 -r 4e6c0e204d29 src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Wed Oct 08 13:57:49 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java Wed Oct 08 15:26:51 2008 -0400 @@ -94,11 +94,31 @@ for (AudioFormat myFormat : supportedFormats) { if (format.matches(myFormat)) { + /* + * A few issues with format: + * + * To match: SAME encoding: safe because its a java enum. SAME + * number of channels: safe because myFormat has specific + * values. SAME bits per sample (aka sampleSize) and bytes per + * frame (aka frameSize): safe because myFormat has specific + * values. SAME sample rate: _not_ safe because myFormat uses + * AudioSystem.NOT_SPECIFIED. SAME frame rate: safe because we + * _ignore_ it completely ;) + * + * + */ + + float sampleRate = format.getSampleRate(); + if (sampleRate == (float) AudioSystem.NOT_SPECIFIED) { + /* pick a random sample rate */ + sampleRate = 44100.0f; + } + synchronized (eventLoop.threadLock) { stream = new Stream(eventLoop.getContextPointer(), streamName, Stream.Format.valueOf((String) myFormat .getProperty(PULSEAUDIO_FORMAT_KEY)), - (int) format.getSampleRate(), format.getChannels()); + (int) sampleRate, myFormat.getChannels()); } currentFormat = format; @@ -371,7 +391,9 @@ * underrun/overflow. * * - * HOWEVER, the javadocs say the opposite thing! + * HOWEVER, the javadocs say the opposite thing! (need help from the jck = + * official spec) + * * */ diff -r 6ac2c3df7588 -r 4e6c0e204d29 src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java --- a/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Oct 08 13:57:49 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java Wed Oct 08 15:26:51 2008 -0400 @@ -104,7 +104,7 @@ StreamBufferAttributes.MAX_VALUE)); refreshSourceAndTargetLines(); - + } synchronized public static PulseAudioMixer getInstance() { @@ -121,12 +121,21 @@ Map properties; /* - * frameSize = sample size (in bytes, not bits) x # of channels ^ From - * PulseAudio's sources + * frameSize = sample size (in bytes, not bits) x # of channels + * + * From PulseAudio's sources * http://git.0pointer.de/?p=pulseaudio.git;a=blob;f=src/pulse/sample.c;h=93da2465f4301e27af4976e82737c3a048124a68;hb=82ea8dde8abc51165a781c69bc3b38034d62d969#l63 */ - int[] channelSizes = new int[] { 1, 2, 5, 6, 8 }; + /* + * technically, PulseAudio supports up to 16 channels, but things get + * interesting with channel maps + * + * PA_CHANNEL_MAP_DEFAULT (=PA_CHANNEL_MAP_AIFF) supports 1,2,3,4,5 or 6 + * channels only + * + */ + 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"); diff -r 6ac2c3df7588 -r 4e6c0e204d29 unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java --- a/unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java Wed Oct 08 13:57:49 2008 -0400 +++ b/unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java Wed Oct 08 15:26:51 2008 -0400 @@ -292,7 +292,6 @@ try { Line sourceLine = selectedMixer.getLine(lineInfo); sourceLine.open(); - System.out.println("closing line"); sourceLine.close(); } catch (IllegalArgumentException e) { // ignore this @@ -311,15 +310,12 @@ TargetDataLine targetLine = (TargetDataLine) selectedMixer .getLine(lineInfo); Assert.assertNotNull(targetLine); - System.out.println("opening line"); targetLine.open(aSupportedFormat); - System.out.println("closing line"); targetLine.close(); } catch (ClassCastException cce) { Port targetLine = (Port) selectedMixer.getLine(lineInfo); Assert.assertNotNull(targetLine); targetLine.open(); - System.out.println("closing line"); targetLine.close(); }