feat(voice): add iOS VAD runtime support
This commit is contained in:
@@ -19,7 +19,7 @@ mod common;
|
||||
use common::{synthetic_opus_bytes, synthetic_opus_frame};
|
||||
|
||||
fn bench_opus_encode_latency(c: &mut Criterion) {
|
||||
let mut enc = Encoder::new(SampleRate::Hz48000, Channels::Mono, Application::Voip)
|
||||
let enc = Encoder::new(SampleRate::Hz48000, Channels::Mono, Application::Voip)
|
||||
.expect("opus encoder init");
|
||||
let pcm = synthetic_opus_frame();
|
||||
let mut out = vec![0u8; 1275];
|
||||
|
||||
@@ -15,15 +15,24 @@
|
||||
// builds and other benches are unaffected per Cargo's per-bench
|
||||
// compilation model.
|
||||
|
||||
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
|
||||
fn main() {}
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
#[global_allocator]
|
||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
use chanora_audio::bench_seam::CaptureBenchHandle;
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
mod common;
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
use common::{synthetic_capture_buffer, FRAME_SAMPLES};
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
fn bench_capture_alloc_count(c: &mut Criterion) {
|
||||
// Build the dhat profiler in test mode so it is process-local
|
||||
// and does not write a JSON heap-dump file. Held for the
|
||||
@@ -90,6 +99,7 @@ fn bench_capture_alloc_count(c: &mut Criterion) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
fn bench_capture_callback_wall_clock(c: &mut Criterion) {
|
||||
let mut handle = CaptureBenchHandle::new(48_000, 1);
|
||||
let buf = synthetic_capture_buffer(FRAME_SAMPLES, 1);
|
||||
@@ -108,9 +118,11 @@ fn bench_capture_callback_wall_clock(c: &mut Criterion) {
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
criterion_group!(
|
||||
realtime_capture,
|
||||
bench_capture_alloc_count,
|
||||
bench_capture_callback_wall_clock
|
||||
);
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
criterion_main!(realtime_capture);
|
||||
|
||||
@@ -8,12 +8,20 @@
|
||||
// feeding a 1-second buffer per iteration. Throughput is reported
|
||||
// as samples/sec via criterion's `Throughput::Elements`.
|
||||
|
||||
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "android"))]
|
||||
fn main() {}
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
use chanora_audio::bench_seam::CaptureBenchHandle;
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
mod common;
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
use common::synthetic_capture_buffer;
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
fn bench_resampler_throughput(c: &mut Criterion) {
|
||||
let mut group = c.benchmark_group("resampler_throughput");
|
||||
|
||||
@@ -39,5 +47,7 @@ fn bench_resampler_throughput(c: &mut Criterion) {
|
||||
group.finish();
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
criterion_group!(resampler, bench_resampler_throughput);
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "android")))]
|
||||
criterion_main!(resampler);
|
||||
|
||||
Reference in New Issue
Block a user