From 9d4c49aaf0c0fadd53ce93ac46e36e76fd997a4a Mon Sep 17 00:00:00 2001 From: majun Date: Thu, 17 Mar 2016 14:49:21 +0800 Subject: [PATCH] modify EZAudioDevice internal implementation to make enumeration methods work like NSArray; --- EZAudio/EZAudioDevice.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/EZAudio/EZAudioDevice.m b/EZAudio/EZAudioDevice.m index 6eacc2f6..64c7e93f 100644 --- a/EZAudio/EZAudioDevice.m +++ b/EZAudio/EZAudioDevice.m @@ -117,7 +117,7 @@ + (void)enumerateInputDevicesUsingBlock:(void (^)(EZAudioDevice *, BOOL *))block return; } - BOOL stop; + BOOL stop = NO; for (AVAudioSessionPortDescription *inputDevicePortDescription in inputs) { // add any additional sub-devices @@ -130,6 +130,10 @@ + (void)enumerateInputDevicesUsingBlock:(void (^)(EZAudioDevice *, BOOL *))block device.port = inputDevicePortDescription; device.dataSource = inputDeviceDataSourceDescription; block(device, &stop); + if (stop) + { + break; + } } } else @@ -153,7 +157,7 @@ + (void)enumerateOutputDevicesUsingBlock:(void (^)(EZAudioDevice *, BOOL *))bloc AVAudioSessionRouteDescription *currentRoute = [[AVAudioSession sharedInstance] currentRoute]; NSArray *portDescriptions = [currentRoute outputs]; - BOOL stop; + BOOL stop = NO; for (AVAudioSessionPortDescription *outputDevicePortDescription in portDescriptions) { // add any additional sub-devices @@ -166,6 +170,10 @@ + (void)enumerateOutputDevicesUsingBlock:(void (^)(EZAudioDevice *, BOOL *))bloc device.port = outputDevicePortDescription; device.dataSource = outputDeviceDataSourceDescription; block(device, &stop); + if (stop) + { + break; + } } } else