Remove duplicate information from duplex callbacks

Open
#1,438 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by locating DuplexCallbackInfo, CallbackInfo, and StreamTimestamp::callback, then trace the duplex callback data flow and their dependencies on #1437. Confirm that the refactor leaves one callback timestamp, one xrun, and one shared data length, potentially using a separate duplex data struct with distinct input and output pointers. No specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Description

API design
  1. DuplexCallbackInfo is composed of 2 CallbackInfos, which means it contains 2 distinct StreamTimestamp::callback values. But duplex streams use a single shared data callback, so there is only 1 callback timestamp to record. This doesn't apply to the device timestamp, as the output one is merely a prediction based on latency (which I think should be exposed separately, but that's another topic).
  2. Having 2 distinct xrun values is pointless, as a disjoint xrun would be, well, disjoint, but the whole point of duplex streams is making this impossible.
  3. Duplex callbacks take 2 distinct Data parameters, each with its own len. These being distinct from one another would again defeat the essence of a duplex stream, so there should only be 1 len.

If we follow through with #1437, then we could simply remove DuplexCallbackInfo and use the regular CallbackInfo in its place. As for the 3rd point, I suggest adding a struct like this:

struct DuplexData {
	input: *const (),
    output: *mut (),
    len: usize,
    input_format: SampleFormat,
    output_format: SampleFormat,
}
Dominant language
Rust
Stars
4k
Forks
554
Avg merge
1d 3h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustAudio/cpal

All issues in RustAudio/cpal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.