From e292d8cfb1f14c895678cf168ac1e0a6467f5799 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Fri, 1 Jul 2016 09:15:39 +0200 Subject: [PATCH] Update AudioUnit backend. --- src/cubeb_audiounit.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp index 41deebf..f0928ba 100644 --- a/src/cubeb_audiounit.cpp +++ b/src/cubeb_audiounit.cpp @@ -705,7 +705,7 @@ audiounit_get_max_channel_count(cubeb * ctx, uint32_t * max_channels) } static int -audiounit_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * latency_ms) +audiounit_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * latency_frames) { #if TARGET_OS_IPHONE //TODO: [[AVAudioSession sharedInstance] inputLatency] @@ -716,7 +716,7 @@ audiounit_get_min_latency(cubeb * ctx, cubeb_stream_params params, uint32_t * la return CUBEB_ERROR; } - *latency_ms = ceil((latency_range.mMinimum * 1000 ) / params.rate); + *latency_frames = latency_range.mMinimum; #endif return CUBEB_OK; @@ -906,7 +906,7 @@ audiounit_stream_init(cubeb * context, cubeb_stream_params * input_stream_params, cubeb_devid output_device, cubeb_stream_params * output_stream_params, - unsigned int latency, + unsigned int latency_frames, cubeb_data_callback data_callback, cubeb_state_callback state_callback, void * user_ptr) @@ -1127,7 +1127,7 @@ audiounit_stream_init(cubeb * context, // Setting the latency doesn't work well for USB headsets (eg. plantronics). // Keep the default latency for now. #if 0 - buffer_size = latency / 1000.0 * ss.mSampleRate; + buffer_size = latency; /* Get the range of latency this particular device can work with, and clamp * the requested latency to this acceptable range. */ @@ -1768,11 +1768,11 @@ audiounit_create_device_from_hwdev(AudioObjectID devid, cubeb_device_type type) adr.mSelector = kAudioDevicePropertyBufferFrameSizeRange; size = sizeof(AudioValueRange); if (AudioObjectGetPropertyData(devid, &adr, 0, NULL, &size, &range) == noErr) { - ret->latency_lo_ms = ((latency + range.mMinimum) * 1000) / ret->default_rate; - ret->latency_hi_ms = ((latency + range.mMaximum) * 1000) / ret->default_rate; + ret->latency_lo = latency + range.mMinimum; + ret->latency_hi = latency + range.mMaximum; } else { - ret->latency_lo_ms = 10; /* Default to 10ms */ - ret->latency_hi_ms = 100; /* Default to 100ms */ + ret->latency_lo = 10 * ret->default_rate / 1000; /* Default to 10ms */ + ret->latency_hi = 100 * ret->default_rate / 1000; /* Default to 100ms */ } return ret;