diff options
| author | Colin Guthrie <cguthrie@mandriva.org> | 2011-03-24 09:08:05 +0000 | 
|---|---|---|
| committer | Colin Guthrie <cguthrie@mandriva.org> | 2011-03-24 09:08:05 +0000 | 
| commit | ae35ec1ed5f76aab6a0a60a27adf1d6b92323e70 (patch) | |
| tree | dce87fc98f6429a679cec0353be3d94f0455c88e | |
| parent | 11da057d81a1a5d28134d1cc8cc2c6469524561d (diff) | |
| parent | fc339a608e0a295312a1887b6cfb78883f7c556c (diff) | |
Merge remote-tracking branch 'zonique/osx'
| -rw-r--r-- | configure.ac | 13 | ||||
| -rw-r--r-- | src/Makefile.am | 10 | ||||
| -rw-r--r-- | src/modules/macosx/module-bonjour-publish.c (renamed from src/modules/module-bonjour-publish.c) | 0 | ||||
| -rw-r--r-- | src/modules/macosx/module-coreaudio-detect.c (renamed from src/modules/coreaudio/module-coreaudio-detect.c) | 4 | ||||
| -rw-r--r-- | src/modules/macosx/module-coreaudio-device.c (renamed from src/modules/coreaudio/module-coreaudio-device.c) | 0 | ||||
| -rw-r--r-- | src/pulsecore/core-util.c | 38 | 
6 files changed, 60 insertions, 5 deletions
| diff --git a/configure.ac b/configure.ac index 99e50b08..07208f25 100644 --- a/configure.ac +++ b/configure.ac @@ -169,6 +169,11 @@ AC_ARG_ENABLE([atomic-arm-memory-barrier],              esac          ],) +AC_ARG_ENABLE(mac-universal, +    AS_HELP_STRING([--enable-mac-universal], [Build Mac universal binaries]), +		enable_mac_universal=$enableval, enable_mac_universal="no") + +  AC_MSG_CHECKING([target operating system])  case $host in          *-*-linux*) @@ -178,6 +183,14 @@ case $host in          *-*-darwin*)              AC_MSG_RESULT([darwin])              pulse_target_os=darwin + +            if test "x$enable_mac_universal" = "xyes" ; then +	        mac_version_min="-mmacosx-version-min=10.5" +                mac_arches="-arch i386 -arch x86_64" +                mac_sysroot="-isysroot /Developer/SDKs/MacOSX10.5.sdk" +                LDFLAGS="$LDFLAGS $mac_arches $mac_sysroot $mac_version_min" +                CFLAGS="$CFLAGS $CFLAGS $mac_arches $mac_sysroot $mac_version_min" +            fi          ;;          *)              AC_MSG_RESULT([unknown]) diff --git a/src/Makefile.am b/src/Makefile.am index bc2db918..f3717cec 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -80,6 +80,10 @@ AM_LDFLAGS+=-Wl,--export-all-symbols,--enable-auto-import -no-undefined  WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet  endif +if OS_IS_DARWIN +AM_LDFLAGS+=-headerpad_max_install_names +endif +  FOREIGN_CFLAGS = -w  MODULE_LDFLAGS = $(AM_LDFLAGS) -module -disable-static -avoid-version $(LDFLAGS_NOUNDEFINED)  MODULE_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la @@ -1542,13 +1546,13 @@ module_oss_la_LIBADD = $(MODULE_LIBADD) liboss-util.la  # COREAUDIO -module_coreaudio_detect_la_SOURCES = modules/coreaudio/module-coreaudio-detect.c +module_coreaudio_detect_la_SOURCES = modules/macosx/module-coreaudio-detect.c  module_coreaudio_detect_la_LDFLAGS = $(MODULE_LDFLAGS) \  		-Wl,-framework -Wl,Cocoa -framework CoreAudio \  		-Wl,-framework -Wl,AudioUnit -framework AudioUnit  module_coreaudio_detect_la_LIBADD = $(MODULE_LIBADD) -module_coreaudio_device_la_SOURCES = modules/coreaudio/module-coreaudio-device.c +module_coreaudio_device_la_SOURCES = modules/macosx/module-coreaudio-device.c  module_coreaudio_device_la_LDFLAGS = $(MODULE_LDFLAGS) \  		-Wl,-framework -Wl,Cocoa -framework CoreAudio \  		-Wl,-framework -Wl,AudioUnit -framework AudioUnit @@ -1619,7 +1623,7 @@ module_zeroconf_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)  # Bonjour -module_bonjour_publish_la_SOURCES = modules/module-bonjour-publish.c +module_bonjour_publish_la_SOURCES = modules/macosx/module-bonjour-publish.c  module_bonjour_publish_la_LDFLAGS = $(MODULE_LDFLAGS) \  			-Wl,-framework -Wl,CoreFoundation -framework CoreFoundation  module_bonjour_publish_la_LIBADD = $(MODULE_LIBADD) diff --git a/src/modules/module-bonjour-publish.c b/src/modules/macosx/module-bonjour-publish.c index 095a1d29..095a1d29 100644 --- a/src/modules/module-bonjour-publish.c +++ b/src/modules/macosx/module-bonjour-publish.c diff --git a/src/modules/coreaudio/module-coreaudio-detect.c b/src/modules/macosx/module-coreaudio-detect.c index 1d26b84e..263fc72d 100644 --- a/src/modules/coreaudio/module-coreaudio-detect.c +++ b/src/modules/macosx/module-coreaudio-detect.c @@ -232,12 +232,14 @@ fail:  void pa__done(pa_module *m) {      struct userdata *u; -    struct ca_device *dev = u->devices; +    struct ca_device *dev;      AudioObjectPropertyAddress property_address;      pa_assert(m);      pa_assert_se(u = m->userdata); +    dev = u->devices; +      property_address.mSelector = kAudioHardwarePropertyDevices;      property_address.mScope = kAudioObjectPropertyScopeGlobal;      property_address.mElement = kAudioObjectPropertyElementMaster; diff --git a/src/modules/coreaudio/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c index cc4600b5..cc4600b5 100644 --- a/src/modules/coreaudio/module-coreaudio-device.c +++ b/src/modules/macosx/module-coreaudio-device.c diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 3eb12428..796ff57c 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -107,6 +107,10 @@  #ifdef __APPLE__  #include <xlocale.h> +#include <mach/mach_init.h> +#include <mach/thread_act.h> +#include <mach/thread_policy.h> +#include <sys/sysctl.h>  #endif  #ifdef HAVE_DBUS @@ -691,7 +695,39 @@ static int set_scheduler(int rtprio) {   * the thread is already realtime, don't do anything. */  int pa_make_realtime(int rtprio) { -#ifdef _POSIX_PRIORITY_SCHEDULING +#if defined(OS_IS_DARWIN) +    struct thread_time_constraint_policy ttcpolicy; +    uint64_t freq = 0; +    size_t size = sizeof(freq); +    int ret; + +    ret = sysctlbyname("hw.cpufrequency", &freq, &size, NULL, 0); +    if (ret < 0) { +        pa_log_info("Unable to read CPU frequency, acquisition of real-time scheduling failed."); +        return -1; +    } + +    pa_log_debug("sysctl for hw.cpufrequency: %llu", freq); + +    /* See http://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html */ +    ttcpolicy.period = freq / 160; +    ttcpolicy.computation = freq / 3300; +    ttcpolicy.constraint = freq / 2200; +    ttcpolicy.preemptible = 1; + +    ret = thread_policy_set(mach_thread_self(), +                            THREAD_TIME_CONSTRAINT_POLICY, +                            (thread_policy_t) &ttcpolicy, +                            THREAD_TIME_CONSTRAINT_POLICY_COUNT); +    if (ret) { +        pa_log_info("Unable to set real-time thread priority (%08x).", ret); +        return -1; +    } + +    pa_log_info("Successfully acquired real-time thread priority."); +    return 0; + +#elif _POSIX_PRIORITY_SCHEDULING      int p;      if (set_scheduler(rtprio) >= 0) { | 
