[135547] trunk/dports/audio/pulseaudio

ionic at macports.org ionic at macports.org
Sat Apr 25 17:20:52 PDT 2015


Revision: 135547
          https://trac.macports.org/changeset/135547
Author:   ionic at macports.org
Date:     2015-04-25 17:20:52 -0700 (Sat, 25 Apr 2015)
Log Message:
-----------
pulseaudio: add patches fixing crashes and startup issues on OS X. Revbump

Modified Paths:
--------------
    trunk/dports/audio/pulseaudio/Portfile
    trunk/dports/audio/pulseaudio/files/i386.patch
    trunk/dports/audio/pulseaudio/files/patch-man-Makefile.am.diff

Added Paths:
-----------
    trunk/dports/audio/pulseaudio/files/patch-configure.ac-add-HAVE_COREAUDIO.diff
    trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-load-module-coreaudio-detect.diff
    trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-skip-consolekit-and-systemdlogin.diff
    trunk/dports/audio/pulseaudio/files/patch-src_daemon_system.pa.in-load-module-coreaudio-detect.diff
    trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-channels.diff
    trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-device-names.diff
    trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-respect-PA_NAME_MAX.diff

Modified: trunk/dports/audio/pulseaudio/Portfile
===================================================================
--- trunk/dports/audio/pulseaudio/Portfile	2015-04-26 00:04:35 UTC (rev 135546)
+++ trunk/dports/audio/pulseaudio/Portfile	2015-04-26 00:20:52 UTC (rev 135547)
@@ -8,7 +8,7 @@
 
 name                pulseaudio
 version             6.0
-revision            1
+revision            2
 license             LGPL-2.1
 categories          audio
 maintainers         ionic openmaintainer
@@ -61,7 +61,20 @@
     }
 }
 
-patchfiles          patch-man-Makefile.am.diff i386.patch
+# The last three patches make PulseAudio startup correctly.
+# Will hopefully be merged upstream soon.
+# All work has been sent upstream.
+# C.f. https://bugs.freedesktop.org/show_bug.cgi?id=62987
+# and posts on the mailing list.
+patchfiles          patch-man-Makefile.am.diff \
+                    i386.patch \
+                    patch-configure.ac-add-HAVE_COREAUDIO.diff \
+                    patch-src_daemon_default.pa.in-load-module-coreaudio-detect.diff \
+                    patch-src_daemon_system.pa.in-load-module-coreaudio-detect.diff \
+                    patch-src_daemon_default.pa.in-skip-consolekit-and-systemdlogin.diff \
+                    patch-src_modules_macosx_module_coreaudio_device.c-fix-device-names.diff \
+                    patch-src_modules_macosx_module_coreaudio_device.c-fix-channels.diff \
+                    patch-src_modules_macosx_module_coreaudio_device.c-respect-PA_NAME_MAX.diff
 
 # reconfigure using upstream autogen.sh for intltool 0.51 compatibility
 

Modified: trunk/dports/audio/pulseaudio/files/i386.patch
===================================================================
--- trunk/dports/audio/pulseaudio/files/i386.patch	2015-04-26 00:04:35 UTC (rev 135546)
+++ trunk/dports/audio/pulseaudio/files/i386.patch	2015-04-26 00:20:52 UTC (rev 135547)
@@ -1,5 +1,5 @@
---- src/pulsecore/svolume_mmx.c.orig	2015-02-12 06:10:35.000000000 -0800
-+++ src/pulsecore/svolume_mmx.c	2015-04-25 12:49:12.000000000 -0700
+--- src/pulsecore/svolume_mmx.c.old	2015-04-17 00:47:29.000000000 +0200
++++ src/pulsecore/svolume_mmx.c	2015-04-17 00:53:16.000000000 +0200
 @@ -32,7 +32,7 @@
  
  #include "sample-util.h"
@@ -9,17 +9,27 @@
  /* in s: 2 int16_t samples
   * in v: 2 int32_t volumes, fixed point 16:16
   * out s: contains scaled and clamped int16_t samples.
-@@ -241,7 +241,7 @@
- #endif /* (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
+@@ -238,15 +238,15 @@ static void pa_volume_s16re_mmx(int16_t 
+     );
+ }
  
+-#endif /* (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
++#endif /* (!defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
+ 
  void pa_volume_func_init_mmx(pa_cpu_x86_flag_t flags) {
 -#if (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__)
 +#if (!defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__)
      if ((flags & PA_CPU_X86_MMX) && (flags & PA_CPU_X86_CMOV)) {
          pa_log_info("Initialising MMX optimized volume functions.");
  
---- src/pulsecore/svolume_sse.c.orig	2015-02-12 06:10:35.000000000 -0800
-+++ src/pulsecore/svolume_sse.c	2015-04-25 12:50:10.000000000 -0700
+         pa_set_volume_func(PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_mmx);
+         pa_set_volume_func(PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_mmx);
+     }
+-#endif /* (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
++#endif /* (!defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
+ }
+--- src/pulsecore/svolume_sse.c.old	2015-04-17 00:47:32.000000000 +0200
++++ src/pulsecore/svolume_sse.c	2015-04-17 00:54:13.000000000 +0200
 @@ -32,7 +32,7 @@
  
  #include "sample-util.h"
@@ -29,12 +39,22 @@
  
  #define VOLUME_32x16(s,v)                  /* .. |   vh  |   vl  | */                   \
        " pxor %%xmm4, %%xmm4          \n\t" /* .. |    0  |    0  | */                   \
-@@ -252,7 +252,7 @@
- #endif /* (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
+@@ -249,15 +249,15 @@ static void pa_volume_s16re_sse2(int16_t
+     );
+ }
  
+-#endif /* (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
++#endif /* (!defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
+ 
  void pa_volume_func_init_sse(pa_cpu_x86_flag_t flags) {
 -#if (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__)
 +#if (!defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__)
      if (flags & PA_CPU_X86_SSE2) {
          pa_log_info("Initialising SSE2 optimized volume functions.");
  
+         pa_set_volume_func(PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_sse2);
+         pa_set_volume_func(PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_sse2);
+     }
+-#endif /* (!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
++#endif /* (!defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && defined (__i386__)) || defined (__amd64__) */
+ }

Added: trunk/dports/audio/pulseaudio/files/patch-configure.ac-add-HAVE_COREAUDIO.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-configure.ac-add-HAVE_COREAUDIO.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-configure.ac-add-HAVE_COREAUDIO.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,14 @@
+--- configure.ac.orig	2014-02-15 03:33:32.000000000 -0500
++++ configure.ac	2014-11-23 22:05:59.000000000 -0500
+@@ -767,8 +794,11 @@
+ AS_IF([test "x$enable_coreaudio_output" = "xyes" && test "x$HAVE_COREAUDIO" = "x0"],
+     [AC_MSG_ERROR([*** CoreAudio output support not found])])
+ 
++AC_SUBST(HAVE_COREAUDIO)
+ AM_CONDITIONAL([HAVE_COREAUDIO], [test "x$HAVE_COREAUDIO" = "x1" && test "x$enable_coreaudio_output" != "xno"])
+ 
++AS_IF([test "x$HAVE_COREAUDIO" = "x1"], AC_DEFINE([HAVE_COREAUDIO], 1, [Have CoreAudio?]))
++
+ #### ALSA support (optional) ####
+ 
+ AC_ARG_ENABLE([alsa],

Modified: trunk/dports/audio/pulseaudio/files/patch-man-Makefile.am.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-man-Makefile.am.diff	2015-04-26 00:04:35 UTC (rev 135546)
+++ trunk/dports/audio/pulseaudio/files/patch-man-Makefile.am.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -1,6 +1,6 @@
---- man/Makefile.am.orig	2014-03-03 12:23:46.000000000 -0800
-+++ man/Makefile.am	2014-03-03 12:24:32.000000000 -0800
-@@ -63,7 +63,7 @@
+--- man/Makefile.am.old	2015-04-17 00:22:04.000000000 +0200
++++ man/Makefile.am	2015-04-17 00:23:14.000000000 +0200
+@@ -59,7 +59,7 @@
  	$(dist_man_MANS)
  
  %: %.xml Makefile

Added: trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-load-module-coreaudio-detect.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-load-module-coreaudio-detect.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-load-module-coreaudio-detect.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,13 @@
+--- src/daemon/default.pa.in.orig	2014-01-23 13:57:55.000000000 -0500
++++ src/daemon/default.pa.in	2014-11-23 22:03:02.000000000 -0500
+@@ -71,6 +71,10 @@
+ .ifexists module-udev-detect at PA_SOEXT@
+ load-module module-udev-detect
+ .else
++], @HAVE_COREAUDIO@, 1, [dnl
++.ifexists module-coreaudio-detect at PA_SOEXT@
++load-module module-coreaudio-detect
++.else
+ ], [dnl
+ .ifexists module-detect at PA_SOEXT@
+ ])dnl

Added: trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-skip-consolekit-and-systemdlogin.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-skip-consolekit-and-systemdlogin.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-src_daemon_default.pa.in-skip-consolekit-and-systemdlogin.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,17 @@
+--- src/daemon/default.pa.in.old	2015-04-20 06:24:03.000000000 +0200
++++ src/daemon/default.pa.in	2015-04-21 05:49:35.000000000 +0200
+@@ -153,12 +153,14 @@ load-module module-suspend-on-idle
+ 
+ ### If autoexit on idle is enabled we want to make sure we only quit
+ ### when no local session needs us anymore.
++ifelse(@HAVE_COREAUDIO@, 1, [], [dnl
+ .ifexists module-console-kit at PA_SOEXT@
+ load-module module-console-kit
+ .endif
+ .ifexists module-systemd-login at PA_SOEXT@
+ load-module module-systemd-login
+ .endif
++])dnl
+ 
+ ### Enable positioned event sounds
+ load-module module-position-event-sounds

Added: trunk/dports/audio/pulseaudio/files/patch-src_daemon_system.pa.in-load-module-coreaudio-detect.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-src_daemon_system.pa.in-load-module-coreaudio-detect.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-src_daemon_system.pa.in-load-module-coreaudio-detect.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,13 @@
+--- src/daemon/system.pa.in.orig	2014-01-23 13:57:55.000000000 -0500
++++ src/daemon/system.pa.in	2014-11-23 22:04:15.000000000 -0500
+@@ -29,6 +29,10 @@
+ .ifexists module-hal-detect at PA_SOEXT@
+ load-module module-hal-detect
+ .else
++], @HAVE_COREAUDIO@, 1, [dnl
++.ifexists module-coreaudio-detect at PA_SOEXT@
++load-module module-coreaudio-detect
++.else
+ ], [dnl
+ .ifexists module-detect at PA_SOEXT@
+ ])dnl

Added: trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-channels.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-channels.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-channels.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,86 @@
+--- src/modules/macosx/module-coreaudio-device.c.old	2015-04-19 07:45:52.000000000 +0200
++++ src/modules/macosx/module-coreaudio-device.c	2015-04-19 07:59:17.000000000 +0200
+@@ -415,21 +415,28 @@ static int ca_device_create_sink(pa_modu
+     pa_sink_flags_t flags = PA_SINK_LATENCY | PA_SINK_HARDWARE;
+     coreaudio_sink *ca_sink;
+     pa_sink *sink;
+-    unsigned int i;
++    unsigned int i, channels;
+     char tmp[255];
+     pa_strbuf *strbuf;
+     AudioObjectPropertyAddress property_address;
+     CFStringRef tmp_cfstr;
+ 
+     ca_sink = pa_xnew0(coreaudio_sink, 1);
+-    ca_sink->map.channels = buf->mNumberChannels;
+-    ca_sink->ss.channels = buf->mNumberChannels;
++
++    /* Clamp to PA_CHANNELS_MAX. */
++    channels = buf->mNumberChannels;
++    if (channels > PA_CHANNELS_MAX) {
++        channels = PA_CHANNELS_MAX;
++    }
++
++    ca_sink->map.channels = channels;
++    ca_sink->ss.channels = channels;
+     ca_sink->channel_idx = channel_idx;
+ 
+     /* build a name for this stream */
+     strbuf = pa_strbuf_new();
+ 
+-    for (i = 0; i < buf->mNumberChannels; i++) {
++    for (i = 0; i < channels; i++) {
+         property_address.mSelector = kAudioObjectPropertyElementName;
+         property_address.mScope = kAudioDevicePropertyScopeOutput;
+         property_address.mElement = channel_idx + i + 1;
+@@ -456,7 +463,7 @@ static int ca_device_create_sink(pa_modu
+     for (i = 0; i < ca_sink->map.channels; i++)
+         ca_sink->map.map[i] = PA_CHANNEL_POSITION_MONO;
+ 
+-    if (buf->mNumberChannels == 2) {
++    if (channels == 2) {
+         ca_sink->map.map[0] = PA_CHANNEL_POSITION_LEFT;
+         ca_sink->map.map[1] = PA_CHANNEL_POSITION_RIGHT;
+     }
+@@ -538,21 +545,28 @@ static int ca_device_create_source(pa_mo
+     pa_source_flags_t flags = PA_SOURCE_LATENCY | PA_SOURCE_HARDWARE;
+     coreaudio_source *ca_source;
+     pa_source *source;
+-    unsigned int i;
++    unsigned int i, channels;
+     char tmp[255];
+     pa_strbuf *strbuf;
+     AudioObjectPropertyAddress property_address;
+     CFStringRef tmp_cfstr;
+ 
+     ca_source = pa_xnew0(coreaudio_source, 1);
+-    ca_source->map.channels = buf->mNumberChannels;
+-    ca_source->ss.channels = buf->mNumberChannels;
++
++    /* Clamp to PA_CHANNELS_MAX. */
++    channels = buf->mNumberChannels;
++    if (channels > PA_CHANNELS_MAX) {
++        channels = PA_CHANNELS_MAX;
++    }
++
++    ca_source->map.channels = channels;
++    ca_source->ss.channels = channels;
+     ca_source->channel_idx = channel_idx;
+ 
+     /* build a name for this stream */
+     strbuf = pa_strbuf_new();
+ 
+-    for (i = 0; i < buf->mNumberChannels; i++) {
++    for (i = 0; i < channels; i++) {
+         property_address.mSelector = kAudioObjectPropertyElementName;
+         property_address.mScope = kAudioDevicePropertyScopeInput;
+         property_address.mElement = channel_idx + i + 1;
+@@ -579,7 +593,7 @@ static int ca_device_create_source(pa_mo
+     for (i = 0; i < ca_source->map.channels; i++)
+         ca_source->map.map[i] = PA_CHANNEL_POSITION_MONO;
+ 
+-    if (buf->mNumberChannels == 2) {
++    if (channels == 2) {
+         ca_source->map.map[0] = PA_CHANNEL_POSITION_LEFT;
+         ca_source->map.map[1] = PA_CHANNEL_POSITION_RIGHT;
+     }

Added: trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-device-names.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-device-names.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-fix-device-names.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,84 @@
+--- src/modules/macosx/module-coreaudio-device.c.old	2015-04-19 07:39:23.000000000 +0200
++++ src/modules/macosx/module-coreaudio-device.c	2015-04-19 07:40:13.000000000 +0200
+@@ -374,6 +374,39 @@ static int ca_sink_set_state(pa_sink *s,
+     return 0;
+ }
+ 
++/* Caveat: this function frees the CFString if conversion succeeded. */
++static int CFString_to_cstr_n(CFStringRef cfstr, char *buf, long n) {
++    int ret;
++
++    assert (buf);
++
++    ret = 0;
++
++    if (cfstr != NULL) {
++        const char *tmp = CFStringGetCStringPtr(cfstr, kCFStringEncodingUTF8);
++
++        if (tmp == NULL) {
++            if (CFStringGetCString(cfstr, buf, n, kCFStringEncodingUTF8))
++                ret = 1;
++        }
++        else {
++            strncpy(buf, tmp, n);
++            buf[n - 1] = 0;
++            ret = 1;
++        }
++    }
++
++    /*
++     * A true value for ret implies cfstr != NULL, but let's still do the check
++     * for safety reasons (i.e., should this code ever be re-organized...)
++     */
++    if (ret && cfstr != NULL) {
++        CFRelease(cfstr);
++    }
++
++    return ret;
++}
++
+ static int ca_device_create_sink(pa_module *m, AudioBuffer *buf, int channel_idx) {
+     OSStatus err;
+     UInt32 size;
+@@ -386,6 +419,7 @@ static int ca_device_create_sink(pa_modu
+     char tmp[255];
+     pa_strbuf *strbuf;
+     AudioObjectPropertyAddress property_address;
++    CFStringRef tmp_cfstr;
+ 
+     ca_sink = pa_xnew0(coreaudio_sink, 1);
+     ca_sink->map.channels = buf->mNumberChannels;
+@@ -400,7 +434,11 @@ static int ca_device_create_sink(pa_modu
+         property_address.mScope = kAudioDevicePropertyScopeOutput;
+         property_address.mElement = channel_idx + i + 1;
+         size = sizeof(tmp);
+-        err = AudioObjectGetPropertyData(u->object_id, &property_address, 0, NULL, &size, tmp);
++        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)));
++        }
++
+         if (err || !strlen(tmp))
+             snprintf(tmp, sizeof(tmp), "Channel %d", (int) property_address.mElement);
+ 
+@@ -504,6 +542,7 @@ static int ca_device_create_source(pa_mo
+     char tmp[255];
+     pa_strbuf *strbuf;
+     AudioObjectPropertyAddress property_address;
++    CFStringRef tmp_cfstr;
+ 
+     ca_source = pa_xnew0(coreaudio_source, 1);
+     ca_source->map.channels = buf->mNumberChannels;
+@@ -518,7 +557,11 @@ static int ca_device_create_source(pa_mo
+         property_address.mScope = kAudioDevicePropertyScopeInput;
+         property_address.mElement = channel_idx + i + 1;
+         size = sizeof(tmp);
+-        err = AudioObjectGetPropertyData(u->object_id, &property_address, 0, NULL, &size, tmp);
++        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)));
++        }
++
+         if (err || !strlen(tmp))
+             snprintf(tmp, sizeof(tmp), "Channel %d", (int) property_address.mElement);
+ 

Added: trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-respect-PA_NAME_MAX.diff
===================================================================
--- trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-respect-PA_NAME_MAX.diff	                        (rev 0)
+++ trunk/dports/audio/pulseaudio/files/patch-src_modules_macosx_module_coreaudio_device.c-respect-PA_NAME_MAX.diff	2015-04-26 00:20:52 UTC (rev 135547)
@@ -0,0 +1,60 @@
+--- src/modules/macosx/module-coreaudio-device.c.old	2015-04-20 01:41:14.000000000 +0200
++++ src/modules/macosx/module-coreaudio-device.c	2015-04-20 01:43:58.000000000 +0200
+@@ -43,6 +43,7 @@
+ #include <pulsecore/thread.h>
+ #include <pulsecore/thread-mq.h>
+ #include <pulsecore/i18n.h>
++#include <pulsecore/namereg.h>
+ 
+ #include <CoreAudio/CoreAudio.h>
+ #include <CoreAudio/CoreAudioTypes.h>
+@@ -416,7 +417,7 @@ static int ca_device_create_sink(pa_modu
+     coreaudio_sink *ca_sink;
+     pa_sink *sink;
+     unsigned int i, channels;
+-    char tmp[255];
++    char tmp[255], *tmp_clamp;
+     pa_strbuf *strbuf;
+     AudioObjectPropertyAddress property_address;
+     CFStringRef tmp_cfstr;
+@@ -455,7 +456,14 @@ static int ca_device_create_sink(pa_modu
+         pa_strbuf_puts(strbuf, tmp);
+     }
+ 
+-    ca_sink->name = pa_strbuf_tostring_free(strbuf);
++    /* Clamp to PA_NAME_MAX and leave a "safety margin" for deduplication
++     * and other appended data. */
++    tmp_clamp = pa_strbuf_tostring_free(strbuf);
++    strncpy(tmp, tmp_clamp, PA_NAME_MAX - 20);
++    tmp[PA_NAME_MAX - 20] = 0;
++    pa_xfree(tmp_clamp);
++
++    ca_sink->name = pa_xstrndup(tmp, PA_NAME_MAX);
+ 
+     pa_log_debug("Stream name is >%s<", ca_sink->name);
+ 
+@@ -546,7 +554,7 @@ static int ca_device_create_source(pa_mo
+     coreaudio_source *ca_source;
+     pa_source *source;
+     unsigned int i, channels;
+-    char tmp[255];
++    char tmp[255], *tmp_clamp;
+     pa_strbuf *strbuf;
+     AudioObjectPropertyAddress property_address;
+     CFStringRef tmp_cfstr;
+@@ -585,7 +593,14 @@ static int ca_device_create_source(pa_mo
+         pa_strbuf_puts(strbuf, tmp);
+     }
+ 
+-    ca_source->name = pa_strbuf_tostring_free(strbuf);
++    /* Clamp to PA_NAME_MAX and leave a "safety margin" for deduplication
++     * and other appended data. */
++    tmp_clamp = pa_strbuf_tostring_free(strbuf);
++    strncpy(tmp, tmp_clamp, PA_NAME_MAX - 20);
++    tmp[PA_NAME_MAX - 20] = 0;
++    pa_xfree(tmp_clamp);
++
++    ca_source->name = pa_xstrndup(tmp, PA_NAME_MAX);
+ 
+     pa_log_debug("Stream name is >%s<", ca_source->name);
+ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150425/bedcdbf3/attachment-0001.html>


More information about the macports-changes mailing list