Skip to content

cli tools: fix frame size estimation when frame_length isn't provided - #831

Open
baranovmv wants to merge 2 commits into
roc-streaming:developfrom
baranovmv:fix/auto_frame_sz
Open

cli tools: fix frame size estimation when frame_length isn't provided#831
baranovmv wants to merge 2 commits into
roc-streaming:developfrom
baranovmv:fix/auto_frame_sz

Conversation

@baranovmv

@baranovmv baranovmv commented Feb 28, 2026

Copy link
Copy Markdown
Member

In multi channel scenario a frame sz become too big and Frame Factory refuses to allocate frames. Here the max frame size is estimated similar way to max packet sz estimation.

gh-821

@baranovmv
baranovmv requested a review from gavv February 28, 2026 22:22
@rocstreaming-bot rocstreaming-bot added the S-ready-for-review status: PR can be reviewed label Feb 28, 2026
@rocstreaming-bot

Copy link
Copy Markdown

🤖 Pull request description does not have a link to an issue.
If there is a related issue, please add it to the description using any of the supported formats.

gavv

This comment was marked as resolved.

@gavv

This comment was marked as resolved.

@gavv gavv added this to the 0.5.0 milestone Jun 25, 2026
@gavv

gavv commented Jun 25, 2026

Copy link
Copy Markdown
Member

If you remember a command that reproduces the bug, could you create an issue with command and output? I didn't see this issue in my tests. Nice to have, but not critical.

@gavv gavv added S-needs-revision status: Author should revise PR and address feedback and removed S-ready-for-review status: PR can be reviewed labels Jun 25, 2026
In multi channel scenario a frame sz become too big and Frame Factory
refuses to allocate frames. Here the max frame size is estimated
similar way to max packet sz estimation.
@baranovmv
baranovmv force-pushed the fix/auto_frame_sz branch from 7b5f737 to 6c0f5d9 Compare June 26, 2026 13:49
@baranovmv

Copy link
Copy Markdown
Member Author

Fixes #821

@baranovmv

Copy link
Copy Markdown
Member Author

@gavv

If you remember a command that reproduces the bug, could you create an issue with command and output? I didn't see this issue in my tests. Nice to have, but not critical.

The issue itself needs arguebly a better solution. This PR proposes a hot-fix for basic and straightforward scenarios in our CLI tools. So at the moment there is no easy way to verify the fix proposed in this PR with our unit tests.

IMHO the issue reveals a usability problem in our public API and as a consequence lead to a corresponding issue in command line parameter of CLI tools.

Let me elaborate on a "better solution" a bit:

  • I'd rather see MTU (size in bytes) parameter instead of roc_sender_config::packet_length (duration)
  • roc_context_config::max_frame_size in it's order could be deduced from MTU, but sometimes it'd make more sense to deduce it from the application. E.g. for pipewire modules it'd be great to tie max_frame_size to quants

@baranovmv baranovmv added S-ready-for-review status: PR can be reviewed and removed S-needs-revision status: Author should revise PR and address feedback labels Jun 27, 2026
@gavv

gavv commented Aug 24, 2026

Copy link
Copy Markdown
Member

I think you've accidentally committed distfiles from master:

image

: profiling_interval(core::Second)
, chunk_duration(10 * core::Millisecond) {
, chunk_duration(sndio::DefaultFrameLength) {
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far roc_audio doesn't depend on roc_sndio (it's the opposite), and I think it's different 10ms. Here 1sec and 1ms are related, and OTOH frame size should be irrelevant.

Comment on lines +23 to 32
namespace {

//! Default duration of a frame. 10ms is rather high,
//! but works well even on cheap sound cards and CPUs.
//! Usually you can use much lower values.
const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;

} // namespace

//! Sink and source config.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is best practice, but elsewhere in code we don't have anon namespace for .h consts.

Suggested change
namespace {
//! Default duration of a frame. 10ms is rather high,
//! but works well even on cheap sound cards and CPUs.
//! Usually you can use much lower values.
const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;
} // namespace
//! Sink and source config.
//! Default duration of a frame. 10ms is rather high,
//! but works well even on cheap sound cards and CPUs.
//! Usually you can use much lower values.
const core::nanoseconds_t DefaultFrameLength = 10 * core::Millisecond;
//! Sink and source config.

@gavv

gavv commented Aug 24, 2026

Copy link
Copy Markdown
Member

Agree with the better solution.

To take the idea further:

  • I'd rather see MTU (size in bytes) parameter instead of roc_sender_config::packet_length (duration)

I think we should have both. User can set packet length (if they care about latency; if they use non-PCM), or MTU (if they care), or both.

If only one is set, the other is derived. If both are set, we may either validate that packet len fits MCU, or use the smaller one.

  • roc_context_config::max_frame_size in it's order could be deduced from MTU, but sometimes it'd make more sense to deduce it from the application. E.g. for pipewire modules it'd be great to tie max_frame_size to quants

Actually, I think we should get make max_frame_size and max_packet_size optional, and if they're not set, don't place any limits. This would require reworking slab pool to support dynamic chunk size, which should be feasible (e.g. using buddy allocator).

@gavv gavv added S-needs-revision status: Author should revise PR and address feedback and removed S-ready-for-review status: PR can be reviewed labels Aug 24, 2026
@gavv

gavv commented Aug 24, 2026

Copy link
Copy Markdown
Member

Please rebase on fresh develop to make CI green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-needs-revision status: Author should revise PR and address feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants