only terminate sox if its runing
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 27 Sep 2020 18:01:43 +0000 (20:01 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 27 Sep 2020 18:01:43 +0000 (20:01 +0200)
music_assistant/stream_manager.py

index 4b28477d6e5d5bf3165e056d36befe310cb082f4..8dbe4c469d77600c95e025242f807fa9d29c489a 100755 (executable)
@@ -147,8 +147,8 @@ class StreamManager:
             if fill_buffer_task and not fill_buffer_task.cancelled():
                 fill_buffer_task.cancel()
             await sox_proc.communicate()
-            sox_proc.terminate()
             if sox_proc and sox_proc.returncode is None:
+                sox_proc.terminate()
                 await sox_proc.wait()
         else:
             LOGGER.debug(
@@ -204,8 +204,8 @@ class StreamManager:
             if fill_buffer_task and not fill_buffer_task.cancelled():
                 fill_buffer_task.cancel()
             await sox_proc.communicate()
-            sox_proc.terminate()
             if sox_proc and sox_proc.returncode is None:
+                sox_proc.terminate()
                 await sox_proc.wait()
         else:
             LOGGER.debug(
@@ -471,8 +471,8 @@ class StreamManager:
                 )
                 # read remaining bytes
                 await process.communicate()
-                process.terminate()
                 if process and process.returncode is None:
+                    process.terminate()
                     await process.wait()
 
         # signal end of stream event