diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2019-12-22 01:41:48 -0500 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2019-12-22 01:41:48 -0500 |
commit | fbd8962b14b0a9b62c664710c826455c0fef79bc (patch) | |
tree | 4b6676b28c66e02b3d2e0606978c48d7fd56bcfd /src/main | |
parent | e0bf4679553065ee76b6250f28c268bc804e6fdc (diff) | |
download | SoundChan-fbd8962b14b0a9b62c664710c826455c0fef79bc.tar.gz SoundChan-fbd8962b14b0a9b62c664710c826455c0fef79bc.tar.bz2 SoundChan-fbd8962b14b0a9b62c664710c826455c0fef79bc.zip |
Sound plays again and preemptive user sound dir fix
I was being too proactive about checking for a null condition, so the
AudioPlayerSendHandler wasn't able to grab the data correctly.
Also now check for the directory the user supplies for usersound
existing and that it is a directory before populating files from it.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/soundchan/AudioPlayerSendHandler.java | 9 | ||||
-rw-r--r-- | src/main/java/soundchan/LocalAudioManager.java | 13 |
2 files changed, 8 insertions, 14 deletions
diff --git a/src/main/java/soundchan/AudioPlayerSendHandler.java b/src/main/java/soundchan/AudioPlayerSendHandler.java index fdd9774..43b1c75 100644 --- a/src/main/java/soundchan/AudioPlayerSendHandler.java +++ b/src/main/java/soundchan/AudioPlayerSendHandler.java @@ -24,19 +24,12 @@ public class AudioPlayerSendHandler implements AudioSendHandler { @Override public boolean canProvide() { - if (lastFrame == null) { - lastFrame = audioPlayer.provide(); - } - + lastFrame = audioPlayer.provide(); return lastFrame != null; } @Override public ByteBuffer provide20MsAudio() { - if (lastFrame == null) { - lastFrame = audioPlayer.provide(); - } - return ByteBuffer.wrap(lastFrame.getData()); } diff --git a/src/main/java/soundchan/LocalAudioManager.java b/src/main/java/soundchan/LocalAudioManager.java index 4db7010..b34c8f4 100644 --- a/src/main/java/soundchan/LocalAudioManager.java +++ b/src/main/java/soundchan/LocalAudioManager.java @@ -112,14 +112,15 @@ public class LocalAudioManager { */ private Map<String, String> PopulateFiles(){ File folder = new File(filepath); - File[] listOfFiles = folder.listFiles(); - Map<String, String> fileDict = new HashMap<>(); + if(folder.exists() && folder.isDirectory()) { + File[] listOfFiles = folder.listFiles(); - for (File file : listOfFiles) { - if (file.isFile()) { - String filename = file.getName(); - fileDict.put(filename.substring(0, filename.indexOf('.')), filename); + for (File file : listOfFiles) { + if (file.isFile()) { + String filename = file.getName(); + fileDict.put(filename.substring(0, filename.indexOf('.')), filename); + } } } return fileDict; |