changeset in /hg/pulseaudio: 2008-10-08 Omair Majid <omajid at redh...
Omair Majid
omajid at redhat.com
Wed Oct 8 12:27:47 PDT 2008
changeset 4e6c0e204d29 in /hg/pulseaudio
details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=4e6c0e204d29
description:
2008-10-08 Omair Majid <omajid at redhat.com>
* 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.
diffstat:
3 files changed, 37 insertions(+), 10 deletions(-)
src/java/org/classpath/icedtea/pulseaudio/PulseAudioDataLine.java | 26 +++++++++-
src/java/org/classpath/icedtea/pulseaudio/PulseAudioMixer.java | 17 +++++-
unittests/org/classpath/icedtea/pulseaudio/PulseAudioMixerTest.java | 4 -
diffs (111 lines):
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 @@ public abstract class PulseAudioDataLine
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 @@ public abstract class PulseAudioDataLine
* 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 @@ public class PulseAudioMixer implements
StreamBufferAttributes.MAX_VALUE));
refreshSourceAndTargetLines();
-
+
}
synchronized public static PulseAudioMixer getInstance() {
@@ -121,12 +121,21 @@ public class PulseAudioMixer implements
Map<String, Object> 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<String, Object>();
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 @@ public class PulseAudioMixerTest {
try {
Line sourceLine = selectedMixer.getLine(lineInfo);
sourceLine.open();
- System.out.println("closing line");
sourceLine.close();
} catch (IllegalArgumentException e) {
// ignore this
@@ -311,15 +310,12 @@ public class PulseAudioMixerTest {
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();
}
More information about the distro-pkg-dev
mailing list