Skip to content

[Alsa Host] Start threshold of 0 #432

@sniperrifle2004

Description

@sniperrifle2004

I noticed that currently the start threshold is set to 0 frames:

sw_params.set_start_threshold(0)?;

Now this doesn't seem like a good idea to me. I don't think this has well defined behaviour across devices and it also seems counter intuitive, to start recording/playing before there are any frames. For playback that threshold should probably be the buffer size, while for recording a single frame would work and the resulting semantics would be the same.

Using significantly less than the buffer size for playback could result in underruns (Which lead to all kinds of fun), though with the alsa host's current approach to buffering - "Just use whatever the device uses or well 100ms is okay I guess" - that can still happen for certain applications. Luckily #401 will change that). Now a period size (Or even a single frame) would also work, but it's risky. If an application relies on the buffer, because the source is bursting or can just about make the period time, not filling up the buffer before starting will result in underruns and no amount of changing the buffer size will fix that if the start_threshold is not appropriately set.

EDIT: The alsa pcm example uses a period less then a full buffer. I guess that would work as well.

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