Skip to content

Commit

Permalink
Merge pull request #33 from brarcher/fix-leak
Browse files Browse the repository at this point in the history
Fix leak
  • Loading branch information
brarcher authored Sep 3, 2016
2 parents 94643d7 + f580813 commit cbd642a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/src/main/java/protect/babysleepsounds/LoopingAudioPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public void run()

while(Thread.currentThread().isInterrupted() == false)
{
Log.d(TAG, "Restarting audio file");
is = new FileInputStream(_wavFile);
int read;

Expand All @@ -114,6 +113,14 @@ public void run()
}

// File completed playback, start again
try
{
is.close();
}
catch(IOException e)
{
// Nothing to do, we are finished with the file anyway
}
}
}
catch(IOException e)
Expand All @@ -122,8 +129,6 @@ public void run()
}
finally
{
audioTrack.release();

try
{
if(is != null)
Expand All @@ -135,6 +140,8 @@ public void run()
{
Log.d(TAG, "Failed to close file", e);
}

audioTrack.release();
}

Log.i(TAG, "Finished playback");
Expand Down

0 comments on commit cbd642a

Please sign in to comment.