Enforce client disconnect when closing monitoring view
This commit is contained in:
@@ -84,7 +84,7 @@ public class MonitorActivity extends Activity {
|
|||||||
socket.setSendBufferSize(pcmBufferSize);
|
socket.setSendBufferSize(pcmBufferSize);
|
||||||
Log.d(TAG, "Socket send buffer size: " + socket.getSendBufferSize());
|
Log.d(TAG, "Socket send buffer size: " + socket.getSendBufferSize());
|
||||||
|
|
||||||
while (socket.isConnected() && !Thread.currentThread().isInterrupted()) {
|
while (socket.isConnected() && currentSocket != null && !Thread.currentThread().isInterrupted()) {
|
||||||
final int read = audioRecord.read(pcmBuffer, 0, bufferSize);
|
final int read = audioRecord.read(pcmBuffer, 0, bufferSize);
|
||||||
int encoded = CODEC.encode(pcmBuffer, read, ulawBuffer, 0);
|
int encoded = CODEC.encode(pcmBuffer, read, ulawBuffer, 0);
|
||||||
out.write(ulawBuffer, 0, encoded);
|
out.write(ulawBuffer, 0, encoded);
|
||||||
@@ -181,7 +181,7 @@ public class MonitorActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onStop() {
|
||||||
Log.i(TAG, "ChildMonitor stop");
|
Log.i(TAG, "ChildMonitor stop");
|
||||||
|
|
||||||
unregisterService();
|
unregisterService();
|
||||||
@@ -190,12 +190,12 @@ public class MonitorActivity extends Activity {
|
|||||||
if(currentSocket != null) {
|
if(currentSocket != null) {
|
||||||
try {
|
try {
|
||||||
currentSocket.close();
|
currentSocket.close();
|
||||||
|
currentSocket = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to close active socket on port "+currentPort);
|
Log.e(TAG, "Failed to close active socket on port "+currentPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
super.onStop();
|
||||||
super.onDestroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerService(final int port) {
|
private void registerService(final int port) {
|
||||||
|
|||||||
Reference in New Issue
Block a user