- 
                Notifications
    
You must be signed in to change notification settings  - Fork 309
 
Open
Description
Hi there,
I’m working on an audio player module with real-time processing for my upcoming app. It uses AudioStream to decode and play audio files in chunks.
So far, things are working well, though the CPU usage is higher compared to players with audio backends written in compiled languages. However, I suspect I’m missing some error-handling logic.
For example, if the output device is unplugged during streaming, stream.running still returns True, and the code freezes at stream.write without raising an exception:
with AudioStream(output_device_name=output_device) as stream:
    with AudioFile(audiofile) as f:
        while f.tell() < f.frames:
            print('Streaming:', stream.running)
            stream.write(f.read(512), sample_rate=f.samplerate)This makes it difficult (or even impossible) to handle such cases gracefully. Is there a way to resolve this?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels