-
Notifications
You must be signed in to change notification settings - Fork 469
Open
Labels
Description
Currently CPAL's stream data callback API allows the user to assume that audio data will be provided with channels interleaved in a single slice of memory. There are some issues with this:
- Not all hosts provide an option for emitting data in an interleaved layout. It's also unclear whether some hosts provide non-interleaved channels within contiguous memory. As a result, CPAL currently does the necessary conversion to and from interleaved for these hosts under the hood - a non-trivial cost for energy/peformance-sensitive applications.
- Different downstream applications prefer different layouts, and some hosts allow for specifying a desired layout. E.g. I believe CoreAudio provides an API for requesting interleaved/non-interleaved, though I don't believe there is any guarantee that either is supported, just that at least one of them will be.
We should update CPAL's API guided by the following broad goals:
- Support both interleaved and non-interleaved layouts, while keeping in mind the potential for other more obscure layouts in the future. For now at least we can be sure that each supported host provides at least interleaved and/or non-interleaved.
- Allow users to query if a layout is supported by a device.
- Allow for users to request a particular layout when building a stream.
- Allow for users to provide a callback or callbacks for handling data in different layouts depending on what is supported by the device.
I don't have a solid proposal in mind yet, though thought I'd open this so that we have a place to discuss.
bluenote10 and bbstilson