refractoring

This commit is contained in:
2025-02-27 11:04:13 +01:00
parent f3107b5cad
commit fc67f0f23d

View File

@@ -368,7 +368,9 @@ class Streamer():
""" """
Streamer class that supports multiple input formats. See bumble for streaming from wav or device Streamer class that supports multiple input formats. See bumble for streaming from wav or device
Added functionallity on top of bumble: Added functionallity on top of bumble:
- precode wav files, - loop parameter
- if True the audio_source will be looped for ever
- precode wav files
- lc3 coded files - lc3 coded files
- just use a .lc3 file as audio_source - just use a .lc3 file as audio_source
- lc3 coded from ram - lc3 coded from ram
@@ -516,10 +518,9 @@ class Streamer():
for i, big in enumerate(bigs.values()): for i, big in enumerate(bigs.values()):
if big['precoded']:# everything was already lc3 coded beforehand if big['precoded']:# everything was already lc3 coded beforehand
lc3_frame = b"" lc3_frame = bytes(
# list(itertools.islice(iterator, 3)) itertools.islice(big['lc3_frames'], big['lc3_bytes_per_frame'])
for _ in range(big['lc3_bytes_per_frame']): # have a look at itertools.islice )
lc3_frame += next(big['lc3_frames']).to_bytes() # TODO: use async ?
else: else:
pcm_frame = await anext(big['audio_input'].frames(big['lc3_frame_samples']), None) pcm_frame = await anext(big['audio_input'].frames(big['lc3_frame_samples']), None)
if pcm_frame is None: # Not all streams may stop at the same time if pcm_frame is None: # Not all streams may stop at the same time