Cleanup AudioRecord if socket throws an exception
Previously an IOException would prevent the AudioRecord from being cleaned up.
This commit is contained in:
@@ -67,6 +67,9 @@ public class MonitorActivity extends Activity
|
||||
audioEncoding, bufferSize);
|
||||
|
||||
byte[] buffer = new byte[bufferSize*2];
|
||||
|
||||
try
|
||||
{
|
||||
audioRecord.startRecording();
|
||||
|
||||
OutputStream out = socket.getOutputStream();
|
||||
@@ -79,9 +82,12 @@ public class MonitorActivity extends Activity
|
||||
int read = audioRecord.read(buffer, 0, bufferSize);
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
|
||||
socket.close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
audioRecord.stop();
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user