This commit is contained in:
encrypt 2020-04-15 20:17:43 +02:00
parent 17ec4d3bf7
commit 881905a4b3

View file

@ -32,35 +32,27 @@ cursor_time = None
cursor_time = time.time() - BUFFER cursor_time = time.time() - BUFFER
while mumble.is_alive(): while mumble.is_alive():
if cursor_time < time.time() - BUFFER:
if cursor_time < time.time() - BUFFER: # it's time to check audio
base_sound = None base_sound = None
try: try:
for user in mumble.users.values(): # check the audio queue of each user for user in mumble.users.values(): # check the audio queue of each user
while ( user.sound.is_sound() and
user.sound.first_sound().time < cursor_time):
user.sound.get_sound(FLOAT_RESOLUTION) # forget about too old sounds
if user.sound.is_sound(): if user.sound.is_sound():
if ( user.sound.first_sound().time >= cursor_time and # available sound is to be treated now and not later
user.sound.first_sound().time < cursor_time + FLOAT_RESOLUTION ): sound = user.sound.get_sound(FLOAT_RESOLUTION)
# available sound is to be treated now and not later stereo_pcm = audioop.tostereo(sound.pcm, 2, 1, 1)
sound = user.sound.get_sound(FLOAT_RESOLUTION) if base_sound == None:
stereo_pcm = audioop.tostereo(sound.pcm, 2, 1, 1) base_sound = stereo_pcm
if base_sound == None: else:
base_sound = stereo_pcm base_sound = audioop.add(base_sound, stereo_pcm, 2)
else:
base_sound = audioop.add(base_sound, stereo_pcm, 2)
except RuntimeError: except RuntimeError:
eprint("ignored exception in stderr...") eprint("ignored exception in stderr...")
if base_sound: if base_sound:
sys.stdout.buffer.write(base_sound) sys.stdout.buffer.write(base_sound)
else: else:
sys.stdout.buffer.write(silent) sys.stdout.buffer.write(silent)
cursor_time += FLOAT_RESOLUTION cursor_time += FLOAT_RESOLUTION
else: else:
time.sleep(FLOAT_RESOLUTION) time.sleep(FLOAT_RESOLUTION)