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

Diff of /jsampler/trunk/src/org/jsampler/task/Audio.java

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

revision 1866 by iliev, Mon Oct 15 20:55:33 2007 UTC revision 1867 by iliev, Mon Mar 16 22:12:32 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-2006 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 22  Line 22 
22    
23  package org.jsampler.task;  package org.jsampler.task;
24    
 import java.util.logging.Level;  
   
25  import org.jsampler.AudioDeviceModel;  import org.jsampler.AudioDeviceModel;
26  import org.jsampler.CC;  import org.jsampler.CC;
 import org.jsampler.HF;  
27  import org.jsampler.SamplerModel;  import org.jsampler.SamplerModel;
28    
29  import org.linuxsampler.lscp.AudioOutputDevice;  import org.linuxsampler.lscp.AudioOutputDevice;
# Line 57  public class Audio { Line 54  public class Audio {
54                  }                  }
55                    
56                  /** The entry point of the task. */                  /** The entry point of the task. */
57                    @Override
58                  public void                  public void
59                  run() {                  exec() throws Exception { setResult(CC.getClient().getAudioOutputDrivers()); }
                         try { setResult(CC.getClient().getAudioOutputDrivers()); }  
                         catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
                 }  
60          }          }
61                    
62          /**          /**
# Line 89  public class Audio { Line 81  public class Audio {
81                  }                  }
82                    
83                  /** The entry point of the task. */                  /** The entry point of the task. */
84                    @Override
85                  public void                  public void
86                  run() {                  exec() throws Exception {
87                          try {                          AudioOutputDriver d;
88                                  AudioOutputDriver d;                          d = CC.getClient().getAudioOutputDriverInfo(driver, depList);
89                                  d = CC.getClient().getAudioOutputDriverInfo(driver, depList);                          setResult(d.getParameters());
                                 setResult(d.getParameters());  
                         }  
                         catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
90                  }                  }
91          }          }
92    
# Line 126  public class Audio { Line 113  public class Audio {
113                  }                  }
114                    
115                  /** The entry point of the task. */                  /** The entry point of the task. */
116                    @Override
117                  public void                  public void
118                  run() {                  exec() throws Exception {
119                          try {                          Integer deviceId = CC.getClient().createAudioOutputDevice(driver, parameters);
120                                  Integer deviceId =                          setResult(deviceId);
                                         CC.getClient().createAudioOutputDevice(driver, parameters);  
                                 setResult(deviceId);  
                         } catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
121                  }                  }
122          }          }
123                    
# Line 159  public class Audio { Line 141  public class Audio {
141                  }                  }
142                    
143                  /** The entry point of the task. */                  /** The entry point of the task. */
144                    @Override
145                  public void                  public void
146                  run() {                  exec() throws Exception { CC.getClient().destroyAudioOutputDevice(deviceId); }
                         try { CC.getClient().destroyAudioOutputDevice(deviceId); }  
                         catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
                 }  
147          }          }
148                    
149          /**          /**
# Line 192  public class Audio { Line 169  public class Audio {
169                  }                  }
170                    
171                  /** The entry point of the task. */                  /** The entry point of the task. */
172                    @Override
173                  public void                  public void
174                  run() {                  exec() throws Exception {
175                          try {                          CC.getClient().enableAudioOutputDevice(dev, enable);
                                 CC.getClient().enableAudioOutputDevice(dev, enable);  
176                                                    
177                                  // Not needed, but eventually speeds up the change.                          // Not needed, but eventually speeds up the change.
178                                  CC.getSamplerModel().getAudioDeviceById(dev).setActive(enable);                          CC.getSamplerModel().getAudioDeviceById(dev).setActive(enable);
                         } catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
179                  }                  }
180          }          }
181    
# Line 228  public class Audio { Line 201  public class Audio {
201                  }                  }
202                    
203                  /** The entry point of the task. */                  /** The entry point of the task. */
204                    @Override
205                  public void                  public void
206                  run() {                  exec() throws Exception {
207                          try { CC.getClient().setAudioOutputDeviceParameter(dev, prm); }                          CC.getClient().setAudioOutputDeviceParameter(dev, prm);
                         catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
208                  }                  }
209          }          }
210    
# Line 263  public class Audio { Line 233  public class Audio {
233                  }                  }
234                    
235                  /** The entry point of the task. */                  /** The entry point of the task. */
236                    @Override
237                  public void                  public void
238                  run() {                  exec() throws Exception {
239                          try { CC.getClient().setAudioOutputChannelParameter(dev, channel, prm); }                          CC.getClient().setAudioOutputChannelParameter(dev, channel, prm);
                         catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
240                  }                  }
241          }          }
242                    
# Line 295  public class Audio { Line 262  public class Audio {
262                  }                  }
263                    
264                  /** The entry point of the task. */                  /** The entry point of the task. */
265                    @Override
266                  public void                  public void
267                  run() {                  exec() throws Exception {
268                          try { CC.getClient().setAudioOutputChannelCount(deviceId, channels); }                          CC.getClient().setAudioOutputChannelCount(deviceId, channels);
                         catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
269                  }                  }
270          }          }
271    
# Line 325  public class Audio { Line 289  public class Audio {
289                  }                  }
290                    
291                  /** The entry point of the task. */                  /** The entry point of the task. */
292                    @Override
293                  public void                  public void
294                  run() {                  exec() throws Exception {
295                          try {                          AudioOutputDevice d = CC.getClient().getAudioOutputDeviceInfo(dev);
296                                  AudioOutputDevice d = CC.getClient().getAudioOutputDeviceInfo(dev);                          CC.getSamplerModel().getAudioDeviceById(dev).setDeviceInfo(d);
                                 CC.getSamplerModel().getAudioDeviceById(dev).setDeviceInfo(d);  
                         } catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
                         }  
297                  }                  }
298          }          }
299    
# Line 349  public class Audio { Line 309  public class Audio {
309                  }                  }
310                    
311                  /** The entry point of the task. */                  /** The entry point of the task. */
312                    @Override
313                  public void                  public void
314                  run() {                  exec() throws Exception {
315                          try {                          SamplerModel sm = CC.getSamplerModel();
316                                  SamplerModel sm = CC.getSamplerModel();                          Integer[] devIDs = CC.getClient().getAudioOutputDeviceIDs();
317                                  Integer[] devIDs = CC.getClient().getAudioOutputDeviceIDs();                  
318                            boolean found = false;
319                                                    
320                                  boolean found = false;                          for(AudioDeviceModel m : sm.getAudioDevices()) {
321                                                                    for(int i = 0; i < devIDs.length; i++) {
322                                  for(AudioDeviceModel m : sm.getAudioDevices()) {                                          if(m.getDeviceId() == devIDs[i]) {
323                                          for(int i = 0; i < devIDs.length; i++) {                                                  devIDs[i] = -1;
324                                                  if(m.getDeviceId() == devIDs[i]) {                                                  found = true;
                                                         devIDs[i] = -1;  
                                                         found = true;  
                                                 }  
325                                          }                                          }
                                   
                                         if(!found) sm.removeAudioDeviceById(m.getDeviceId());  
                                         found = false;  
326                                  }                                  }
327                                                    
328                                  AudioOutputDevice d;                                  if(!found) sm.removeAudioDeviceById(m.getDeviceId());
329                                                                    found = false;
330                                  for(int id : devIDs) {                          }
331                                          if(id >= 0) {                  
332                                                  d = CC.getClient().getAudioOutputDeviceInfo(id);                          AudioOutputDevice d;
333                                                  sm.addAudioDevice(d);                          
334                                          }                          for(int id : devIDs) {
335                                    if(id >= 0) {
336                                            d = CC.getClient().getAudioOutputDeviceInfo(id);
337                                            sm.addAudioDevice(d);
338                                  }                                  }
                         } catch(Exception x) {  
                                 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));  
                                 CC.getLogger().log(Level.FINE, getErrorMessage(), x);  
339                          }                          }
340                  }                  }
341          }          }

Legend:
Removed from v.1866  
changed lines
  Added in v.1867

  ViewVC Help
Powered by ViewVC