/[svn]/jsampler/trunk/src/org/jsampler/CC.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/CC.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1786 by iliev, Wed Oct 8 22:38:15 2008 UTC revision 1864 by iliev, Sat Mar 14 20:44:58 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 126  public class CC { Line 126  public class CC {
126           * @return The task queue to be used for scheduling tasks           * @return The task queue to be used for scheduling tasks
127           * for execution out of the event-dispatching thread.           * for execution out of the event-dispatching thread.
128           */           */
129          public static TaskQueue          public static synchronized TaskQueue
130          getTaskQueue() { return taskQueue; }          getTaskQueue() { return taskQueue; }
131                    
132          /**          /**
133           * Adds the specified task to the task queue. All task in the           * Adds the specified task to the task queue. All task in the
134           * queue equal to the specified task are removed from the queue.           * queue equal to the specified task are removed from the queue.
135           */           */
136          public static void          public static synchronized void
137          scheduleTask(Task t) {          scheduleTask(Task t) {
138                  while(getTaskQueue().removeTask(t)) { }                  while(getTaskQueue().removeTask(t)) { }
139                                    
# Line 142  public class CC { Line 142  public class CC {
142                    
143          /**          /**
144           * Adds the specified task to the task queue only if the last           * Adds the specified task to the task queue only if the last
145           * task in the is not equal to <code>t</code>.           * task in the queue is not equal to <code>t</code>.
146           */           */
147          public static void          public static synchronized void
148          addTask(Task t) {          addTask(Task t) {
149                  Task[] tasks = getTaskQueue().getPendingTasks();                  Task[] tasks = getTaskQueue().getPendingTasks();
150                  if(tasks.length > 0 && tasks[tasks.length - 1].equals(t)) return;                  if(tasks.length > 0 && tasks[tasks.length - 1].equals(t)) return;
# Line 255  public class CC { Line 255  public class CC {
255                          actionPerformed(ActionEvent e) { CC.getProgressIndicator().start(); }                          actionPerformed(ActionEvent e) { CC.getProgressIndicator().start(); }
256                  });                  });
257                                    
258                  taskQueue.addTaskQueueListener(getHandler());                  getTaskQueue().addTaskQueueListener(getHandler());
259                                    
260                  taskQueue.start();                  getTaskQueue().start();
261                                    
262                  getClient().removeChannelCountListener(getHandler());                  getClient().removeChannelCountListener(getHandler());
263                  getClient().addChannelCountListener(getHandler());                  getClient().addChannelCountListener(getHandler());
# Line 851  public class CC { Line 851  public class CC {
851                                  getTaskQueue().add(new Audio.UpdateDevices());                                  getTaskQueue().add(new Audio.UpdateDevices());
852                                  addTask(uc);                                  addTask(uc);
853                                                                    
854                                    int vl = preferences().getIntProperty(JSPrefs.GLOBAL_VOICE_LIMIT);
855                                    int sl = preferences().getIntProperty(JSPrefs.GLOBAL_STREAM_LIMIT);
856                                    
857                                    getTaskQueue().add(new Global.SetPolyphony(vl, sl));
858                                    
859                                  fireConnectionEstablishedEvent();                                  fireConnectionEstablishedEvent();
860                          }                          }
861                  });                  });
# Line 1108  public class CC { Line 1113  public class CC {
1113                          sb.append("\r\n");                          sb.append("\r\n");
1114                  }                  }
1115                                    
1116                  //sb.append(getViewConfig().exportSessionViewConfig());                  sb.append(getViewConfig().exportSessionViewConfig());
1117                                    
1118                  return sb.toString();                  return sb.toString();
1119          }          }
# Line 1251  public class CC { Line 1256  public class CC {
1256                                    
1257                  return true;                  return true;
1258          }          }
1259    
1260            public static boolean
1261            isMacOS() {
1262                    return System.getProperty("os.name").toLowerCase().startsWith("mac os x");
1263            }
1264                    
1265                    
1266          private final static EventHandler eventHandler = new EventHandler();          private final static EventHandler eventHandler = new EventHandler();
# Line 1268  public class CC { Line 1278  public class CC {
1278                  @Override                  @Override
1279                  public void                  public void
1280                  channelCountChanged( ChannelCountEvent e) {                  channelCountChanged( ChannelCountEvent e) {
1281                            if(e.getChannelCount() == 0) {
1282                                    /*
1283                                     * This special case is handled because this might be due to
1284                                     * loading a lscp script containing sampler view configuration.
1285                                     */
1286                                    CC.getSamplerModel().removeAllChannels();
1287                                    return;
1288                            }
1289                          addTask(new UpdateChannels());                          addTask(new UpdateChannels());
1290                  }                  }
1291                                    
# Line 1383  public class CC { Line 1401  public class CC {
1401                  @Override                  @Override
1402                  public void                  public void
1403                  totalVoiceCountChanged(TotalVoiceCountEvent e) {                  totalVoiceCountChanged(TotalVoiceCountEvent e) {
1404                          getTaskQueue().add(new UpdateTotalVoiceCount());                          scheduleTask(new UpdateTotalVoiceCount());
1405                  }                  }
1406                                    
1407                  /** Invoked when the number of MIDI instruments in a MIDI instrument map is changed. */                  /** Invoked when the number of MIDI instruments in a MIDI instrument map is changed. */
# Line 1411  public class CC { Line 1429  public class CC {
1429                          getSamplerModel().setVolume(e.getVolume());                          getSamplerModel().setVolume(e.getVolume());
1430                  }                  }
1431                                    
1432                    @Override
1433                    public void
1434                    voiceLimitChanged(GlobalInfoEvent e) { }
1435                    
1436                    @Override
1437                    public void
1438                    streamLimitChanged(GlobalInfoEvent e) { }
1439                    
1440                  /**                  /**
1441                   * Invoked to indicate that the state of a task queue is changed.                   * Invoked to indicate that the state of a task queue is changed.
1442                   * This method is invoked only from the event-dispatching thread.                   * This method is invoked only from the event-dispatching thread.

Legend:
Removed from v.1786  
changed lines
  Added in v.1864

  ViewVC Help
Powered by ViewVC