Skip to content

AudioStream Module Issue: Handling Output Device Errors #411

@Gdalik

Description

@Gdalik

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions