]> git.scottworley.com Git - srec/blobdiff - srec.py
Make stop_streams idempotent
[srec] / srec.py
diff --git a/srec.py b/srec.py
index 3490695939be861a7dbd3eec0d439ba660948bb8..c4d5d54a4106c4d826d2236035a2355397cd78e6 100644 (file)
--- a/srec.py
+++ b/srec.py
@@ -126,14 +126,19 @@ def on_start_button(_: Gtk.Button, stack: Gtk.Stack) -> None:
         ['-f', 'pulse', '-ac', '2', '-i', 'default', filename])
 
 
-def on_stop_button(_: Gtk.Button, stack: Gtk.Stack) -> None:
+def stop_streams() -> None:
     global recording, sharing  # pylint: disable=global-statement
-    assert recording is not None
-    recording.stop()
-    recording = None
+    if recording is not None:
+        recording.stop()
+        recording = None
     if sharing is not None:
         sharing.stop()
         sharing = None
+
+
+def on_stop_button(_: Gtk.Button, stack: Gtk.Stack) -> None:
+    assert recording is not None
+    stop_streams()
     stack.set_visible_child_name("not_recording")