Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Added in-place preamp recovery when I2C writes fail persistently
* Fixed all loopback dmix devices sharing one ipc_key in asound.conf, which made loopback playback devices intermittently fail to open with EINVAL (#957)
* Disabled USB autosuspend for the CM6206 USB audio device
* Fixed LMS stream shutdown force-killing the wrong process group
* Web App
* Add warning for older versions of the webapp running on newer backends

Expand Down
14 changes: 10 additions & 4 deletions amplipi/streams/lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def _activate(self, vsrc: int):
meta_args.extend(["--server", f"{self.server}"])
if self.port is not None:
meta_args.extend(["--port", f"{self.port}"])
self.meta_proc = subprocess.Popen(args=meta_args, stdout=sys.stdout, stderr=sys.stderr)
self.meta_proc = subprocess.Popen(args=meta_args, stdout=sys.stdout, stderr=sys.stderr, preexec_fn=os.setpgrp)

self.proc = subprocess.Popen(args=lms_args)
self.proc = subprocess.Popen(args=lms_args, preexec_fn=os.setpgrp)
except Exception as exc:
logger.exception(f'error starting lms: {exc}')

Expand All @@ -106,7 +106,10 @@ def _deactivate(self):
except Exception as e:
logger.exception(f"failed to gracefully terminate LMS stream {self.name}: {e}")
logger.warning(f"forcefully killing LMS stream {self.name}")
os.killpg(self.proc.pid, signal.SIGKILL)
try:
os.killpg(os.getpgid(self.proc.pid), signal.SIGKILL)
except ProcessLookupError:
pass
self.proc.communicate(timeout=3)

if self.meta_proc is not None:
Expand All @@ -116,7 +119,10 @@ def _deactivate(self):
except Exception as e:
logger.exception(f"failed to gracefully terminate LMS meta proc for {self.name}: {e}")
logger.warning(f"forcefully killing LMS meta proc for {self.name}")
os.killpg(self.meta_proc.pid, signal.SIGKILL)
try:
os.killpg(os.getpgid(self.meta_proc.pid), signal.SIGKILL)
except ProcessLookupError:
pass
self.meta_proc.communicate(timeout=3)

self.proc = None
Expand Down
Loading