X-Git-Url: http://git.scottworley.com/srec/blobdiff_plain/99c6dc78ff64331f53e626354c4900a3f539a25d..9ce111085151ffcd78d6541d44db8b4bb59b3eb5:/srec.py?ds=sidebyside diff --git a/srec.py b/srec.py index 3490695..dc6aeff 100644 --- 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") @@ -151,7 +156,7 @@ def make_button(label: str, action: Callable[[ def make_share_control() -> Gtk.CheckButton: can_share = os.path.exists('/sys/module/v4l2loopback') control = Gtk.CheckButton( - label='Share Webcam', sensitive=can_share, active=can_share) + label='Share Webcam', sensitive=can_share) control.set_margin_start(20) return control @@ -186,6 +191,7 @@ def main() -> None: app = Gtk.Application(application_id='net.chkno.srec') app.connect('activate', on_activate) app.run(None) + stop_streams() if __name__ == '__main__':