[pulseaudio-commits] 3 commits - configure.ac src/modules

Arun Raghavan arun at kemper.freedesktop.org
Fri Feb 12 14:10:58 UTC 2016


 configure.ac                                 |   11 +++-
 src/modules/macosx/module-coreaudio-device.c |   68 ++++++++++++++++-----------
 2 files changed, 49 insertions(+), 30 deletions(-)

New commits:
commit 3977a906e21fe215051c0a82cf951cc12080fbb1
Author: Arun Raghavan <git at arunraghavan.net>
Date:   Mon Jan 4 12:33:11 2016 +0530

    coreaudio: Catch devices with more channels than we support

diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
index aa299a0..6c9e55d 100644
--- a/src/modules/macosx/module-coreaudio-device.c
+++ b/src/modules/macosx/module-coreaudio-device.c
@@ -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;

commit cf503f956071895b6e1d467afdc1e10382d60c87
Author: Arun Raghavan <git at arunraghavan.net>
Date:   Mon Jan 4 12:16:01 2016 +0530

    coreaudio: Dynamically allocate C string when converting from CFString

diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
index 0c92d42..aa299a0 100644
--- a/src/modules/macosx/module-coreaudio-device.c
+++ b/src/modules/macosx/module-coreaudio-device.c
@@ -376,23 +376,25 @@ static int ca_sink_set_state(pa_sink *s, pa_sink_state_t state) {
 }
 
 /* Caveat: The caller is responsible to get rid of the CFString(Ref). */
-static bool CFString_to_cstr_n(CFStringRef cfstr, char *buf, long n) {
-    bool ret;
-
-    pa_assert (buf);
+static char * CFString_to_cstr(CFStringRef cfstr) {
+    char *ret = NULL;
 
     ret = false;
 
     if (cfstr != NULL) {
         const char *tmp = CFStringGetCStringPtr(cfstr, kCFStringEncodingUTF8);
+        CFIndex n = CFStringGetLength(cfstr) + 1 /* for the terminating NULL */;
+
+        ret = pa_xmalloc(n);
 
         if (tmp == NULL) {
-            if (CFStringGetCString(cfstr, buf, n, kCFStringEncodingUTF8))
-                ret = true;
+            if (!CFStringGetCString(cfstr, ret, n, kCFStringEncodingUTF8)) {
+                pa_xfree(ret);
+                ret = NULL;
+            }
         } else {
-            strncpy(buf, tmp, n);
-            buf[n - 1] = 0;
-            ret = true;
+            strncpy(ret, tmp, n - 1);
+            ret[n - 1] = '\0';
         }
     }
 
@@ -408,7 +410,7 @@ static int ca_device_create_sink(pa_module *m, AudioBuffer *buf, int channel_idx
     coreaudio_sink *ca_sink;
     pa_sink *sink;
     unsigned int i;
-    char tmp[255];
+    char *tmp;
     pa_strbuf *strbuf;
     AudioObjectPropertyAddress property_address;
     CFStringRef tmp_cfstr = NULL;
@@ -425,23 +427,24 @@ static int ca_device_create_sink(pa_module *m, AudioBuffer *buf, int channel_idx
         property_address.mSelector = kAudioObjectPropertyElementName;
         property_address.mScope = kAudioDevicePropertyScopeOutput;
         property_address.mElement = channel_idx + i + 1;
-        size = sizeof(tmp);
+        size = sizeof(tmp_cfstr);
         err = AudioObjectGetPropertyData(u->object_id, &property_address, 0, NULL, &size, &tmp_cfstr);
         if (err == 0) {
-            err = !(CFString_to_cstr_n(tmp_cfstr, tmp, sizeof(tmp)));
+            tmp = CFString_to_cstr(tmp_cfstr);
 
-            if (tmp_cfstr) {
+            if (tmp_cfstr)
                 CFRelease(tmp_cfstr);
-            }
         }
 
-        if (err || !strlen(tmp))
-            snprintf(tmp, sizeof(tmp), "Channel %d", (int) property_address.mElement);
-
         if (i > 0)
             pa_strbuf_puts(strbuf, ", ");
 
-        pa_strbuf_puts(strbuf, tmp);
+        if (err || !tmp || !strlen(tmp))
+            pa_strbuf_printf(strbuf, "Channel %d", (int) property_address.mElement);
+        else
+            pa_strbuf_puts(strbuf, tmp);
+
+        pa_xfree(tmp);
     }
 
     ca_sink->name = pa_strbuf_to_string_free(strbuf);
@@ -535,7 +538,7 @@ static int ca_device_create_source(pa_module *m, AudioBuffer *buf, int channel_i
     coreaudio_source *ca_source;
     pa_source *source;
     unsigned int i;
-    char tmp[255];
+    char *tmp;
     pa_strbuf *strbuf;
     AudioObjectPropertyAddress property_address;
     CFStringRef tmp_cfstr = NULL;
@@ -552,23 +555,24 @@ static int ca_device_create_source(pa_module *m, AudioBuffer *buf, int channel_i
         property_address.mSelector = kAudioObjectPropertyElementName;
         property_address.mScope = kAudioDevicePropertyScopeInput;
         property_address.mElement = channel_idx + i + 1;
-        size = sizeof(tmp);
+        size = sizeof(tmp_cfstr);
         err = AudioObjectGetPropertyData(u->object_id, &property_address, 0, NULL, &size, &tmp_cfstr);
         if (err == 0) {
-            err = !(CFString_to_cstr_n(tmp_cfstr, tmp, sizeof(tmp)));
+            tmp = CFString_to_cstr(tmp_cfstr);
 
-            if (tmp_cfstr) {
+            if (tmp_cfstr)
                 CFRelease(tmp_cfstr);
-            }
         }
 
-        if (err || !strlen(tmp))
-            snprintf(tmp, sizeof(tmp), "Channel %d", (int) property_address.mElement);
-
         if (i > 0)
             pa_strbuf_puts(strbuf, ", ");
 
-        pa_strbuf_puts(strbuf, tmp);
+        if (err || !tmp || !strlen(tmp))
+            pa_strbuf_printf(strbuf, "Channel %d", (int) property_address.mElement);
+        else
+            pa_strbuf_puts(strbuf, tmp);
+
+        pa_xfree(tmp);
     }
 
     ca_source->name = pa_strbuf_to_string_free(strbuf);

commit 3314dc72eaef16a5dc909387b2bb21bbcc4efdc2
Author: Arun Raghavan <git at arunraghavan.net>
Date:   Mon Jan 4 11:17:29 2016 +0530

    build-sys: Only use sysroot in OS X CFLAGS if specified
    
    The default value doesn't make sense any more, so we'll only use this if
    explicitly specified.

diff --git a/configure.ac b/configure.ac
index dcd0110..99c425d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1375,11 +1375,16 @@ AC_ARG_WITH(mac-version-min,
 
 AC_ARG_WITH(mac-sysroot,
     AS_HELP_STRING([--with-mac-sysroot=<path>], [SDK basedir to use as the logical root directory for headers and libraries.]),
-    mac_sysroot=$withval, mac_sysroot="/Developer/SDKs/MacOSX10.5.sdk")
+    mac_sysroot=$withval)
 
 if test "x$os_is_darwin" = "x1" ; then
-    LDFLAGS="$LDFLAGS -isysroot $mac_sysroot -mmacosx-version-min=$mac_version_min"
-    CFLAGS="$CFLAGS -isysroot $mac_sysroot -mmacosx-version-min=$mac_version_min"
+    LDFLAGS="$LDFLAGS -mmacosx-version-min=$mac_version_min"
+    CFLAGS="$CFLAGS -mmacosx-version-min=$mac_version_min"
+
+    if test "x$mac_sysroot" != "x" ; then
+        LDFLAGS="$LDFLAGS -isysroot $mac_sysroot"
+        CFLAGS="$CFLAGS -isysroot $mac_sysroot"
+    fi
 
     if test "x$enable_mac_universal" = "xyes" ; then
         mac_arches="-arch i386 -arch x86_64"



More information about the pulseaudio-commits mailing list