coreaudio: Catch devices with more channels than we support
authorArun Raghavan <git@arunraghavan.net>
Mon, 4 Jan 2016 07:03:11 +0000 (12:33 +0530)
committerArun Raghavan <git@arunraghavan.net>
Fri, 12 Feb 2016 14:04:58 +0000 (19:34 +0530)
src/modules/macosx/module-coreaudio-device.c

index aa299a0..6c9e55d 100644 (file)
@@ -415,6 +415,11 @@ static int ca_device_create_sink(pa_module *m, AudioBuffer *buf, int channel_idx
     AudioObjectPropertyAddress property_address;
     CFStringRef tmp_cfstr = NULL;
 
+    if (buf->mNumberChannels > PA_CHANNELS_MAX) {
+        pa_log("Skipping device with more channels than we support (%u)", (unsigned int) buf->mNumberChannels);
+        return -1;
+    }
+
     ca_sink = pa_xnew0(coreaudio_sink, 1);
     ca_sink->map.channels = buf->mNumberChannels;
     ca_sink->ss.channels = buf->mNumberChannels;
@@ -543,6 +548,11 @@ static int ca_device_create_source(pa_module *m, AudioBuffer *buf, int channel_i
     AudioObjectPropertyAddress property_address;
     CFStringRef tmp_cfstr = NULL;
 
+    if (buf->mNumberChannels > PA_CHANNELS_MAX) {
+        pa_log("Skipping device with more channels than we support (%u)", (unsigned int) buf->mNumberChannels);
+        return -1;
+    }
+
     ca_source = pa_xnew0(coreaudio_source, 1);
     ca_source->map.channels = buf->mNumberChannels;
     ca_source->ss.channels = buf->mNumberChannels;