Implement audiounit_make_silent

This commit is contained in:
Chun-Min Chang 2019-02-12 15:16:14 -08:00
Родитель f6fdfa4948
Коммит 22a5d5ee41
3 изменённых файлов: 30 добавлений и 3 удалений

Просмотреть файл

@ -49,9 +49,9 @@ Currently it can only be built by *rust-nightly* since we use *nightly-only* ato
### Interanl APIs
- 🥚 : 14/75 (18.6%)
- 🥚 : 13/75 (17.3%)
- 🐣 : 7/75 (9.3%)
- 🐥 : 54/75 (72%)
- 🐥 : 55/75 (73.3%)
| Interanl AudioUnit APIs | status |
| ------------------------------------------- | ------ |
@ -65,7 +65,7 @@ Currently it can only be built by *rust-nightly* since we use *nightly-only* ato
| audiounit_decrement_active_streams | 🐥 |
| audiounit_active_streams | 🐥 |
| audiounit_set_global_latency | 🐥 |
| audiounit_make_silent | 🥚 |
| audiounit_make_silent | 🐥 |
| audiounit_render_input | 🐥 |
| audiounit_input_callback | 🐥 |
| audiounit_mix_output_buffer | 🥚 |

Просмотреть файл

@ -242,6 +242,13 @@ fn audiounit_set_global_latency(ctx: &mut AudioUnitContext, latency_frames: u32)
ctx.global_latency_frames = latency_frames;
}
fn audiounit_make_silent(ioData: &mut AudioBuffer) {
assert!(!ioData.mData.is_null());
unsafe {
libc::memset(ioData.mData, 0, ioData.mDataByteSize as usize);
}
}
fn audiounit_render_input(stm: &mut AudioUnitStream,
flags: *mut AudioUnitRenderActionFlags,
tstamp: *const AudioTimeStamp,

Просмотреть файл

@ -896,6 +896,26 @@ fn test_set_global_latency() {
}
}
// make_silent
// ------------------------------------
#[test]
fn test_make_silent() {
let mut array = allocate_array::<u32>(10);
for data in array.iter_mut() {
*data = 0xFFFF;
}
let mut buffer = AudioBuffer::default();
buffer.mData = array.as_mut_ptr() as *mut c_void;
buffer.mDataByteSize = (array.len() * mem::size_of::<u32>()) as u32;
buffer.mNumberChannels = 1;
audiounit_make_silent(&mut buffer);
for data in array {
assert_eq!(data, 0);
}
}
// render_input
// ------------------------------------
// TODO