changeset in /hg/icedtea6: Updated Gervill from upstream CVS (Se...

Mark Wielaard mark at klomp.org
Thu Sep 11 11:48:02 PDT 2008


changeset 8b0e11483252 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=8b0e11483252
description:
	Updated Gervill from upstream CVS (September 1, 2008)

	2008-09-11  Mark Wielaard  <mark at klomp.org>

	        * patches/icedtea-gervill.patch: Updated patch for old tests.
	        * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/*:
	        New Gervill files (sept 1).

	- Add: More JTreg tests added:
	         EmergencySoundbank
	         SoftFilter
	         AudioFloatConverter.ToFloatArray (improved)
	- Change: SoftReverb optimized, about 2 times faster.
	- Fix: ModelByteBuffer.skip called super.skip
	       instead to call to RandomAccessFile directly.
	       JTreg tests added: ModelByteBuffer/RandomFileInputStream/*.java
	- Fix: ModelByteBuffer.len was being modified in inner
	       class RandomFileInputStream. The variable was made final
	       and RandomFileInputStream.read methods where fixed.
	- Fix: ArrayOutOfException error in ModelInstrument.getKeys(),
	       Keys array was to small, it couldn't
	       hold all possible midi notes (0..127).

	Version 1.0.1
	- Fix: Created dummy SourceDataline so that following
	     jtreg test can be tested without using
	     a real Audio Device SourceDataLine.
	        javax/sound/midi/Gervill/SoftAudioSynthesizer/Open.java
	        javax/sound/midi/Gervill/SoftSynthesizer/GetLatency.java
	        javax/sound/midi/Gervill/SoftSynthesizer/GetReceiver.java
	        javax/sound/midi/Gervill/SoftSynthesizer/GetReceiver2.java
	        javax/sound/midi/Gervill/SoftSynthesizer/GetReceivers.java
	        javax/sound/midi/Gervill/SoftSynthesizer/GetTransmitter.java
	        javax/sound/midi/Gervill/SoftSynthesizer/GetTransmitters.java
	        javax/sound/midi/Gervill/SoftSynthesizer/ImplicitOpenClose.java
	        javax/sound/midi/Gervill/SoftSynthesizer/Open.java
	- Fix: Make open SoftSynthesizer garbage-collectable
	       when user don't have reference to it and it is not
	       producing any sound.
	- Fix: SoftReverb silent detection improved.
	- Added: SoftSynthesizer.getPropertyInfo returns
	         current properties values if it is open.
	- Fix: Restrict input values in SoftChannel to 7 and 14 bit in these methods:
	          noteOn
	          noteOff
	          setPolyPressure
	          setChannelPressure
	          controlChange
	          programChange(program)
	          programChange(bank, program)
	          setPitchBend
	- Fix: Store generated soundbank to disk for faster future use.

diffstat:

21 files changed, 727 insertions(+), 218 deletions(-)
ChangeLog                                                                            |    6 
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt               |   44 +
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java      |   26 
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java      |    4 
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java          |   52 +
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java   |    2 
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java        |   51 +
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java      |   56 +
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java           |  341 +++++-----
overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java      |  220 +++++-
overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatConverter/ToFloatArray.java  |   29 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/Open.java         |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetLatency.java        |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceiver.java       |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceiver2.java      |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceivers.java      |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetTransmitter.java    |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetTransmitters.java   |    2 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/ImplicitOpenClose.java |    6 
overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/Open.java              |    6 
patches/icedtea-gervill.patch                                                        |   88 ++

diffs (truncated from 1627 to 500 lines):

diff -r aacc3e8a8e16 -r 8b0e11483252 ChangeLog
--- a/ChangeLog	Wed Sep 10 13:37:08 2008 -0400
+++ b/ChangeLog	Thu Sep 11 20:47:50 2008 +0200
@@ -1,3 +1,9 @@ 2008-09-10  Lillian Angel  <langel at redha
+2008-09-11  Mark Wielaard  <mark at klomp.org>
+
+	* patches/icedtea-gervill.patch: Updated patch for old tests.
+	* overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/*:
+	New Gervill files (sept 1).
+
 2008-09-10  Lillian Angel  <langel at redhat.com>
 
 	* patches/icedtea-lc_ctype.patch: New patch to fix this issue:
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt	Thu Sep 11 20:47:50 2008 +0200
@@ -1,3 +1,47 @@
+  - Add: More JTreg tests added:
+           EmergencySoundbank
+           SoftFilter
+           AudioFloatConverter.ToFloatArray (improved)
+  - Change: SoftReverb optimized, about 2 times faster.
+  - Fix: ModelByteBuffer.skip called super.skip
+         instead to call to RandomAccessFile directly.
+         JTreg tests added: ModelByteBuffer/RandomFileInputStream/*.java
+  - Fix: ModelByteBuffer.len was being modified in inner
+         class RandomFileInputStream. The variable was made final
+         and RandomFileInputStream.read methods where fixed.
+  - Fix: ArrayOutOfException error in ModelInstrument.getKeys(),
+         Keys array was to small, it couldn't
+         hold all possible midi notes (0..127).
+
+Version 1.0.1
+  - Fix: Created dummy SourceDataline so that following 
+         jtreg test can be tested without using
+         a real Audio Device SourceDataLine.  
+            javax/sound/midi/Gervill/SoftAudioSynthesizer/Open.java
+            javax/sound/midi/Gervill/SoftSynthesizer/GetLatency.java
+            javax/sound/midi/Gervill/SoftSynthesizer/GetReceiver.java
+            javax/sound/midi/Gervill/SoftSynthesizer/GetReceiver2.java
+            javax/sound/midi/Gervill/SoftSynthesizer/GetReceivers.java
+            javax/sound/midi/Gervill/SoftSynthesizer/GetTransmitter.java
+            javax/sound/midi/Gervill/SoftSynthesizer/GetTransmitters.java
+            javax/sound/midi/Gervill/SoftSynthesizer/ImplicitOpenClose.java
+            javax/sound/midi/Gervill/SoftSynthesizer/Open.java
+  - Fix: Make open SoftSynthesizer garbage-collectable
+         when user don't have reference to it and it is not
+         producing any sound.
+  - Fix: SoftReverb silent detection improved.
+  - Added: SoftSynthesizer.getPropertyInfo returns
+           current properties values if it is open.        
+  - Fix: Restrict input values in SoftChannel to 7 and 14 bit in these methods:
+            noteOn 
+            noteOff
+            setPolyPressure
+            setChannelPressure
+            controlChange
+            programChange(program)
+            programChange(bank, program)
+            setPitchBend
+  - Fix: Store generated soundbank to disk for faster future use.         
   - Cleanup: Make inner classes static 
               AudioFloatFormatConverter.AudioFloatFormatConverterInputStream
               AudioFloatFormatConverter.AudioFloatInputStreamChannelMixer
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java	Thu Sep 11 20:47:50 2008 +0200
@@ -45,7 +45,7 @@ public class ModelByteBuffer {
     private long fileoffset;
     private byte[] buffer;
     private long offset;
-    private long len;
+    private final long len;
 
     private class RandomFileInputStream extends InputStream {
 
@@ -85,11 +85,12 @@ public class ModelByteBuffer {
         }
 
         public long skip(long n) throws IOException {
+            if( n < 0)
+                return 0;
             if (n > left)
                 n = left;
-            n = super.skip(n);
-            if (n == -1)
-                return -1;
+            long p = raf.getFilePointer();
+            raf.seek(p + n);
             left -= n;
             return n;
         }
@@ -107,11 +108,12 @@ public class ModelByteBuffer {
         }
 
         public int read(byte[] b) throws IOException {
+            int len = b.length;
             if (len > left)
                 len = (int)left;
             if (left == 0)
                 return -1;
-            int len = raf.read(b);
+            len = raf.read(b, 0, len);
             if (len == -1)
                 return -1;
             left -= len;
@@ -119,12 +121,12 @@ public class ModelByteBuffer {
         }
 
         public int read() throws IOException {
-            if (len == 0)
+            if (left == 0)
                 return -1;
             int b = raf.read();
             if (b == -1)
                 return -1;
-            len--;
+            left--;
             return b;
         }
 
@@ -137,15 +139,15 @@ public class ModelByteBuffer {
             long beginIndex, long endIndex, boolean independent) {
         this.root = parent.root;
         this.offset = 0;
-        this.len = parent.len;
+        long parent_len = parent.len;
         if (beginIndex < 0)
             beginIndex = 0;
-        if (beginIndex > len)
-            beginIndex = len;
+        if (beginIndex > parent_len)
+            beginIndex = parent_len;
         if (endIndex < 0)
             endIndex = 0;
-        if (endIndex > len)
-            endIndex = len;
+        if (endIndex > parent_len)
+            endIndex = parent_len;
         if (beginIndex > endIndex)
             beginIndex = endIndex;
         offset = beginIndex;
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java	Thu Sep 11 20:47:50 2008 +0200
@@ -88,10 +88,10 @@ public abstract class ModelInstrument ex
     // This information is generated from ModelPerformer.getName()
     // returned from getPerformers().
     public String[] getKeys() {
-        String[] keys = new String[127];
+        String[] keys = new String[128];
         for (ModelPerformer performer : getPerformers()) {
             for (int k = performer.getKeyFrom(); k <= performer.getKeyTo(); k++) {
-                if (keys[k] == null) {
+                if (k >= 0 && k < 128 && keys[k] == null) {
                     String name = performer.getName();
                     if (name == null)
                         name = "untitled";
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java	Thu Sep 11 20:47:50 2008 +0200
@@ -194,6 +194,20 @@ public class SoftChannel implements Midi
             return v;
         }
     };
+    
+    private static int restrict7Bit(int value)
+    {
+        if(value < 0) return 0;
+        if(value > 127) return 127;
+        return value;
+    }
+    
+    private static int restrict14Bit(int value)
+    {
+        if(value < 0) return 0;
+        if(value > 16256) return 16256;
+        return value;
+    }
 
     public SoftChannel(SoftSynthesizer synth, int channel) {
         this.channel = channel;
@@ -386,8 +400,8 @@ public class SoftChannel implements Midi
     }
 
     public void noteOn(int noteNumber, int velocity) {
-
-        if(noteNumber < 0 || noteNumber > 127) return;
+        noteNumber = restrict7Bit(noteNumber);
+        velocity = restrict7Bit(velocity);        
         noteOn_internal(noteNumber, velocity);
         if (current_mixer != null)
             current_mixer.noteOn(noteNumber, velocity);
@@ -415,7 +429,7 @@ public class SoftChannel implements Midi
                 sustain = true;
             }
 
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+            mainmixer.activity();
 
             if (mono) {
                 if (portamento) {
@@ -515,7 +529,8 @@ public class SoftChannel implements Midi
     }
 
     public void noteOff(int noteNumber, int velocity) {
-        if(noteNumber < 0 || noteNumber > 127) return;
+        noteNumber = restrict7Bit(noteNumber);
+        velocity = restrict7Bit(velocity);        
         noteOff_internal(noteNumber, velocity);
 
         if (current_mixer != null)
@@ -534,7 +549,7 @@ public class SoftChannel implements Midi
                 }
             }
 
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+            mainmixer.activity();
             for (int i = 0; i < voices.length; i++) {
                 if (voices[i].on && voices[i].channel == channel
                         && voices[i].note == noteNumber
@@ -617,11 +632,14 @@ public class SoftChannel implements Midi
     }
 
     public void setPolyPressure(int noteNumber, int pressure) {
+        noteNumber = restrict7Bit(noteNumber);
+        pressure = restrict7Bit(pressure);        
+
         if (current_mixer != null)
             current_mixer.setPolyPressure(noteNumber, pressure);
 
         synchronized (control_mutex) {
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+            mainmixer.activity();
             co_midi[noteNumber].get(0, "poly_pressure")[0] = pressure*(1.0/128.0);
             polypressure[noteNumber] = pressure;
             for (int i = 0; i < voices.length; i++) {
@@ -637,11 +655,12 @@ public class SoftChannel implements Midi
         }
     }
 
-    public void setChannelPressure(int pressure) {
+    public void setChannelPressure(int pressure) {        
+        pressure = restrict7Bit(pressure);                
         if (current_mixer != null)
             current_mixer.setChannelPressure(pressure);
         synchronized (control_mutex) {
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+            mainmixer.activity();
             co_midi_channel_pressure[0] = pressure * (1.0 / 128.0);
             channelpressure = pressure;
             for (int i = 0; i < voices.length; i++) {
@@ -1006,6 +1025,8 @@ 121  |79H   |**Coarse Tuning          |0
     }
 
     public void controlChange(int controller, int value) {
+        controller = restrict7Bit(controller);
+        value = restrict7Bit(value);
         if (current_mixer != null)
             current_mixer.controlChange(controller, value);
 
@@ -1210,13 +1231,15 @@ 121  |79H   |**Coarse Tuning          |0
         }
     }
 
-    public void programChange(int program) {
+    public void programChange(int program) {        
         programChange(bank, program);
     }
 
     public void programChange(int bank, int program) {
-        synchronized (control_mutex) {
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+        bank = restrict7Bit(bank);
+        program = restrict7Bit(program);        
+        synchronized (control_mutex) {
+            mainmixer.activity();
             this.bank = bank;
             this.program = program;
             current_instrument = null;
@@ -1230,10 +1253,11 @@ 121  |79H   |**Coarse Tuning          |0
     }
 
     public void setPitchBend(int bend) {
-        if (current_mixer != null)
+        bend = restrict14Bit(bend);
+        if (current_mixer != null)            
             current_mixer.setPitchBend(bend);
         synchronized (control_mutex) {
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+            mainmixer.activity();
             co_midi_pitch[0] = bend * (1.0 / 16384.0);
             pitchbend = bend;
             for (int i = 0; i < voices.length; i++)
@@ -1349,7 +1373,7 @@ 121  |79H   |**Coarse Tuning          |0
 
     public void resetAllControllers(boolean allControls) {
         synchronized (control_mutex) {
-            mainmixer.msec_last_activity = mainmixer.msec_pos;
+            mainmixer.activity();
 
             for (int i = 0; i < 128; i++) {
                 setPolyPressure(i, 0);
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java	Thu Sep 11 20:47:50 2008 +0200
@@ -5,7 +5,7 @@
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Sun designates this
- * particular file as suabject to the "Classpath" exception as provided
+ * particular file as subject to the "Classpath" exception as provided
  * by Sun in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Thu Sep 11 20:47:50 2008 +0200
@@ -59,15 +59,17 @@ public class SoftMainMixer {
     public final static int CHANNEL_CHANNELMIXER_LEFT = 14;
     public final static int CHANNEL_CHANNELMIXER_RIGHT = 15;
     protected boolean active_sensing_on = false;
-    protected long msec_last_activity = -1;
-    protected long msec_pos = 0;
+    private long msec_last_activity = -1;
+    private boolean pusher_silent = false;
+    private int pusher_silent_count = 0;
+    private long msec_pos = 0;
     protected boolean readfully = true;
     private Object control_mutex;
     private SoftSynthesizer synth;
     private int nrofchannels = 2;
     private SoftVoice[] voicestatus = null;
     private SoftAudioBuffer[] buffers;
-    private SoftAudioProcessor reverb;
+    private SoftReverb reverb;
     private SoftAudioProcessor chorus;
     private SoftAudioProcessor agc;
     private long msec_buffer_len = 0;
@@ -106,7 +108,7 @@ public class SoftMainMixer {
 
     private void processSystemExclusiveMessage(byte[] data) {
         synchronized (synth.control_mutex) {
-            msec_last_activity = msec_pos;
+            activity();
 
             // Universal Non-Real-Time SysEx
             if ((data[1] & 0xFF) == 0x7E) {
@@ -597,10 +599,39 @@ public class SoftMainMixer {
 
             }
         }
+        
+        if(buffers[CHANNEL_LEFT].isSilent()
+            && buffers[CHANNEL_RIGHT].isSilent())
+        {            
+            pusher_silent_count++;
+            if(pusher_silent_count > 5)
+            {
+                pusher_silent_count = 0;
+                synchronized (control_mutex) {
+                    pusher_silent = true;
+                    if(synth.weakstream != null)
+                        synth.weakstream.setInputStream(null);
+                }                    
+            }
+        }
+        else
+            pusher_silent_count = 0;
 
         if (synth.agc_on)
             agc.processAudio();
 
+    }
+        
+    // Must only we called within control_mutex synchronization
+    public void activity()
+    {        
+        msec_last_activity = msec_pos;
+        if(pusher_silent)
+        {
+            pusher_silent = false;
+            if(synth.weakstream != null)
+                synth.weakstream.setInputStream(ais);
+        }
     }
 
     public void stopMixer(ModelChannelMixer mixer) {
@@ -650,6 +681,8 @@ public class SoftMainMixer {
         chorus.init(samplerate, controlrate);
         agc.init(samplerate, controlrate);
 
+        reverb.setLightMode(synth.reverb_light);
+        
         reverb.setMixMode(true);
         chorus.setMixMode(true);
         agc.setMixMode(false);
@@ -686,7 +719,13 @@ public class SoftMainMixer {
             private byte[] single = new byte[1];
 
             public void fillBuffer() {
-                processAudioBuffers();
+                /*
+                boolean pusher_silent2;
+                synchronized (control_mutex) {
+                    pusher_silent2 = pusher_silent;
+                }
+                if(!pusher_silent2)*/
+                processAudioBuffers(); 
                 for (int i = 0; i < nrofchannels; i++)
                     buffers[i].get(bbuffer, i);
                 bbuffer_pos = 0;
@@ -884,7 +923,7 @@ public class SoftMainMixer {
 
     public void processMessage(int ch, int cmd, int data1, int data2) {
         synchronized (synth.control_mutex) {
-            msec_last_activity = msec_pos;
+            activity();
         }
 
         if (cmd == 0xF0) {
diff -r aacc3e8a8e16 -r 8b0e11483252 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java	Wed Sep 10 13:37:08 2008 -0400
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java	Thu Sep 11 20:47:50 2008 +0200
@@ -62,7 +62,7 @@ public class SoftMixingMixer implements 
 
     protected static final String INFO_DESCRIPTION = "Software Sound Mixer";
 
-    protected static final String INFO_VERSION = "0.9";
+    protected static final String INFO_VERSION = "1.0";
 
     protected final static Mixer.Info info = new Info();
 
@@ -354,9 +354,6 @@ public class SoftMixingMixer implements 
                 AudioInputStream ais = openStream(getFormat());
 
                 if (line == null) {
-                    DataLine.Info info = new DataLine.Info(
-                            SourceDataLine.class, format);
-
                     synchronized (SoftMixingMixerProvider.mutex) {
                         SoftMixingMixerProvider.lockthread = Thread
                                 .currentThread();
@@ -365,8 +362,55 @@ public class SoftMixingMixer implements 
                     try {
                         Mixer defaultmixer = AudioSystem.getMixer(null);
                         if (defaultmixer != null)
-                            line = (SourceDataLine) defaultmixer.getLine(info);
-                        else
+                        {
+                            // Search for suitable line
+                            
+                            DataLine.Info idealinfo = null;
+                            AudioFormat idealformat = null;
+                            
+                            Line.Info[] lineinfos = defaultmixer.getSourceLineInfo();
+                            idealFound:
+                            for (int i = 0; i < lineinfos.length; i++) {
+                                if(lineinfos[i].getLineClass() == SourceDataLine.class)
+                                {
+                                    DataLine.Info info = (DataLine.Info)lineinfos[i];
+                                    AudioFormat[] formats = info.getFormats();
+                                    for (int j = 0; j < formats.length; j++) {
+                                        AudioFormat format = formats[j];
+                                        if(format.getChannels() == 2 || 
+                                                format.getChannels() == AudioSystem.NOT_SPECIFIED)
+                                        if(format.getEncoding().equals(Encoding.PCM_SIGNED) || 
+                                                format.getEncoding().equals(Encoding.PCM_UNSIGNED))
+                                        if(format.getSampleRate() == AudioSystem.NOT_SPECIFIED || 
+                                                format.getSampleRate() == 48000.0)
+                                        if(format.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED || 
+                                                format.getSampleSizeInBits() == 16)
+                                        {
+                                            idealinfo = info;
+                                            int ideal_channels = format.getChannels();
+                                            boolean ideal_signed = format.getEncoding().equals(Encoding.PCM_SIGNED); 
+                                            float ideal_rate = format.getSampleRate();
+                                            boolean ideal_endian = format.isBigEndian();                                            
+                                            int ideal_bits = format.getSampleSizeInBits();                                            
+                                            if(ideal_bits == AudioSystem.NOT_SPECIFIED) ideal_bits = 16;
+                                            if(ideal_channels == AudioSystem.NOT_SPECIFIED) ideal_channels = 2;
+                                            if(ideal_rate == AudioSystem.NOT_SPECIFIED) ideal_rate = 48000;
+                                            idealformat = new AudioFormat(ideal_rate, ideal_bits, 
+                                                    ideal_channels, ideal_signed, ideal_endian);
+                                            break idealFound;
+                                        }
+                                    }
+                                }                                    
+                            }
+                            
+                            if(idealformat != null)
+                            {
+                                format = idealformat;
+                                line = (SourceDataLine) defaultmixer.getLine(idealinfo);
+                            }
+                        }
+                        
+                        if(line == null)
                             line = AudioSystem.getSourceDataLine(format);
                     } finally {



More information about the distro-pkg-dev mailing list