28 |
import java.net.InetSocketAddress; |
import java.net.InetSocketAddress; |
29 |
import java.net.Socket; |
import java.net.Socket; |
30 |
import java.net.SocketTimeoutException; |
import java.net.SocketTimeoutException; |
|
import java.net.UnknownHostException; |
|
31 |
|
|
32 |
import java.util.Vector; |
import java.util.Vector; |
33 |
import java.util.logging.Level; |
import java.util.logging.Level; |
84 |
|
|
85 |
EventThread() { super("LSCP-Event-Thread"); } |
EventThread() { super("LSCP-Event-Thread"); } |
86 |
|
|
87 |
|
@Override |
88 |
public void |
public void |
89 |
run() { |
run() { |
90 |
while(!mustTerminate()) { |
while(!mustTerminate()) { |
186 |
soTimeout = timeout; |
soTimeout = timeout; |
187 |
|
|
188 |
try { if(sock != null) sock.setSoTimeout(timeout); } |
try { if(sock != null) sock.setSoTimeout(timeout); } |
189 |
catch(Exception x) { this.getLogger().log(Level.INFO, "Unable to set timeout", x); } |
catch(Exception x) { getLogger().log(Level.INFO, "Unable to set timeout", x); } |
190 |
} |
} |
191 |
|
|
192 |
private String |
private String |
964 |
float f = Float.parseFloat(s.substring("VOLUME ".length())); |
float f = Float.parseFloat(s.substring("VOLUME ".length())); |
965 |
GlobalInfoEvent e = new GlobalInfoEvent(this, f); |
GlobalInfoEvent e = new GlobalInfoEvent(this, f); |
966 |
for(GlobalInfoListener l : llGI) l.volumeChanged(e); |
for(GlobalInfoListener l : llGI) l.volumeChanged(e); |
967 |
|
} else if(s.startsWith("VOICES ")) { |
968 |
|
int i = Integer.parseInt(s.substring("VOICES ".length())); |
969 |
|
GlobalInfoEvent e = new GlobalInfoEvent(this, i, -1); |
970 |
|
for(GlobalInfoListener l : llGI) l.voiceLimitChanged(e); |
971 |
|
} else if(s.startsWith("STREAMS ")) { |
972 |
|
int i = Integer.parseInt(s.substring("STREAMS ".length())); |
973 |
|
GlobalInfoEvent e = new GlobalInfoEvent(this, -1, i); |
974 |
|
for(GlobalInfoListener l : llGI) l.streamLimitChanged(e); |
975 |
|
} else { |
976 |
|
getLogger().info("Unknown GLOBAL_INFO format: " + s); |
977 |
} |
} |
978 |
} catch(NumberFormatException x) { |
} catch(NumberFormatException x) { |
979 |
getLogger().log(Level.WARNING, "Unknown GLOBAL_INFO format", x); |
getLogger().log(Level.WARNING, "Unknown GLOBAL_INFO format", x); |
5301 |
} |
} |
5302 |
|
|
5303 |
/** |
/** |
5304 |
* Gets the golobal volume of the sampler. |
* Gets the global volume of the sampler. |
5305 |
* @return The golobal volume of the sampler. |
* @return The global volume of the sampler. |
5306 |
* @throws IOException If some I/O error occurs. |
* @throws IOException If some I/O error occurs. |
5307 |
* @throws LscpException If LSCP protocol corruption occurs. |
* @throws LscpException If LSCP protocol corruption occurs. |
5308 |
* @throws LSException If some other error occurs. |
* @throws LSException If some other error occurs. |
5336 |
} |
} |
5337 |
|
|
5338 |
/** |
/** |
5339 |
|
* Gets the global sampler-wide limit of maximum voices. |
5340 |
|
* @return The global sampler-wide limit of maximum voices. |
5341 |
|
* @throws IOException If some I/O error occurs. |
5342 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5343 |
|
* @throws LSException If some other error occurs. |
5344 |
|
*/ |
5345 |
|
public synchronized int |
5346 |
|
getGlobalVoiceLimit() throws IOException, LscpException, LSException { |
5347 |
|
verifyConnection(); |
5348 |
|
out.writeLine("GET VOICES"); |
5349 |
|
if(getPrintOnlyMode()) return -1; |
5350 |
|
|
5351 |
|
String s = getSingleLineResultSet().getResult(); |
5352 |
|
return parseInt(s); |
5353 |
|
} |
5354 |
|
|
5355 |
|
/** |
5356 |
|
* Sets the global sampler-wide limit of maximum voices. |
5357 |
|
* @param maxVoices The new global limit of maximum voices. |
5358 |
|
* @throws IOException If some I/O error occurs. |
5359 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5360 |
|
* @throws LSException If some other error occurs. |
5361 |
|
* @see #getVolume |
5362 |
|
*/ |
5363 |
|
public synchronized void |
5364 |
|
setGlobalVoiceLimit(int maxVoices) throws IOException, LscpException, LSException { |
5365 |
|
verifyConnection(); |
5366 |
|
out.writeLine("SET VOICES " + maxVoices); |
5367 |
|
if(getPrintOnlyMode()) return; |
5368 |
|
|
5369 |
|
ResultSet rs = getEmptyResultSet(); |
5370 |
|
} |
5371 |
|
|
5372 |
|
/** |
5373 |
|
* Gets the global sampler-wide limit of maximum disk streams. |
5374 |
|
* @return The global sampler-wide limit of maximum disk streams. |
5375 |
|
* @throws IOException If some I/O error occurs. |
5376 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5377 |
|
* @throws LSException If some other error occurs. |
5378 |
|
*/ |
5379 |
|
public synchronized int |
5380 |
|
getGlobalStreamLimit() throws IOException, LscpException, LSException { |
5381 |
|
verifyConnection(); |
5382 |
|
out.writeLine("GET STREAMS"); |
5383 |
|
if(getPrintOnlyMode()) return -1; |
5384 |
|
|
5385 |
|
String s = getSingleLineResultSet().getResult(); |
5386 |
|
return parseInt(s); |
5387 |
|
} |
5388 |
|
|
5389 |
|
/** |
5390 |
|
* Sets the global sampler-wide limit for maximum disk streams. |
5391 |
|
* @param maxVoices The new global limit of maximum disk streams. |
5392 |
|
* @throws IOException If some I/O error occurs. |
5393 |
|
* @throws LscpException If LSCP protocol corruption occurs. |
5394 |
|
* @throws LSException If some other error occurs. |
5395 |
|
* @see #getVolume |
5396 |
|
*/ |
5397 |
|
public synchronized void |
5398 |
|
setGlobalStreamLimit(int maxStreams) throws IOException, LscpException, LSException { |
5399 |
|
verifyConnection(); |
5400 |
|
out.writeLine("SET STREAMS " + maxStreams); |
5401 |
|
if(getPrintOnlyMode()) return; |
5402 |
|
|
5403 |
|
ResultSet rs = getEmptyResultSet(); |
5404 |
|
} |
5405 |
|
|
5406 |
|
/** |
5407 |
* Gets the number of instruments in the specified instrument file. |
* Gets the number of instruments in the specified instrument file. |
5408 |
* @param filename The absolute path name of the instrument file. |
* @param filename The absolute path name of the instrument file. |
5409 |
* @return The number of instruments in the specified instrument file. |
* @return The number of instruments in the specified instrument file. |
5470 |
super(resultSet); |
super(resultSet); |
5471 |
} |
} |
5472 |
|
|
5473 |
|
@Override |
5474 |
public String |
public String |
5475 |
getEngine() { |
getEngine() { |
5476 |
// TODO: engine lookup? |
// TODO: engine lookup? |
5477 |
return getFormatFamily(); |
return getFormatFamily(); |
5478 |
} |
} |
5479 |
|
|
5480 |
|
@Override |
5481 |
public boolean |
public boolean |
5482 |
parse(String s) throws LscpException { |
parse(String s) throws LscpException { |
5483 |
if(s.startsWith("PRODUCT: ") || s.startsWith("ARTISTS: ")) return true; |
if(s.startsWith("PRODUCT: ") || s.startsWith("ARTISTS: ")) return true; |