Implement make_sized_audio_channel_layout
This commit is contained in:
Родитель
6a126f6b83
Коммит
6eeeee6b62
|
@ -59,13 +59,13 @@ By applying the [patch][integrate-with-cubeb] to integrate within [Cubeb][cubeb]
|
|||
|
||||
### Interanl APIs
|
||||
|
||||
- 🥚 : 10/75 (13.3%)
|
||||
- 🥚 : 9/75 (12%)
|
||||
- 🐣 : 7/75 (9.3%)
|
||||
- 🐥 : 58/75 (77.3%)
|
||||
- 🐥 : 59/75 (78.6%)
|
||||
|
||||
| Interanl AudioUnit APIs | status |
|
||||
| ------------------------------------------- | ------ |
|
||||
| make_sized_audio_channel_layout | 🥚 |
|
||||
| make_sized_audio_channel_layout | 🐥 |
|
||||
| to_string | 🐥 |
|
||||
| has_input | 🐥 |
|
||||
| has_output | 🐥 |
|
||||
|
|
|
@ -150,6 +150,21 @@ enum io_side {
|
|||
OUTPUT,
|
||||
}
|
||||
|
||||
fn make_sized_audio_channel_layout(sz: usize) -> AutoRelease<AudioChannelLayout> {
|
||||
assert!(sz >= mem::size_of::<AudioChannelLayout>());
|
||||
assert_eq!(
|
||||
(sz - mem::size_of::<AudioChannelLayout>()) % mem::size_of::<AudioChannelDescription>(),
|
||||
0
|
||||
);
|
||||
let acl = unsafe { libc::calloc(1, sz) } as *mut AudioChannelLayout;
|
||||
|
||||
unsafe extern "C" fn free_acl(acl: *mut AudioChannelLayout) {
|
||||
libc::free(acl as *mut c_void);
|
||||
}
|
||||
|
||||
AutoRelease::new(acl, free_acl)
|
||||
}
|
||||
|
||||
fn to_string(side: &io_side) -> &'static str
|
||||
{
|
||||
match side {
|
||||
|
|
|
@ -825,6 +825,28 @@ fn test_manual_ctx_stream_register_device_changed_callback() {
|
|||
|
||||
// Private APIs
|
||||
// ============================================================================
|
||||
// make_sized_audio_channel_layout
|
||||
// ------------------------------------
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_make_sized_audio_channel_layout_with_wrong_size() {
|
||||
// let _ = make_sized_audio_channel_layout(0);
|
||||
let one_channel_size = mem::size_of::<AudioChannelLayout>();
|
||||
let padding_size = 10;
|
||||
assert_ne!(mem::size_of::<AudioChannelDescription>(), padding_size);
|
||||
let wrong_size = one_channel_size + padding_size;
|
||||
let _ = make_sized_audio_channel_layout(wrong_size);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_make_sized_audio_channel_layout() {
|
||||
for channels in 1..10 {
|
||||
let size = mem::size_of::<AudioChannelLayout>()
|
||||
+ (channels - 1) * mem::size_of::<AudioChannelDescription>();
|
||||
let _ = make_sized_audio_channel_layout(size);
|
||||
}
|
||||
}
|
||||
|
||||
// to_string
|
||||
// ------------------------------------
|
||||
#[test]
|
||||
|
|
Загрузка…
Ссылка в новой задаче