projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosui: Remove ability to graph data in .csv files
[fw/altos]
/
ao-tools
/
altosui
/
AltosVoice.java
diff --git
a/ao-tools/altosui/AltosVoice.java
b/ao-tools/altosui/AltosVoice.java
index ebe9d5a81c0d5c8b1cab4084db70925dc59049b8..ac13ee14e81176c69d46587392340c3a8018ba62 100644
(file)
--- a/
ao-tools/altosui/AltosVoice.java
+++ b/
ao-tools/altosui/AltosVoice.java
@@
-27,6
+27,7
@@
public class AltosVoice implements Runnable {
Voice voice;
LinkedBlockingQueue<String> phrases;
Thread thread;
Voice voice;
LinkedBlockingQueue<String> phrases;
Thread thread;
+ boolean busy;
final static String voice_name = "kevin16";
final static String voice_name = "kevin16";
@@
-35,15
+36,30
@@
public class AltosVoice implements Runnable {
for (;;) {
String s = phrases.take();
voice.speak(s);
for (;;) {
String s = phrases.take();
voice.speak(s);
+ synchronized(this) {
+ if (phrases.isEmpty()) {
+ busy = false;
+ notifyAll();
+ }
+ }
}
} catch (InterruptedException e) {
}
}
}
} catch (InterruptedException e) {
}
}
+ public synchronized void drain() throws InterruptedException {
+ while (busy)
+ wait();
+ }
+
public void speak_always(String s) {
try {
public void speak_always(String s) {
try {
- if (voice != null)
- phrases.put(s);
+ if (voice != null) {
+ synchronized(this) {
+ busy = true;
+ phrases.put(s);
+ }
+ }
} catch (InterruptedException e) {
}
}
} catch (InterruptedException e) {
}
}
@@
-58,6
+74,7
@@
public class AltosVoice implements Runnable {
}
public AltosVoice () {
}
public AltosVoice () {
+ busy = false;
voice_manager = VoiceManager.getInstance();
voice = voice_manager.getVoice(voice_name);
if (voice != null) {
voice_manager = VoiceManager.getInstance();
voice = voice_manager.getVoice(voice_name);
if (voice != null) {