Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit be28ef2

Browse files
committed
fix: ensure that resume doesn't hang the pipeline
1 parent dee88c9 commit be28ef2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/java/io/spokestack/spokestack/SpeechPipeline.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,13 @@ public void pause() {
258258
/**
259259
* Resumes a paused speech pipeline, returning the pipeline to a passive
260260
* listening state.
261+
*
262+
* Does nothing if the pipeline has not been previously paused.
261263
*/
262264
public void resume() {
265+
if (!this.paused) {
266+
return;
267+
}
263268
this.paused = false;
264269
synchronized (lock) {
265270
lock.notify();

src/test/java/io/spokestack/spokestack/SpeechPipelineTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ public void testPause() throws Exception {
223223
Thread.sleep(5);
224224
assertTrue(FreeInput.counter > frames);
225225

226+
// resume before pause doesn't cause any hangs
227+
pipeline.resume();
228+
226229
// we won't get any more frames if we're paused
227230
pipeline.pause();
228231

0 commit comments

Comments
 (0)