changeset 1886:3fdc1dee7f86

Merge
author Andrew John Hughes <ahughes@redhat.com>
date Wed, 02 Dec 2009 17:58:28 +0000
parents ac0296b09732 (current diff) eb51df7af234 (diff)
children b00255fb507b
files ChangeLog
diffstat 13 files changed, 413 insertions(+), 148 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Nov 23 13:38:58 2009 +0000
+++ b/ChangeLog	Wed Dec 02 17:58:28 2009 +0000
@@ -1,3 +1,20 @@
+2009-11-27  Deepak Bhole <dbhole@redhat.com>
+
+	* plugin/icedtea/sun/applet/PluginAppletViewer.java
+	(getWindow): Fortify condition for	wait for panel initialization.
+	(parse): Handle nested objected tags, don't allow parameter value
+	overwrite.
+	* rt/net/sourceforge/jnlp/Launcher.java
+	(createApplet): Set context classloader for the thread to the applet's
+	classloader, so that getContextClassLoader calls succeed.
+
+2009-11-25  Gary Benson  <gbenson@redhat.com>
+
+	* ports/hotspot/src/cpu/zero/vm/entry_zero.hpp 
+	(ZeroEntry::entry_point): Removed explicit inline.
+	(ZeroEntry::invoke): Likewise.
+	(ZeroEntry::invoke_osr): Likewise.
+
 2009-11-23  Andrew John Hughes  <ahughes@redhat.com>
 
 	* Makefile.am:
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt	Wed Dec 02 17:58:28 2009 +0000
@@ -1,3 +1,6 @@
+6833357: Improve time-stamp support in Gervill to reduce jitter.
+6823449: Gervill: ArrayIndexOutOfBoundsException thrown when trying to
+6806019: 38 JCK api/javax_sound/midi/ tests fails starting from jdk7 b46
 6823446: Gervill SoftLowFrequencyOscillator fails when freq is set to 0 cent or 8.1758 Hz.
 6823445: Gervill SoftChannel/ResetAllControllers jtreg test fails after portamento fix from last merge. 
 6821030: Merge OpenJDK Gervill with upstream sources, Q1CY2009
@@ -307,4 +310,4 @@
   - General Midi Level 2
   - MIDI Tuning Standard
   - Drumkits can be used on any channel
-  - Sinc interpolation with anti-aliasing
\ No newline at end of file
+  - Sinc interpolation with anti-aliasing
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java	Wed Dec 02 17:58:28 2009 +0000
@@ -47,6 +47,30 @@
         this.format = format;
         converter = AudioFloatConverter.getConverter(format);
     }
+    
+    public void swap(SoftAudioBuffer swap)
+    {
+        int bak_size = size;
+        float[] bak_buffer = buffer;
+        boolean bak_empty = empty;
+        AudioFormat bak_format = format;
+        AudioFloatConverter bak_converter = converter;
+        byte[] bak_converter_buffer = converter_buffer;
+        
+        size = swap.size;
+        buffer = swap.buffer;
+        empty = swap.empty;
+        format = swap.format;
+        converter = swap.converter;
+        converter_buffer = swap.converter_buffer;
+        
+        swap.size = bak_size;
+        swap.buffer = bak_buffer;
+        swap.empty = bak_empty;
+        swap.format = bak_format;
+        swap.converter = bak_converter;
+        swap.converter_buffer = bak_converter_buffer;
+    }
 
     public AudioFormat getFormat() {
         return format;
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java	Wed Dec 02 17:58:28 2009 +0000
@@ -218,6 +218,15 @@
     }
 
     private int findFreeVoice(int x) {
+        if(x == -1)
+        {
+            // x = -1 means that there where no available voice
+            // last time we called findFreeVoice  
+            // and it hasn't changed because no audio has been 
+            // rendered in the meantime.
+            // Therefore we have to return -1.
+            return -1;
+        }
         for (int i = x; i < voices.length; i++)
             if (!voices[i].active)
                 return i;
@@ -285,9 +294,9 @@
         } else {
             // Default Voice Allocation
             //  * Find voice that is on
-            //  	and Find voice which has lowest voiceID ( oldest voice)
+            //      and Find voice which has lowest voiceID ( oldest voice)
             //  * Or find voice that is off
-            //  	and Find voice which has lowest voiceID ( oldest voice)
+            //      and Find voice which has lowest voiceID ( oldest voice)
 
             int voiceNo = -1;
 
@@ -328,7 +337,7 @@
     }
 
     protected void initVoice(SoftVoice voice, SoftPerformer p, int voiceID,
-            int noteNumber, int velocity, ModelConnectionBlock[] connectionBlocks,
+            int noteNumber, int velocity, int delay, ModelConnectionBlock[] connectionBlocks,
             ModelChannelMixer channelmixer, boolean releaseTriggered) {
         if (voice.active) {
             // Voice is active , we must steal the voice
@@ -363,7 +372,7 @@
         voice.objects.put("midi_cc", co_midi_cc);
         voice.objects.put("midi_rpn", co_midi_rpn);
         voice.objects.put("midi_nrpn", co_midi_nrpn);
-        voice.noteOn(noteNumber, velocity);
+        voice.noteOn(noteNumber, velocity, delay);
         voice.setMute(mute);
         voice.setSoloMute(solomute);
         if (releaseTriggered)
@@ -399,14 +408,21 @@
     }
 
     public void noteOn(int noteNumber, int velocity) {
+        noteOn(noteNumber, velocity, 0);
+    }
+    
+    /* A special noteOn with delay parameter, which is used to
+     * start note within control buffers.   
+     */
+    protected void noteOn(int noteNumber, int velocity, int delay) {
         noteNumber = restrict7Bit(noteNumber);
         velocity = restrict7Bit(velocity);        
-        noteOn_internal(noteNumber, velocity);
+        noteOn_internal(noteNumber, velocity, delay);
         if (current_mixer != null)
             current_mixer.noteOn(noteNumber, velocity);
     }
 
-    private void noteOn_internal(int noteNumber, int velocity) {
+    private void noteOn_internal(int noteNumber, int velocity, int delay) {
 
         if (velocity == 0) {
             noteOff_internal(noteNumber, 64);
@@ -490,6 +506,7 @@
             int tunedKey = (int)(Math.round(tuning.getTuning()[noteNumber]/100.0));
             play_noteNumber = noteNumber;
             play_velocity = velocity;
+            play_delay = delay;
             play_releasetriggered = false;
             lastVelocity[noteNumber] = velocity;
             current_director.noteOn(tunedKey, velocity);
@@ -594,6 +611,7 @@
             play_noteNumber = noteNumber;
             play_velocity = lastVelocity[noteNumber];
             play_releasetriggered = true;
+            play_delay = 0;
             current_director.noteOff(tunedKey, velocity);
 
         }
@@ -604,12 +622,14 @@
     private int voiceNo = 0;
     private int play_noteNumber = 0;
     private int play_velocity = 0;
+    private int play_delay = 0;
     private boolean play_releasetriggered = false;
 
     public void play(int performerIndex, ModelConnectionBlock[] connectionBlocks) {
 
         int noteNumber = play_noteNumber;
         int velocity = play_velocity;
+        int delay = play_delay;
         boolean releasetriggered = play_releasetriggered;
 
         SoftPerformer p = current_instrument.getPerformers()[performerIndex];
@@ -633,7 +653,7 @@
         if (voiceNo == -1)
             return;
 
-        initVoice(voices[voiceNo], p, prevVoiceID, noteNumber, velocity,
+        initVoice(voices[voiceNo], p, prevVoiceID, noteNumber, velocity, delay,
                 connectionBlocks, current_mixer, releasetriggered);
     }
 
@@ -1212,7 +1232,7 @@
 
             this.controller[controller] = value;
             if(controller < 0x20)
-                this.controller[controller + 0x20] = 0;	
+                this.controller[controller + 0x20] = 0; 
 
             for (int i = 0; i < voices.length; i++)
                 if (voices[i].active)
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java	Wed Dec 02 17:58:28 2009 +0000
@@ -79,7 +79,7 @@
             if (silentcounter > 60) {
                 if (!mix) {
                     bufferLout.clear();
-                    bufferRout.clear();
+                    if(bufferRout != null) bufferRout.clear();
                 }
                 return;
             }
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Wed Dec 02 17:58:28 2009 +0000
@@ -26,7 +26,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -46,28 +45,37 @@
  */
 public class SoftMainMixer {
 
+    // A private class thats contains a ModelChannelMixer and it's private buffers.
+    // This becomes necessary when we want to have separate delay buffers for each channel mixer.
+    private class SoftChannelMixerContainer
+    {
+        ModelChannelMixer mixer;
+        SoftAudioBuffer[] buffers;
+    }
+    
     public final static int CHANNEL_LEFT = 0;
     public final static int CHANNEL_RIGHT = 1;
     public final static int CHANNEL_MONO = 2;
-    public final static int CHANNEL_EFFECT1 = 3;
-    public final static int CHANNEL_EFFECT2 = 4;
-    public final static int CHANNEL_EFFECT3 = 5;
-    public final static int CHANNEL_EFFECT4 = 6;
+    public final static int CHANNEL_DELAY_LEFT = 3;
+    public final static int CHANNEL_DELAY_RIGHT = 4;
+    public final static int CHANNEL_DELAY_MONO = 5;
+    public final static int CHANNEL_EFFECT1 = 6;
+    public final static int CHANNEL_EFFECT2 = 7;
+    public final static int CHANNEL_DELAY_EFFECT1 = 8;
+    public final static int CHANNEL_DELAY_EFFECT2 = 9;
     public final static int CHANNEL_LEFT_DRY = 10;
     public final static int CHANNEL_RIGHT_DRY = 11;
     public final static int CHANNEL_SCRATCH1 = 12;
     public final static int CHANNEL_SCRATCH2 = 13;
-    public final static int CHANNEL_CHANNELMIXER_LEFT = 14;
-    public final static int CHANNEL_CHANNELMIXER_RIGHT = 15;
-    public final static int CHANNEL_CHANNELMIXER_MONO = 16;
     protected boolean active_sensing_on = false;
     private long msec_last_activity = -1;
     private boolean pusher_silent = false;
     private int pusher_silent_count = 0;
-    private long msec_pos = 0;
+    private long sample_pos = 0;
     protected boolean readfully = true;
     private Object control_mutex;
     private SoftSynthesizer synth;
+    private float samplerate = 44100;
     private int nrofchannels = 2;
     private SoftVoice[] voicestatus = null;
     private SoftAudioBuffer[] buffers;
@@ -75,7 +83,10 @@
     private SoftAudioProcessor chorus;
     private SoftAudioProcessor agc;
     private long msec_buffer_len = 0;
+    private int buffer_len = 0;
     protected TreeMap<Long, Object> midimessages = new TreeMap<Long, Object>();
+    private int delay_midievent = 0;
+    private int max_delay_midievent = 0;
     double last_volume_left = 1.0;
     double last_volume_right = 1.0;
     private double[] co_master_balance = new double[1];
@@ -83,9 +94,9 @@
     private double[] co_master_coarse_tuning = new double[1];
     private double[] co_master_fine_tuning = new double[1];
     private AudioInputStream ais;
-    private Set<ModelChannelMixer> registeredMixers = null;
+    private Set<SoftChannelMixerContainer> registeredMixers = null;
     private Set<ModelChannelMixer> stoppedMixers = null;
-    private ModelChannelMixer[] cur_registeredMixers = null;
+    private SoftChannelMixerContainer[] cur_registeredMixers = null;
     protected SoftControl co_master = new SoftControl() {
 
         double[] balance = co_master_balance;
@@ -413,26 +424,68 @@
         Iterator<Entry<Long, Object>> iter = midimessages.entrySet().iterator();
         while (iter.hasNext()) {
             Entry<Long, Object> entry = iter.next();
-            if (entry.getKey() > (timeStamp + 100))
+            if (entry.getKey() >= (timeStamp + msec_buffer_len))
                 return;
+            long msec_delay = entry.getKey() - timeStamp;            
+            delay_midievent = (int)(msec_delay * (samplerate / 1000000.0) + 0.5);
+            if(delay_midievent > max_delay_midievent)
+                delay_midievent = max_delay_midievent;
+            if(delay_midievent < 0)
+                delay_midievent = 0;
             processMessage(entry.getValue());
             iter.remove();
         }
+        delay_midievent = 0;
     }
 
     protected void processAudioBuffers() {
-        for (int i = 0; i < buffers.length; i++) {
-            buffers[i].clear();
+
+        if(synth.weakstream != null && synth.weakstream.silent_samples != 0)
+        {
+            sample_pos += synth.weakstream.silent_samples;
+            synth.weakstream.silent_samples = 0;
+        }
+        
+        for (int i = 0; i < buffers.length; i++) {                        
+            if(i != CHANNEL_DELAY_LEFT && 
+                    i != CHANNEL_DELAY_RIGHT && 
+                    i != CHANNEL_DELAY_MONO &&
+                    i != CHANNEL_DELAY_EFFECT1 &&
+                    i != CHANNEL_DELAY_EFFECT2) 
+                buffers[i].clear();
+        }
+        
+        if(!buffers[CHANNEL_DELAY_LEFT].isSilent())
+        {
+            buffers[CHANNEL_LEFT].swap(buffers[CHANNEL_DELAY_LEFT]);
+        }
+        if(!buffers[CHANNEL_DELAY_RIGHT].isSilent())
+        {
+            buffers[CHANNEL_RIGHT].swap(buffers[CHANNEL_DELAY_RIGHT]);
+        }
+        if(!buffers[CHANNEL_DELAY_MONO].isSilent())
+        {
+            buffers[CHANNEL_MONO].swap(buffers[CHANNEL_DELAY_MONO]);
+        }
+        if(!buffers[CHANNEL_DELAY_EFFECT1].isSilent())
+        {
+            buffers[CHANNEL_EFFECT1].swap(buffers[CHANNEL_DELAY_EFFECT1]);
+        }
+        if(!buffers[CHANNEL_DELAY_EFFECT2].isSilent())
+        {
+            buffers[CHANNEL_EFFECT2].swap(buffers[CHANNEL_DELAY_EFFECT2]);
         }
 
         double volume_left;
         double volume_right;
 
-        ModelChannelMixer[] act_registeredMixers;
+        SoftChannelMixerContainer[] act_registeredMixers;
 
         // perform control logic
         synchronized (control_mutex) {
 
+            long msec_pos = (long)(sample_pos * (1000000.0 / samplerate));
+            
             processMessages(msec_pos);
 
             if (active_sensing_on) {
@@ -450,7 +503,7 @@
             for (int i = 0; i < voicestatus.length; i++)
                 if (voicestatus[i].active)
                     voicestatus[i].processControlLogic();
-            msec_pos += msec_buffer_len;
+            sample_pos += buffer_len;
 
             double volume = co_master_volume[0];
             volume_left = volume;
@@ -469,7 +522,7 @@
             if (cur_registeredMixers == null) {
                 if (registeredMixers != null) {
                     cur_registeredMixers =
-                            new ModelChannelMixer[registeredMixers.size()];
+                            new SoftChannelMixerContainer[registeredMixers.size()];
                     registeredMixers.toArray(cur_registeredMixers);
                 }
             }
@@ -483,49 +536,67 @@
 
         if (act_registeredMixers != null) {
 
-            // Reroute default left,right output
-            // to channelmixer left,right input/output
+            // Make backup of left,right,mono channels
             SoftAudioBuffer leftbak = buffers[CHANNEL_LEFT];
             SoftAudioBuffer rightbak = buffers[CHANNEL_RIGHT];
             SoftAudioBuffer monobak = buffers[CHANNEL_MONO];
-            buffers[CHANNEL_LEFT] = buffers[CHANNEL_CHANNELMIXER_LEFT];
-            buffers[CHANNEL_RIGHT] = buffers[CHANNEL_CHANNELMIXER_RIGHT];
-            buffers[CHANNEL_MONO] = buffers[CHANNEL_CHANNELMIXER_MONO];
+            SoftAudioBuffer delayleftbak = buffers[CHANNEL_DELAY_LEFT];
+            SoftAudioBuffer delayrightbak = buffers[CHANNEL_DELAY_RIGHT];
+            SoftAudioBuffer delaymonobak = buffers[CHANNEL_DELAY_MONO];
 
             int bufferlen = buffers[CHANNEL_LEFT].getSize();
 
             float[][] cbuffer = new float[nrofchannels][];
-            cbuffer[0] = buffers[CHANNEL_LEFT].array();
-            if (nrofchannels != 1)
-                cbuffer[1] = buffers[CHANNEL_RIGHT].array();
-
             float[][] obuffer = new float[nrofchannels][];
             obuffer[0] = leftbak.array();
             if (nrofchannels != 1)
                 obuffer[1] = rightbak.array();
 
-            for (ModelChannelMixer cmixer : act_registeredMixers) {
-                for (int i = 0; i < cbuffer.length; i++)
-                    Arrays.fill(cbuffer[i], 0);
+            for (SoftChannelMixerContainer cmixer : act_registeredMixers) {
+                
+                // Reroute default left,right output
+                // to channelmixer left,right input/output
+                buffers[CHANNEL_LEFT] =  cmixer.buffers[CHANNEL_LEFT];
+                buffers[CHANNEL_RIGHT] = cmixer.buffers[CHANNEL_RIGHT];
+                buffers[CHANNEL_MONO] = cmixer.buffers[CHANNEL_MONO];
+                buffers[CHANNEL_DELAY_LEFT] = cmixer.buffers[CHANNEL_DELAY_LEFT];
+                buffers[CHANNEL_DELAY_RIGHT] = cmixer.buffers[CHANNEL_DELAY_RIGHT];
+                buffers[CHANNEL_DELAY_MONO] = cmixer.buffers[CHANNEL_DELAY_MONO];
+
+                buffers[CHANNEL_LEFT].clear();
+                buffers[CHANNEL_RIGHT].clear();
                 buffers[CHANNEL_MONO].clear();
+
+                if(!buffers[CHANNEL_DELAY_LEFT].isSilent())
+                {
+                    buffers[CHANNEL_LEFT].swap(buffers[CHANNEL_DELAY_LEFT]);
+                }
+                if(!buffers[CHANNEL_DELAY_RIGHT].isSilent())
+                {
+                    buffers[CHANNEL_RIGHT].swap(buffers[CHANNEL_DELAY_RIGHT]);
+                }
+                if(!buffers[CHANNEL_DELAY_MONO].isSilent())
+                {
+                    buffers[CHANNEL_MONO].swap(buffers[CHANNEL_DELAY_MONO]);
+                }
+                
+                cbuffer[0] = buffers[CHANNEL_LEFT].array();
+                if (nrofchannels != 1)
+                    cbuffer[1] = buffers[CHANNEL_RIGHT].array();
+                
                 boolean hasactivevoices = false;
                 for (int i = 0; i < voicestatus.length; i++)
                     if (voicestatus[i].active)
-                        if (voicestatus[i].channelmixer == cmixer) {
+                        if (voicestatus[i].channelmixer == cmixer.mixer) {
                             voicestatus[i].processAudioLogic(buffers);
                             hasactivevoices = true;
                         }
-                if (!cmixer.process(cbuffer, 0, bufferlen)) {
-                    synchronized (control_mutex) {
-                        registeredMixers.remove(cmixer);
-                        cur_registeredMixers = null;
-                    }
-                }
+                
 
                 if(!buffers[CHANNEL_MONO].isSilent())
                 {
                     float[] mono = buffers[CHANNEL_MONO].array();
-                    float[] left = buffers[CHANNEL_LEFT].array();            
+                    float[] left = buffers[CHANNEL_LEFT].array();
                     if (nrofchannels != 1) {
                         float[] right = buffers[CHANNEL_RIGHT].array();
                         for (int i = 0; i < bufferlen; i++) {
@@ -538,9 +609,16 @@
                     {
                         for (int i = 0; i < bufferlen; i++) {
                             left[i] += mono[i];
-                        }                                
-                    }                              
-                }                
+                        }
+                    }
+                }
+
+                if (!cmixer.mixer.process(cbuffer, 0, bufferlen)) {
+                    synchronized (control_mutex) {
+                        registeredMixers.remove(cmixer);
+                        cur_registeredMixers = null;
+                    }
+                }
 
                 for (int i = 0; i < cbuffer.length; i++) {
                     float[] cbuff = cbuffer[i];
@@ -554,7 +632,7 @@
                         if (stoppedMixers != null) {
                             if (stoppedMixers.contains(cmixer)) {
                                 stoppedMixers.remove(cmixer);
-                                cmixer.stop();
+                                cmixer.mixer.stop();
                             }
                         }
                     }
@@ -565,6 +643,9 @@
             buffers[CHANNEL_LEFT] = leftbak;
             buffers[CHANNEL_RIGHT] = rightbak;
             buffers[CHANNEL_MONO] = monobak;
+            buffers[CHANNEL_DELAY_LEFT] = delayleftbak;
+            buffers[CHANNEL_DELAY_RIGHT] = delayrightbak;
+            buffers[CHANNEL_DELAY_MONO] = delaymonobak;
 
         }
 
@@ -649,16 +730,25 @@
         
         if(buffers[CHANNEL_LEFT].isSilent()
             && buffers[CHANNEL_RIGHT].isSilent())
-        {            
-            pusher_silent_count++;
-            if(pusher_silent_count > 5)
+        {       
+            
+            int midimessages_size;
+            synchronized (control_mutex) {
+                midimessages_size = midimessages.size();
+            }    
+            
+            if(midimessages_size == 0)
             {
-                pusher_silent_count = 0;
-                synchronized (control_mutex) {
-                    pusher_silent = true;
-                    if(synth.weakstream != null)
-                        synth.weakstream.setInputStream(null);
-                }                    
+                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
@@ -672,13 +762,18 @@
     // Must only we called within control_mutex synchronization
     public void activity()
     {        
-        msec_last_activity = msec_pos;
+        long silent_samples = 0;
         if(pusher_silent)
         {
             pusher_silent = false;
             if(synth.weakstream != null)
+            {
                 synth.weakstream.setInputStream(ais);
+                silent_samples = synth.weakstream.silent_samples;;
+            }
         }
+        msec_last_activity = (long)((sample_pos + silent_samples)
+                * (1000000.0 / samplerate));
     }
 
     public void stopMixer(ModelChannelMixer mixer) {
@@ -689,15 +784,22 @@
 
     public void registerMixer(ModelChannelMixer mixer) {
         if (registeredMixers == null)
-            registeredMixers = new HashSet<ModelChannelMixer>();
-        registeredMixers.add(mixer);
+            registeredMixers = new HashSet<SoftChannelMixerContainer>();
+        SoftChannelMixerContainer mixercontainer = new SoftChannelMixerContainer();
+        mixercontainer.buffers = new SoftAudioBuffer[6];
+        for (int i = 0; i < mixercontainer.buffers.length; i++) {
+            mixercontainer.buffers[i] = 
+                new SoftAudioBuffer(buffer_len, synth.getFormat());
+        }
+        mixercontainer.mixer = mixer;
+        registeredMixers.add(mixercontainer);
         cur_registeredMixers = null;
     }
 
     public SoftMainMixer(SoftSynthesizer synth) {
         this.synth = synth;
 
-        msec_pos = 0;
+        sample_pos = 0;
 
         co_master_balance[0] = 0.5;
         co_master_volume[0] = 1;
@@ -705,14 +807,18 @@
         co_master_fine_tuning[0] = 0.5;
 
         msec_buffer_len = (long) (1000000.0 / synth.getControlRate());
-
+        samplerate = synth.getFormat().getSampleRate();
         nrofchannels = synth.getFormat().getChannels();
 
         int buffersize = (int) (synth.getFormat().getSampleRate()
                                 / synth.getControlRate());
+        
+        buffer_len = buffersize;
+        
+        max_delay_midievent = buffersize;
 
         control_mutex = synth.control_mutex;
-        buffers = new SoftAudioBuffer[17];
+        buffers = new SoftAudioBuffer[14];
         for (int i = 0; i < buffers.length; i++) {
             buffers[i] = new SoftAudioBuffer(buffersize, synth.getFormat());
         }
@@ -994,7 +1100,10 @@
 
         switch (cmd) {
         case ShortMessage.NOTE_ON:
-            softchannel.noteOn(data1, data2);
+            if(delay_midievent != 0)
+                softchannel.noteOn(data1, data2, delay_midievent);
+            else
+                softchannel.noteOn(data1, data2);
             break;
         case ShortMessage.NOTE_OFF:
             softchannel.noteOff(data1, data2);
@@ -1021,7 +1130,15 @@
     }
 
     public long getMicrosecondPosition() {
-        return msec_pos;
+        if(pusher_silent)
+        {
+            if(synth.weakstream != null)
+            {
+                return (long)((sample_pos  + synth.weakstream.silent_samples)
+                        * (1000000.0 / samplerate));  
+            }            
+        }
+        return (long)(sample_pos * (1000000.0 / samplerate));
     }
 
     public void close() {
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java	Wed Dec 02 17:58:28 2009 +0000
@@ -26,8 +26,8 @@
 
 import java.util.TreeMap;
 
+import javax.sound.midi.MidiDevice;
 import javax.sound.midi.MidiMessage;
-import javax.sound.midi.Receiver;
 import javax.sound.midi.ShortMessage;
 
 /**
@@ -35,7 +35,7 @@
  *
  * @author Karl Helgason
  */
-public class SoftReceiver implements Receiver {
+public class SoftReceiver implements MidiDeviceReceiver {
 
     protected boolean open = true;
     private Object control_mutex;
@@ -51,6 +51,10 @@
             this.midimessages = mainmixer.midimessages;
     }
 
+    public MidiDevice getMidiDevice() {
+        return synth;
+    }    
+
     public void send(MidiMessage message, long timeStamp) {
 
         synchronized (control_mutex) {
@@ -60,6 +64,7 @@
 
         if (timeStamp != -1) {
             synchronized (control_mutex) {
+                mainmixer.activity();
                 while (midimessages.get(timeStamp) != null)
                     timeStamp++;
                 if (message instanceof ShortMessage
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java	Wed Dec 02 17:58:28 2009 +0000
@@ -59,23 +59,25 @@
  */
 public class SoftSynthesizer implements AudioSynthesizer,
         ReferenceCountingDevice {
-    
-    protected static class WeakAudioStream extends InputStream 
+
+    protected static class WeakAudioStream extends InputStream
     {
         private volatile AudioInputStream stream;
         public SoftAudioPusher pusher = null;
-        public AudioInputStream jitter_stream = null;       
+        public AudioInputStream jitter_stream = null;
         public SourceDataLine sourceDataLine = null;
+        public volatile long silent_samples = 0;
+        private int framesize = 0;
         private WeakReference<AudioInputStream> weak_stream_link;
         private AudioFloatConverter converter;
         private float[] silentbuffer = null;
         private int samplesize;
-        
+
         public void setInputStream(AudioInputStream stream)
         {
             this.stream = stream;
         }
-            
+
         public int available() throws IOException {
             AudioInputStream local_stream = stream;
             if(local_stream != null)
@@ -89,7 +91,7 @@
                   return -1;
              return b[0] & 0xFF;
         }
-            
+
         public int read(byte[] b, int off, int len) throws IOException {
              AudioInputStream local_stream = stream;
              if(local_stream != null)
@@ -100,7 +102,9 @@
                  if(silentbuffer == null || silentbuffer.length < flen)
                      silentbuffer = new float[flen];
                  converter.toByteArray(silentbuffer, flen, b, off);
-                 
+
+                 silent_samples += (long)((len / framesize));
+
                  if(pusher != null)
                  if(weak_stream_link.get() == null)
                  {
@@ -129,20 +133,21 @@
                  }
                  return len;
              }
-        }            
-            
+        }
+
         public WeakAudioStream(AudioInputStream stream) {
             this.stream = stream;
             weak_stream_link = new WeakReference<AudioInputStream>(stream);
             converter = AudioFloatConverter.getConverter(stream.getFormat());
-            samplesize = stream.getFormat().getFrameSize() / stream.getFormat().getChannels();             
-        }        
-        
+            samplesize = stream.getFormat().getFrameSize() / stream.getFormat().getChannels();
+            framesize = stream.getFormat().getFrameSize();
+        }
+
         public AudioInputStream getAudioInputStream()
         {
             return new AudioInputStream(this, stream.getFormat(), AudioSystem.NOT_SPECIFIED);
         }
-        
+
         public void close() throws IOException
         {
             AudioInputStream astream  = weak_stream_link.get();
@@ -162,13 +167,13 @@
     protected static final String INFO_DESCRIPTION = "Software MIDI Synthesizer";
     protected static final String INFO_VERSION = "1.0";
     protected final static MidiDevice.Info info = new Info();
-    
+
     private static SourceDataLine testline = null;
 
     private static Soundbank defaultSoundBank = null;
 
     protected WeakAudioStream weakstream = null;
-    
+
     protected Object control_mutex = this;
 
     protected int voiceIDCounter = 0;
@@ -284,7 +289,7 @@
         return true;
     }
 
-    private void processPropertyInfo(Map<String, Object> info)	{
+    private void processPropertyInfo(Map<String, Object> info) {
         AudioSynthesizerPropertyInfo[] items = getPropertyInfo(info);
 
         String resamplerType = (String)items[0].value;
@@ -661,31 +666,31 @@
 
             File userhome = null;
             File emg_soundbank_file = null;
-            
+
             /*
-             *  Try to load saved generated soundbank 
-             */                
+             *  Try to load saved generated soundbank
+             */
             try {
                 userhome = new File(System.getProperty("user.home"),
                      ".gervill");
                 emg_soundbank_file = new File(userhome, "soundbank-emg.sf2");
                 Soundbank sbk = MidiSystem.getSoundbank(emg_soundbank_file);
                 defaultSoundBank = sbk;
-                return defaultSoundBank;                
+                return defaultSoundBank;
             } catch (AccessControlException e) {
             } catch (Exception e) {
                 //e.printStackTrace();
             }
-            
+
             try {
-                
+
                 /*
-                 *  Generate emergency soundbank 
+                 *  Generate emergency soundbank
                  */
                 defaultSoundBank = EmergencySoundbank.createSoundbank();
-                
+
                 /*
-                 *  Save generated soundbank to disk for faster future use. 
+                 *  Save generated soundbank to disk for faster future use.
                  */
                 if(defaultSoundBank != null)
                 {
@@ -794,7 +799,7 @@
                 new ArrayList<AudioSynthesizerPropertyInfo>();
 
         AudioSynthesizerPropertyInfo item;
-        
+
         // If info != null or synthesizer is closed
         //   we return how the synthesizer will be set on next open
         // If info == null and synthesizer is open
@@ -855,7 +860,7 @@
         item = new AudioSynthesizerPropertyInfo("light reverb", o?reverb_light:true);
         item.description = "Turn light reverb mode on or off";
         list.add(item);
-        
+
         AudioSynthesizerPropertyInfo[] items;
         items = list.toArray(new AudioSynthesizerPropertyInfo[list.size()]);
 
@@ -889,28 +894,36 @@
             return;
         }
         synchronized (control_mutex) {
+            Throwable causeException = null;
             try {
-                if (line != null)
+                if (line != null) {
+                    // can throw IllegalArgumentException
                     setFormat(line.getFormat());
+                }
 
                 AudioInputStream ais = openStream(getFormat(), info);
-                
+
                 weakstream = new WeakAudioStream(ais);
                 ais = weakstream.getAudioInputStream();
 
                 if (line == null)
                 {
-                    if(testline != null)
+                    if (testline != null) {
                         line = testline;
-                    else
+                    } else {
+                        // can throw LineUnavailableException,
+                        // IllegalArgumentException, SecurityException
                         line = AudioSystem.getSourceDataLine(getFormat());
-                }                    
+                    }
+                }
 
                 double latency = this.latency;
 
                 if (!line.isOpen()) {
                     int bufferSize = getFormat().getFrameSize()
                         * (int)(getFormat().getFrameRate() * (latency/1000000f));
+                    // can throw LineUnavailableException,
+                    // IllegalArgumentException, SecurityException
                     line.open(getFormat(), bufferSize);
 
                     // Remember that we opened that line
@@ -953,14 +966,23 @@
                     weakstream.pusher = pusher;
                     weakstream.sourceDataLine = sourceDataLine;
                 }
-                
-
 
             } catch (LineUnavailableException e) {
+                causeException = e;
+            } catch (IllegalArgumentException e) {
+                causeException = e;
+            } catch (SecurityException e) {
+                causeException = e;
+            }
+
+            if (causeException != null) {
                 if (isOpen())
                     close();
                 // am: need MidiUnavailableException(Throwable) ctor!
-                throw new MidiUnavailableException(e.toString());
+                MidiUnavailableException ex = new MidiUnavailableException(
+                        "Can not open line");
+                ex.initCause(causeException);
+                throw ex;
             }
 
         }
@@ -978,10 +1000,10 @@
             voice_allocation_mode = 0;
 
             processPropertyInfo(info);
-            
+
             open = true;
             implicitOpen = false;
-            
+
             if (targetFormat != null)
                 setFormat(targetFormat);
 
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java	Wed Dec 02 17:58:28 2009 +0000
@@ -43,6 +43,7 @@
     private int noteOn_noteNumber = 0;
     private int noteOn_velocity = 0;
     private int noteOff_velocity = 0;
+    private int delay = 0;
     protected ModelChannelMixer channelmixer = null;
     protected double tunedKey = 0;
     protected SoftTuning tuning = null;
@@ -294,7 +295,7 @@
         tunedKey = tuning.getTuning(noteNumber) / 100.0;
     }
 
-    protected void noteOn(int noteNumber, int velocity) {
+    protected void noteOn(int noteNumber, int velocity, int delay) {
 
         sustain = false;
         sostenuto = false;
@@ -308,6 +309,7 @@
 
         noteOn_noteNumber = noteNumber;
         noteOn_velocity = velocity;
+        this.delay = delay;
 
         lastMuteValue = 0;
         lastSoloMuteValue = 0;
@@ -562,7 +564,7 @@
 
             if (stealer_channel != null) {
                 stealer_channel.initVoice(this, stealer_performer,
-                        stealer_voiceID, stealer_noteNumber, stealer_velocity,
+                        stealer_voiceID, stealer_noteNumber, stealer_velocity, 0,
                         stealer_extendedConnectionBlocks, stealer_channelmixer,
                         stealer_releaseTriggered);
                 stealer_releaseTriggered = false;
@@ -733,23 +735,55 @@
     }
 
     protected void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out,
+            SoftAudioBuffer dout,
             float amp_from, float amp_to) {
         int bufferlen = in.getSize();
         if (amp_from < 0.000000001 && amp_to < 0.000000001)
             return;
-        if (amp_from == amp_to) {
-            float[] fout = out.array();
-            float[] fin = in.array();
-            for (int i = 0; i < bufferlen; i++)
-                fout[i] += fin[i] * amp_to;
-        } else {
-            float amp = amp_from;
-            float amp_delta = (amp_to - amp_from) / bufferlen;
-            float[] fout = out.array();
-            float[] fin = in.array();
-            for (int i = 0; i < bufferlen; i++) {
-                amp += amp_delta;
-                fout[i] += fin[i] * amp;
+        if(dout != null && delay != 0)
+        {
+            if (amp_from == amp_to) {
+                float[] fout = out.array();
+                float[] fin = in.array();                
+                int j = 0;
+                for (int i = delay; i < bufferlen; i++)
+                    fout[i] += fin[j++] * amp_to;
+                fout = dout.array();
+                for (int i = 0; i < delay; i++)
+                    fout[i] += fin[j++] * amp_to;
+            } else {
+                float amp = amp_from;
+                float amp_delta = (amp_to - amp_from) / bufferlen;
+                float[] fout = out.array();
+                float[] fin = in.array();
+                int j = 0;
+                for (int i = delay; i < bufferlen; i++) {
+                    amp += amp_delta;
+                    fout[i] += fin[j++] * amp;
+                }
+                fout = dout.array();
+                for (int i = 0; i < delay; i++) {
+                    amp += amp_delta;
+                    fout[i] += fin[j++] * amp;
+                }                
+            }
+        }
+        else
+        {
+            if (amp_from == amp_to) {
+                float[] fout = out.array();
+                float[] fin = in.array();
+                for (int i = 0; i < bufferlen; i++)
+                    fout[i] += fin[i] * amp_to;
+            } else {
+                float amp = amp_from;
+                float amp_delta = (amp_to - amp_from) / bufferlen;
+                float[] fout = out.array();
+                float[] fin = in.array();
+                for (int i = 0; i < bufferlen; i++) {
+                    amp += amp_delta;
+                    fout[i] += fin[i] * amp;
+                }
             }
         }
 
@@ -785,6 +819,13 @@
         SoftAudioBuffer mono = buffer[SoftMainMixer.CHANNEL_MONO];
         SoftAudioBuffer eff1 = buffer[SoftMainMixer.CHANNEL_EFFECT1];
         SoftAudioBuffer eff2 = buffer[SoftMainMixer.CHANNEL_EFFECT2];
+
+        SoftAudioBuffer dleft = buffer[SoftMainMixer.CHANNEL_DELAY_LEFT];
+        SoftAudioBuffer dright = buffer[SoftMainMixer.CHANNEL_DELAY_RIGHT];
+        SoftAudioBuffer dmono = buffer[SoftMainMixer.CHANNEL_DELAY_MONO];
+        SoftAudioBuffer deff1 = buffer[SoftMainMixer.CHANNEL_DELAY_EFFECT1];
+        SoftAudioBuffer deff2 = buffer[SoftMainMixer.CHANNEL_DELAY_EFFECT2];
+        
         SoftAudioBuffer leftdry = buffer[SoftMainMixer.CHANNEL_LEFT_DRY];
         SoftAudioBuffer rightdry = buffer[SoftMainMixer.CHANNEL_RIGHT_DRY];
 
@@ -799,42 +840,42 @@
 
         if (nrofchannels == 1) {
             out_mixer_left = (out_mixer_left + out_mixer_right) / 2;
-            mixAudioStream(leftdry, left, last_out_mixer_left, out_mixer_left);
+            mixAudioStream(leftdry, left, dleft, last_out_mixer_left, out_mixer_left);
             if (rightdry != null)
-                mixAudioStream(rightdry, left, last_out_mixer_left,
+                mixAudioStream(rightdry, left, dleft, last_out_mixer_left,
                         out_mixer_left);
         } else {
             if(rightdry == null && 
                     last_out_mixer_left == last_out_mixer_right &&
                     out_mixer_left == out_mixer_right)
             {
-                mixAudioStream(leftdry, mono, last_out_mixer_left, out_mixer_left);
+                mixAudioStream(leftdry, mono, dmono, last_out_mixer_left, out_mixer_left);
             }
             else
             {
-                mixAudioStream(leftdry, left, last_out_mixer_left, out_mixer_left);
+                mixAudioStream(leftdry, left, dleft, last_out_mixer_left, out_mixer_left);
                 if (rightdry != null)
-                    mixAudioStream(rightdry, right, last_out_mixer_right,
+                    mixAudioStream(rightdry, right, dright, last_out_mixer_right,
                         out_mixer_right);
                 else
-                    mixAudioStream(leftdry, right, last_out_mixer_right,
+                    mixAudioStream(leftdry, right, dright, last_out_mixer_right,
                         out_mixer_right);
             }
         }
 
         if (rightdry == null) {
-            mixAudioStream(leftdry, eff1, last_out_mixer_effect1,
+            mixAudioStream(leftdry, eff1, deff1, last_out_mixer_effect1,
                     out_mixer_effect1);
-            mixAudioStream(leftdry, eff2, last_out_mixer_effect2,
+            mixAudioStream(leftdry, eff2, deff2, last_out_mixer_effect2,
                     out_mixer_effect2);
         } else {
-            mixAudioStream(leftdry, eff1, last_out_mixer_effect1 * 0.5f,
+            mixAudioStream(leftdry, eff1, deff1, last_out_mixer_effect1 * 0.5f,
                     out_mixer_effect1 * 0.5f);
-            mixAudioStream(leftdry, eff2, last_out_mixer_effect2 * 0.5f,
+            mixAudioStream(leftdry, eff2, deff2, last_out_mixer_effect2 * 0.5f,
                     out_mixer_effect2 * 0.5f);
-            mixAudioStream(rightdry, eff1, last_out_mixer_effect1 * 0.5f,
+            mixAudioStream(rightdry, eff1, deff1, last_out_mixer_effect1 * 0.5f,
                     out_mixer_effect1 * 0.5f);
-            mixAudioStream(rightdry, eff2, last_out_mixer_effect2 * 0.5f,
+            mixAudioStream(rightdry, eff2, deff2, last_out_mixer_effect2 * 0.5f,
                     out_mixer_effect2 * 0.5f);
         }
 
--- a/plugin/icedtea/sun/applet/PluginAppletViewer.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/plugin/icedtea/sun/applet/PluginAppletViewer.java	Wed Dec 02 17:58:28 2009 +0000
@@ -898,8 +898,8 @@
     	 try {
     		 PluginDebug.debug ("wait request 1");
     		 synchronized(request) {
-    			 PluginDebug.debug ("wait request 2");
-    			 while ((Long) request.getObject() == 0)
+    			 PluginDebug.debug ("wait request 2 " + status.get(identifier) );
+    			 while ((Long) request.getObject() == 0 && (status.get(identifier).equals(PAV_INIT_STATUS.ACTIVE) || status.get(identifier).equals(PAV_INIT_STATUS.PRE_INIT)))
     				 request.wait();
     			 PluginDebug.debug ("wait request 3");
     		 }
@@ -1677,6 +1677,7 @@
     	 boolean isAppletTag = false;
     	 boolean isObjectTag = false;
     	 boolean isEmbedTag = false;
+    	 boolean objectTagAlreadyParsed = false;
 
     	 // warning messages
     	 String requiresNameWarning = amh.getMessage("parse.warning.requiresname");
@@ -1751,6 +1752,10 @@
     				 if (nm.equalsIgnoreCase("param")) {
     					 Hashtable t = scanTag(in);
     					 String att = (String)t.get("name");
+    					 
+    					 if (atts.containsKey(att))
+    					     continue;
+
     					 if (att == null) {
     						 statusMsgStream.println(requiresNameWarning);
     					 } else {
@@ -1783,7 +1788,7 @@
     					 atts = scanTag(in);
 
                          // If there is a classid and no code tag present, transform it to code tag
-                         if (atts.get("code") == null && atts.get("classid") != null) {
+                         if (atts.get("code") == null && atts.get("classid") != null && ((String) atts.get("classid")).endsWith(".class")) {
                              atts.put("code", atts.get("classid"));
                          }
                          
@@ -1817,13 +1822,18 @@
     				 }
     				 else if (nm.equalsIgnoreCase("object")) {
     					 isObjectTag = true;
-    					 atts = scanTag(in);
 
-    					 // If there is a classid and no code tag present, transform it to code tag
-                         if (atts.get("code") == null && atts.get("classid") != null) {
-                             atts.put("code", atts.get("classid"));
-                         }
-                         
+    				     // Once code is set, additional nested objects are ignored
+    				     if (!objectTagAlreadyParsed) {
+    				         objectTagAlreadyParsed = true;
+    				         atts = scanTag(in);
+    				     }
+
+    				     // If there is a classid and no code tag present, transform it to code tag
+    				     if (atts.get("code") == null && atts.get("classid") != null && ((String) atts.get("classid")).endsWith(".class")) {
+    				         atts.put("code", atts.get("classid"));
+    				     }
+                        
                          // remove java: from code tag
                          if (atts.get("code") != null && ((String) atts.get("code")).startsWith("java:")) {
                              atts.put("code", ((String) atts.get("code")).substring(5));
@@ -1835,6 +1845,10 @@
                              atts.put("code", ((String) atts.get("java_code")));
                          }
 
+                         if (atts.containsKey("code")) {
+                             objectTagAlreadyParsed = true;
+                         }
+
                          if (atts.get("java_codebase") != null) {
                              atts.put("codebase", ((String) atts.get("java_codebase")));
                          }
@@ -1874,7 +1888,7 @@
     					 atts = scanTag(in);
 
                          // If there is a classid and no code tag present, transform it to code tag
-                         if (atts.get("code") == null && atts.get("classid") != null) {
+                         if (atts.get("code") == null && atts.get("classid") != null && ((String) atts.get("classid")).endsWith(".class")) {
                              atts.put("code", atts.get("classid"));
                          }
                          
--- a/ports/hotspot/src/cpu/zero/vm/entry_zero.hpp	Mon Nov 23 13:38:58 2009 +0000
+++ b/ports/hotspot/src/cpu/zero/vm/entry_zero.hpp	Wed Dec 02 17:58:28 2009 +0000
@@ -33,7 +33,7 @@
   address _entry_point;
 
  public:
-  inline address entry_point() const {
+  address entry_point() const {
     return _entry_point;
   }
   void set_entry_point(address entry_point) {
@@ -50,10 +50,10 @@
                                TRAPS);
 
  public:
-  inline void invoke(methodOop method, TRAPS) const {
+  void invoke(methodOop method, TRAPS) const {
     ((NormalEntryFunc) entry_point())(method, (intptr_t) this, THREAD);
   }
-  inline void invoke_osr(methodOop method, address osr_buf, TRAPS) const {
+  void invoke_osr(methodOop method, address osr_buf, TRAPS) const {
     ((OSREntryFunc) entry_point())(method, osr_buf, (intptr_t) this, THREAD);
   }
 
--- a/rt/net/sourceforge/jnlp/Launcher.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/rt/net/sourceforge/jnlp/Launcher.java	Wed Dec 02 17:58:28 2009 +0000
@@ -580,6 +580,8 @@
             group.setApplication(appletInstance);
             loader.setApplication(appletInstance);
 
+            setContextClassLoaderForAllThreads(appletInstance.getClassLoader());
+
             return appletInstance;
         }
         catch (Exception ex) {
--- a/rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java	Mon Nov 23 13:38:58 2009 +0000
+++ b/rt/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java	Wed Dec 02 17:58:28 2009 +0000
@@ -130,7 +130,7 @@
         public void windowDeactivated(WindowEvent e) {
             activeApplication = null;
         }
-        
+
         public void windowClosing(WindowEvent e) {
         	System.err.println("Disposing window");
         	e.getWindow().dispose();