Pulseaudio: Wait on child processes to avoid zombies
subprocess.Popen() does not implicitly wait() on the child process. This leads to transient zombie pactl processes which are only reaped as new processes are spawned. Use synchronous subprocess communication to collect child process return codes immediately and allow them to exit.
This commit is contained in:
parent
40b9283840
commit
91fae807ed
@ -90,9 +90,8 @@ class PulseAudio(Module, ColorRangeModule):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def sink(self):
|
def sink(self):
|
||||||
self.sinks = subprocess.Popen(['pactl', 'list', 'short', 'sinks'],
|
self.sinks = subprocess.check_output(['pactl', 'list', 'short', 'sinks'],
|
||||||
stdout=subprocess.PIPE,
|
universal_newlines=True).splitlines()
|
||||||
universal_newlines=True).stdout.read().splitlines()
|
|
||||||
bestsink = None
|
bestsink = None
|
||||||
state = 'DEFAULT'
|
state = 'DEFAULT'
|
||||||
for sink in self.sinks:
|
for sink in self.sinks:
|
||||||
@ -184,20 +183,18 @@ class PulseAudio(Module, ColorRangeModule):
|
|||||||
sinks = list(s.split()[1] for s in self.sinks)
|
sinks = list(s.split()[1] for s in self.sinks)
|
||||||
next_sink = (sinks.index(curr_sink) + 1) % len(sinks)
|
next_sink = (sinks.index(curr_sink) + 1) % len(sinks)
|
||||||
|
|
||||||
sink_inputs = subprocess.Popen("pacmd list-sink-inputs".split(),
|
sink_inputs = subprocess.check_output("pacmd list-sink-inputs".split(),
|
||||||
stdout=subprocess.PIPE,
|
universal_newlines=True)
|
||||||
universal_newlines=True).stdout.read()
|
|
||||||
for input_index in re.findall('index:\s+(\d+)', sink_inputs):
|
for input_index in re.findall('index:\s+(\d+)', sink_inputs):
|
||||||
command = "pacmd move-sink-input {} {}".format(input_index, sinks[next_sink])
|
command = "pacmd move-sink-input {} {}".format(input_index, sinks[next_sink])
|
||||||
subprocess.Popen(command.split(),
|
subprocess.call(command.split())
|
||||||
stdout=subprocess.PIPE)
|
subprocess.call("pacmd set-default-sink {}".format(sinks[next_sink]).split())
|
||||||
subprocess.Popen("pacmd set-default-sink {}".format(sinks[next_sink]).split())
|
|
||||||
|
|
||||||
def switch_mute(self):
|
def switch_mute(self):
|
||||||
subprocess.Popen(['pactl', 'set-sink-mute', self.sink, "toggle"])
|
subprocess.call(['pactl', 'set-sink-mute', self.sink, "toggle"])
|
||||||
|
|
||||||
def increase_volume(self):
|
def increase_volume(self):
|
||||||
subprocess.Popen(['pactl', 'set-sink-volume', self.sink, "+%s%%" % self.step])
|
subprocess.call(['pactl', 'set-sink-volume', self.sink, "+%s%%" % self.step])
|
||||||
|
|
||||||
def decrease_volume(self):
|
def decrease_volume(self):
|
||||||
subprocess.Popen(['pactl', 'set-sink-volume', self.sink, "-%s%%" % self.step])
|
subprocess.call(['pactl', 'set-sink-volume', self.sink, "-%s%%" % self.step])
|
||||||
|
Loading…
Reference in New Issue
Block a user