Signed-off-by: Robert von Könemann <lordtaifleh@gmail.com>
This commit is contained in:
parent
91fbe746e9
commit
fa9e3db34b
@ -17,6 +17,7 @@ import static org.openhab.binding.pulseaudio.internal.PulseaudioBindingConstants
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.net.NoRouteToHostException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
@ -132,7 +133,7 @@ public class PulseaudioClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return client.isConnected();
|
return client != null ? client.isConnected() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -539,6 +540,7 @@ public class PulseaudioClient {
|
|||||||
|
|
||||||
private void sendRawCommand(String command) {
|
private void sendRawCommand(String command) {
|
||||||
checkConnection();
|
checkConnection();
|
||||||
|
if (client != null) {
|
||||||
try {
|
try {
|
||||||
PrintStream out = new PrintStream(client.getOutputStream(), true);
|
PrintStream out = new PrintStream(client.getOutputStream(), true);
|
||||||
logger.trace("sending command {} to pa-server {}", command, host);
|
logger.trace("sending command {} to pa-server {}", command, host);
|
||||||
@ -549,11 +551,13 @@ public class PulseaudioClient {
|
|||||||
logger.error("{}", e.getLocalizedMessage(), e);
|
logger.error("{}", e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String sendRawRequest(String command) {
|
private String sendRawRequest(String command) {
|
||||||
logger.trace("_sendRawRequest({})", command);
|
logger.trace("_sendRawRequest({})", command);
|
||||||
checkConnection();
|
checkConnection();
|
||||||
String result = "";
|
String result = "";
|
||||||
|
if (client != null) {
|
||||||
try {
|
try {
|
||||||
PrintStream out = new PrintStream(client.getOutputStream(), true);
|
PrintStream out = new PrintStream(client.getOutputStream(), true);
|
||||||
out.print(command + "\r\n");
|
out.print(command + "\r\n");
|
||||||
@ -590,6 +594,7 @@ public class PulseaudioClient {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("{}", e.getLocalizedMessage(), e);
|
logger.error("{}", e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,6 +617,8 @@ public class PulseaudioClient {
|
|||||||
client.setSoTimeout(500);
|
client.setSoTimeout(500);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
logger.error("unknown socket host {}", host);
|
logger.error("unknown socket host {}", host);
|
||||||
|
} catch (NoRouteToHostException e) {
|
||||||
|
logger.error("no route to host {}", host);
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
logger.error("{}", e.getLocalizedMessage(), e);
|
logger.error("{}", e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user