Permalink
Browse files

Don't break audio on Arch Linux

Trying to get an alsaaudio PCM in another process
while the PCM is held somewhere else breaks.
Doing this in another thread doesn't break.
I'm not incredibly sure why this is the way it is
  • Loading branch information...
asonix committed Oct 22, 2017
1 parent b5db079 commit b0bd1f907a7c45ccdf1e552e4c80ea458e0a8f2c
Showing with 7 additions and 4 deletions.
  1. +7 −4 piaudio.py
@@ -6,7 +6,8 @@
import psutil, os
import time
import scipy.signal as signal
from multiprocessing import Process, Value
from multiprocessing import Value
from threading import Thread
import pygame
import alsaaudio
import threading
@@ -147,13 +148,15 @@ def start_audio_loop(self):
self.stop_proc = Value('i', 0)
self.ratio = Value('d' , 1.0)
self.p = Process(target=audio_loop, args=(self.wav_data_, self.ratio, self.stop_proc))
self.p.start()
self.t = Thread(target=audio_loop, args=(self.wav_data_, self.ratio, self.stop_proc))
self.t.start()
def stop_audio(self):
self.stop_proc.value = 1
time.sleep(0.1)
self.p.terminate()
self.t.join()
self.transition_future_.cancel()
def change_ratio(self, ratio):
self.ratio.value = ratio

0 comments on commit b0bd1f9

Please sign in to comment.