Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ASIO API supports the sample formats int24 (3 bytes long) in little and big endian variants (see documentation page 33 and 34). Some professional audio interfaces make use of this part of the API. Currently, the ASIO host does not allow for this, so these devices are left unsupported altogether.
This PR introduces support for these sample formats without changing much of the external API. The only change is the fact that the sample format I24 is uncommented. This is a breaking change since the enum has a new member.
Regarding this implementation
Current implementation uses a single function with generics which allows to parse the SampleFormats from/to the ASIO types. Since int24 has no direct representation with rust primitive types, and is in fact represented internally using a i32, this implementation reads/writes bytes directly from/to the ASIO buffers.
ASIO does not support the other sample types such as U24, I48 and U48. Therefore, I decided to implemented a single function for this special case, without refactoring much of the already working one. This part of the ASIO API will likely not change in the future, so I see no benefit in writing a general function to support the aforementioned types.
The existing function could be rewritten completely to support all types (including int24) simultaneously if it would write the raw bytes directly instead of using rust primitive types for every case. It might be somewhat more concise, but it does require refactoring of working code, which in this case, I personally see as a waste of resources.
Examples
Some examples were extended to the use of I24. I honestly never use anything else than ASIO or CoreAudio, so I'm not certain, that everything will just work for the other hosts.
Tests
I did manual tests with a professional audio interface which utilizes ASIO int24 as its default sample type. Both callbacks worked as expected. No unit tests were added here.