/[svn]/jlscp/trunk/src/org/linuxsampler/lscp/Client.java
ViewVC logotype

Diff of /jlscp/trunk/src/org/linuxsampler/lscp/Client.java

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

revision 2190 by iliev, Fri Jun 24 20:18:03 2011 UTC revision 2240 by iliev, Tue Aug 16 14:50:01 2011 UTC
# Line 30  import java.net.Socket; Line 30  import java.net.Socket;
30  import java.net.SocketTimeoutException;  import java.net.SocketTimeoutException;
31    
32  import java.util.ArrayList;  import java.util.ArrayList;
33    import java.util.TreeMap;
34  import java.util.Vector;  import java.util.Vector;
35  import java.util.logging.Level;  import java.util.logging.Level;
36  import java.util.logging.Logger;  import java.util.logging.Logger;
# Line 94  public class Client { Line 95  public class Client {
95    
96          private Vector<ResultSetEntry> resultSetQueue = new Vector<ResultSetEntry>();          private Vector<ResultSetEntry> resultSetQueue = new Vector<ResultSetEntry>();
97                    
98            /* Used for caching the engines' info */
99            private final TreeMap<String, SamplerEngine> engineMap = new TreeMap<String, SamplerEngine>();
100            
101          class EventThread extends Thread {          class EventThread extends Thread {
102                  private Vector<String> queue = new Vector<String>();                  private Vector<String> queue = new Vector<String>();
103                  private boolean terminate = false;                  private boolean terminate = false;
# Line 323  public class Client { Line 327  public class Client {
327                  if(sock != null) disconnect();                  if(sock != null) disconnect();
328                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
329                                    
330                    engineMap.clear();
331                    
332                  // Initializing LSCP event thread                  // Initializing LSCP event thread
333                  if(eventThread.isAlive()) {                  if(eventThread.isAlive()) {
334                          getLogger().warning("LSCP event thread already running!");                          getLogger().warning("LSCP event thread already running!");
# Line 441  public class Client { Line 447  public class Client {
447                          eventThread.terminate();                          eventThread.terminate();
448                          eventThread = new EventThread();                          eventThread = new EventThread();
449                  }                  }
450                    
451                    engineMap.clear();
452          }          }
453                    
454          /**          /**
# Line 3503  public class Client { Line 3511  public class Client {
3511           */           */
3512          private synchronized SamplerEngine          private synchronized SamplerEngine
3513          getEngineInfo(String engineName) throws IOException, LscpException, LSException {          getEngineInfo(String engineName) throws IOException, LscpException, LSException {
3514                  SamplerEngine se = new SamplerEngine();                  SamplerEngine se = engineMap.get(engineName);
3515                    if(se != null) return null;
3516                    
3517                    se = new SamplerEngine();
3518                  if(!retrieveInfo("GET ENGINE INFO " + engineName, se)) return null;                  if(!retrieveInfo("GET ENGINE INFO " + engineName, se)) return null;
3519                  se.setName(engineName);                  se.setName(engineName);
3520                    engineMap.put(engineName, se);
3521    
3522                  return se;                  return se;
3523          }          }
# Line 4250  public class Client { Line 4262  public class Client {
4262    
4263          /**          /**
4264           * Gets the current list of effect instances.           * Gets the current list of effect instances.
4265           * @return An <code>EffectInstance</code> array           * @return An <code>EffectInstanceInfo</code> array
4266           * providing the current list of effect instances.           * providing the current list of effect instances.
4267           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
4268           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
4269           */           */
4270          public synchronized EffectInstance[]          public synchronized EffectInstanceInfo[]
4271          getEffectInstances() throws IOException, LscpException, LSException {          getEffectInstances() throws IOException, LscpException, LSException {
4272                  Integer[] idS = getEffectInscanceIDs();                  Integer[] idS = getEffectInscanceIDs();
4273                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4274    
4275                  EffectInstance[] eis = new EffectInstance[idS.length];                  EffectInstanceInfo[] eis = new EffectInstanceInfo[idS.length];
4276    
4277                  for(int i = 0; i < eis.length; i++)                  for(int i = 0; i < eis.length; i++)
4278                          eis[i] = getEffectInstanceInfo(idS[i]);                          eis[i] = getEffectInstanceInfo(idS[i]);
# Line 4282  public class Client { Line 4294  public class Client {
4294          /**          /**
4295           * Gets the current informations about the specified effect instance.           * Gets the current informations about the specified effect instance.
4296           * @param id The numerical ID of the effect instance.           * @param id The numerical ID of the effect instance.
4297           * @return <code>EffectInstance</code> object containing           * @return <code>EffectInstanceInfo</code> object containing
4298           * the current informations about the specified effect instance.           * the current informations about the specified effect instance.
4299           * @throws IOException If an I/O error occurs.           * @throws IOException If an I/O error occurs.
4300           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
4301           * @throws LSException If the effect instance ID is invalid.           * @throws LSException If the effect instance ID is invalid.
4302           */           */
4303          public synchronized EffectInstance          public synchronized EffectInstanceInfo
4304          getEffectInstanceInfo(int id) throws IOException, LscpException, LSException {          getEffectInstanceInfo(int id) throws IOException, LscpException, LSException {
4305                  EffectInstance ei = new EffectInstance();                  EffectInstanceInfo ei = new EffectInstanceInfo();
4306                  if(!retrieveInfo("GET EFFECT_INSTANCE INFO " + id, ei)) return null;                  if(!retrieveInfo("GET EFFECT_INSTANCE INFO " + id, ei)) return null;
4307                  ei.setInstanceId(id);                  ei.setInstanceId(id);
4308    
# Line 4317  public class Client { Line 4329  public class Client {
4329          getEffectInstanceParameterInfo(int instanceId, int parameter)          getEffectInstanceParameterInfo(int instanceId, int parameter)
4330                                  throws IOException, LscpException, LSException                                  throws IOException, LscpException, LSException
4331          {          {
4332                  EffectParameter prm = new EffectParameter();                  EffectParameter prm = new EffectParameter(instanceId, parameter);
4333                  String s = String.valueOf(instanceId) + " " + String.valueOf(parameter);                  String s = String.valueOf(instanceId) + " " + String.valueOf(parameter);
4334                  if(!retrieveInfo("GET EFFECT_INSTANCE_INPUT_CONTROL INFO " + s, prm)) return null;                  if(!retrieveInfo("GET EFFECT_INSTANCE_INPUT_CONTROL INFO " + s, prm)) return null;
4335    
# Line 4363  public class Client { Line 4375  public class Client {
4375          /**          /**
4376           * Gets the current list of send effect chains on the specified audio output device.           * Gets the current list of send effect chains on the specified audio output device.
4377           * @param audioDeviceId The numerical ID of the audio output device.           * @param audioDeviceId The numerical ID of the audio output device.
4378           * @return An <code>EffectInstance</code> array           * @return An <code>EffectInstanceInfo</code> array
4379           * providing the current list of effect instances.           * providing the current list of effect instances.
4380           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
4381           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
4382           */           */
4383          public synchronized EffectChain[]          public synchronized EffectChainInfo[]
4384          getSendEffectChains(int audioDeviceId) throws IOException, LscpException, LSException {          getSendEffectChains(int audioDeviceId) throws IOException, LscpException, LSException {
4385                  Integer[] idS = getSendEffectChainIDs(audioDeviceId);                  Integer[] idS = getSendEffectChainIDs(audioDeviceId);
4386                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4387    
4388                  EffectChain[] ecs = new EffectChain[idS.length];                  EffectChainInfo[] ecs = new EffectChainInfo[idS.length];
4389    
4390                  for(int i = 0; i < ecs.length; i++) {                  for(int i = 0; i < ecs.length; i++) {
4391                          ecs[i] = getSendEffectChainInfo(audioDeviceId, idS[i]);                          ecs[i] = getSendEffectChainInfo(audioDeviceId, idS[i]);
# Line 4426  public class Client { Line 4438  public class Client {
4438           * Gets the current information of a send effect chain.           * Gets the current information of a send effect chain.
4439           * @param audioDeviceId The numerical ID of the audio output device.           * @param audioDeviceId The numerical ID of the audio output device.
4440           * @param chainId The numerical ID of the send effect chain.           * @param chainId The numerical ID of the send effect chain.
4441           * @return <code>EffectChain</code> object containing           * @return <code>EffectChainInfo</code> object containing
4442           * the current informations about the specified effect chain.           * the current informations about the specified effect chain.
4443           * @throws IOException If an I/O error occurs.           * @throws IOException If an I/O error occurs.
4444           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
4445           * @throws LSException If the audio device ID or the effect chain ID is invalid.           * @throws LSException If the audio device ID or the effect chain ID is invalid.
4446           */           */
4447          public synchronized EffectChain          public synchronized EffectChainInfo
4448          getSendEffectChainInfo(int audioDeviceId, int chainId)          getSendEffectChainInfo(int audioDeviceId, int chainId)
4449                                  throws IOException, LscpException, LSException                                  throws IOException, LscpException, LSException
4450          {          {
# Line 4442  public class Client { Line 4454  public class Client {
4454                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4455    
4456                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
4457                  EffectChain chain = null;                  EffectChainInfo chain = null;
4458    
4459                  for(String s : rs.getMultiLineResult()) {                  for(String s : rs.getMultiLineResult()) {
4460                          if(s.startsWith("EFFECT_SEQUENCE: ")) {                          if(s.startsWith("EFFECT_SEQUENCE: ")) {
4461                                  s = s.substring("EFFECT_SEQUENCE: ".length());                                  s = s.substring("EFFECT_SEQUENCE: ".length());
4462                                  Integer[] eis = parseIntList(s);                                  Integer[] eis = parseIntList(s);
4463                                  EffectInstance[] instances = new EffectInstance[eis.length];                                  EffectInstanceInfo[] instances = new EffectInstanceInfo[eis.length];
4464                                  for(int i = 0; i < eis.length; i++) {                                  for(int i = 0; i < eis.length; i++) {
4465                                          instances[i] = getEffectInstanceInfo(eis[i]);                                          instances[i] = getEffectInstanceInfo(eis[i]);
4466                                  }                                  }
4467                                  chain = new EffectChain(instances);                                  chain = new EffectChainInfo(instances);
4468                                  chain.setChainId(chainId);                                  chain.setChainId(chainId);
4469                          }                          }
4470                  }                  }

Legend:
Removed from v.2190  
changed lines
  Added in v.2240

  ViewVC Help
Powered by ViewVC