Commit 6cd6fa17 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

AudioService: do not leak resources in exceptions

And catch all exceptions
parent f1069517
...@@ -1382,8 +1382,8 @@ public class AudioService extends Service { ...@@ -1382,8 +1382,8 @@ public class AudioService extends Service {
return; return;
String line; String line;
FileInputStream input; FileInputStream input = null;
BufferedReader br; BufferedReader br = null;
int rowCount = 0; int rowCount = 0;
int position = 0; int position = 0;
...@@ -1396,7 +1396,7 @@ public class AudioService extends Service { ...@@ -1396,7 +1396,7 @@ public class AudioService extends Service {
br = new BufferedReader(new InputStreamReader(input)); br = new BufferedReader(new InputStreamReader(input));
currentMedia = br.readLine(); currentMedia = br.readLine();
mShuffling = "1".equals(br.readLine()); mShuffling = "1".equals(br.readLine());
br.close(); br.close(); br = null;
input.close(); input.close();
// read MediaList // read MediaList
...@@ -1408,18 +1408,23 @@ public class AudioService extends Service { ...@@ -1408,18 +1408,23 @@ public class AudioService extends Service {
position = rowCount; position = rowCount;
rowCount++; rowCount++;
} }
br.close();
input.close();
// load playlist // load playlist
mInterface.load(mediaPathList, position, false); mInterface.load(mediaPathList, position, false);
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} catch (RemoteException e) { }
finally {
try {
if (br!= null) br.close();
if (input != null) input.close();
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
private synchronized void saveCurrentMedia() { private synchronized void saveCurrentMedia() {
if (!AndroidDevices.hasExternalStorage()) if (!AndroidDevices.hasExternalStorage())
return; return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment