]> code.delx.au - pulseaudio/commitdiff
Merge remote-tracking branch 'zonique/osx'
authorColin Guthrie <cguthrie@mandriva.org>
Thu, 24 Mar 2011 09:08:05 +0000 (09:08 +0000)
committerColin Guthrie <cguthrie@mandriva.org>
Thu, 24 Mar 2011 09:08:05 +0000 (09:08 +0000)
1  2 
configure.ac
src/Makefile.am
src/pulsecore/core-util.c

diff --combined configure.ac
index 99e50b080ecb0fb367d75dec3155e05a118e02ea,78b37c4cac7b25aa8bd68c109eafe5ecc66ecdea..07208f25cb273e4e4a95dc917ae10b2567ee4128
@@@ -169,6 -169,11 +169,11 @@@ AC_ARG_ENABLE([atomic-arm-memory-barrie
              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*)
          *-*-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])
@@@ -475,7 -488,7 +488,7 @@@ AC_FUNC_FOR
  AC_FUNC_GETGROUPS
  AC_FUNC_SELECT_ARGTYPES
  AC_CHECK_FUNCS_ONCE([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
 -    getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
 +    getpwnam_r getpwuid_r gettimeofday getuid mlock nanosleep \
      pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
      sigaction sleep symlink sysconf uname pthread_setaffinity_np])
  AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
diff --combined src/Makefile.am
index bc2db91892ad80d81859444c5f8b6465e4667e73,dc49bc19af89b16366e36af9087da42f6c4348bf..f3717cec15722c67c9e77b661972e92fd3af5a0d
@@@ -27,23 -27,21 +27,23 @@@ pulseincludedir=$(includedir)/puls
  pulsecoreincludedir=$(includedir)/pulsecore
  pulseconfdir=$(sysconfdir)/pulse
  pulselibexecdir=$(libexecdir)/pulse
 +if HAVE_X11
  xdgautostartdir=$(sysconfdir)/xdg/autostart
 +endif
 +if HAVE_ALSA
  alsaprofilesetsdir=$(datadir)/pulseaudio/alsa-mixer/profile-sets
  alsapathsdir=$(datadir)/pulseaudio/alsa-mixer/paths
 +endif
 +if HAVE_DBUS
  dbuspolicydir=$(sysconfdir)/dbus-1/system.d
 +endif
  
  ###################################
  #            Defines              #
  ###################################
  
  PA_BINARY=$(bindir)/pulseaudio$(EXEEXT)
 -if OS_IS_WIN32
 -PA_DEFAULT_CONFIG_DIR=%PULSE_ROOT%
 -else
  PA_DEFAULT_CONFIG_DIR=$(pulseconfdir)
 -endif
  
  ###################################
  #     Compiler/linker flags       #
@@@ -80,6 -78,10 +80,10 @@@ AM_LDFLAGS+=-Wl,--export-all-symbols,--
  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
@@@ -123,9 -125,9 +127,9 @@@ if HAVE_X1
  xdgautostart_in_files = \
                daemon/pulseaudio.desktop.in \
                daemon/pulseaudio-kde.desktop.in
 -endif
  xdgautostart_DATA = $(xdgautostart_in_files:.desktop.in=.desktop)
  @INTLTOOL_DESKTOP_RULE@
 +endif
  
  
  ###################################
@@@ -590,7 -592,8 +594,7 @@@ libpulsecommon_@PA_MAJORMINOR@_la_SOURC
                pulsecore/flist.c pulsecore/flist.h \
                pulsecore/hashmap.c pulsecore/hashmap.h \
                pulsecore/idxset.c pulsecore/idxset.h \
 -              pulsecore/inet_ntop.c pulsecore/inet_ntop.h \
 -              pulsecore/inet_pton.c pulsecore/inet_pton.h \
 +              pulsecore/arpa-inet.c pulsecore/arpa-inet.h \
                pulsecore/iochannel.c pulsecore/iochannel.h \
                pulsecore/ioline.c pulsecore/ioline.h \
                pulsecore/ipacl.h pulsecore/ipacl.c \
@@@ -1542,13 -1545,13 +1546,13 @@@ module_oss_la_LIBADD = $(MODULE_LIBADD
  
  # 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 -1622,7 +1623,7 @@@ module_zeroconf_discover_la_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)
@@@ -1921,28 -1924,21 +1925,28 @@@ daemon.conf: daemon/daemon.conf.in Make
        $(AM_V_GEN) sed -e 's,@PA_DLSEARCHPATH\@,$(modlibexecdir),g' \
                -e 's,@PA_DEFAULT_CONFIG_FILE\@,$(DEFAULT_CONFIG_DIR),g' < $< > $@
  
 +if OS_IS_WIN32
 +SYMLINK_PROGRAM=cd $(DESTDIR)$(bindir) && cp
 +else
 +SYMLINK_PROGRAM=ln -sf
 +endif
  install-exec-hook:
 +if HAVE_BLUEZ
        -chown root $(DESTDIR)$(pulselibexecdir)/proximity-helper
        -chmod u+s $(DESTDIR)$(pulselibexecdir)/proximity-helper
 -      ln -sf pacat $(DESTDIR)$(bindir)/parec
 -      ln -sf pacat $(DESTDIR)$(bindir)/pamon
 -      ln -sf pacat $(DESTDIR)$(bindir)/paplay
 -      ln -sf pacat $(DESTDIR)$(bindir)/parecord
 +endif
 +      $(SYMLINK_PROGRAM) pacat$(EXEEXT) $(DESTDIR)$(bindir)/parec$(EXEEXT)
 +      $(SYMLINK_PROGRAM) pacat$(EXEEXT) $(DESTDIR)$(bindir)/pamon$(EXEEXT)
 +      $(SYMLINK_PROGRAM) pacat$(EXEEXT) $(DESTDIR)$(bindir)/paplay$(EXEEXT)
 +      $(SYMLINK_PROGRAM) pacat$(EXEEXT) $(DESTDIR)$(bindir)/parecord$(EXEEXT)
        rm -f $(DESTDIR)$(libdir)/libpulsedsp.la
        rm -f $(DESTDIR)$(modlibexecdir)/*.la
  
  uninstall-hook:
 -      rm -f $(DESTDIR)$(bindir)/parec
 -      rm -f $(DESTDIR)$(bindir)/pamon
 -      rm -f $(DESTDIR)$(bindir)/paplay
 -      rm -f $(DESTDIR)$(bindir)/parecord
 +      rm -f $(DESTDIR)$(bindir)/parec$(EXEEXT)
 +      rm -f $(DESTDIR)$(bindir)/pamon$(EXEEXT)
 +      rm -f $(DESTDIR)$(bindir)/paplay$(EXEEXT)
 +      rm -f $(DESTDIR)$(bindir)/parecord$(EXEEXT)
        rm -f $(DESTDIR)$(libdir)/libpulsedsp.*
        rm -f $(DESTDIR)$(modlibexecdir)/*.so
  
@@@ -1956,21 -1952,21 +1960,21 @@@ update-ffmpeg
  update-sbc:
        for i in $(BLUETOOTH_SBC_FILES) ; do \
                wget -O /dev/null http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=$$i ; \
 -              wget -O modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=$$i ; \
 +              wget -O $(top_srcdir)/src/modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=$$i ; \
        done
        for i in $(BLUETOOTH_IPC_FILES); do \
                wget -O /dev/null http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=audio/$$i ; \
 -              wget -O modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=audio/$$i ; \
 +              wget -O $(top_srcdir)/src/modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=audio/$$i ; \
        done
  
  update-reserve:
        for i in reserve.c reserve.h reserve-monitor.c reserve-monitor.h ; do \
 -              wget -O modules/$$i http://git.0pointer.de/\?p=reserve.git\;a=blob_plain\;f=$$i\;hb=master ; \
 +              wget -O $(top_srcdir)/src/modules/$$i http://git.0pointer.de/\?p=reserve.git\;a=blob_plain\;f=$$i\;hb=master ; \
        done
  
  update-rtkit:
        for i in rtkit.c rtkit.h ; do \
 -              wget -O pulsecore/$$i http://git.0pointer.de/\?p=rtkit.git\;a=blob_plain\;f=$$i\;hb=master ; \
 +              wget -O $(top_srcdir)/src/pulsecore/$$i http://git.0pointer.de/\?p=rtkit.git\;a=blob_plain\;f=$$i\;hb=master ; \
        done
  
  # Automatically generate linker version script. We use the same one for all public .sos
index 3eb12428fa7ba00cd989e9f3f12a0f6415b6d947,7d239186cdd791caef1a37944d218bcac735e787..796ff57c28905de5e484c3a95fd4b6ad756b22cd
  
  #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
@@@ -146,29 -150,24 +150,29 @@@ static pa_strlist *recorded_env = NULL
  
  #ifdef OS_IS_WIN32
  
 -#define PULSE_ROOTENV "PULSE_ROOT"
 +/* Returns the directory of the current DLL, with '/bin/' removed if it is the last component */
 +char *pa_win32_get_toplevel(HANDLE handle) {
 +    static char *toplevel = NULL;
  
 -int pa_set_root(HANDLE handle) {
 -    char library_path[MAX_PATH], *sep;
 +    if (!toplevel) {
 +        char library_path[MAX_PATH];
 +        char *p;
  
 -    /* FIXME: Needs to set errno */
 +        if (!GetModuleFileName(handle, library_path, MAX_PATH))
 +            return NULL;
  
 -    if (!GetModuleFileName(handle, library_path, MAX_PATH))
 -        return 0;
 +        toplevel = pa_xstrdup(library_path);
  
 -    sep = strrchr(library_path, PA_PATH_SEP_CHAR);
 -    if (sep)
 -        *sep = '\0';
 +        p = strrchr(toplevel, PA_PATH_SEP_CHAR);
 +        if (p)
 +            *p = '\0';
  
 -    if (!SetEnvironmentVariable(PULSE_ROOTENV, library_path))
 -        return 0;
 +        p = strrchr(toplevel, PA_PATH_SEP_CHAR);
 +        if (p && (strcmp(p + 1, "bin") == 0))
 +            *p = '\0';
 +    }
  
 -    return 1;
 +    return toplevel;
  }
  
  #endif
@@@ -259,12 -258,11 +263,12 @@@ int pa_make_secure_dir(const char* dir
      }
  
  #ifdef HAVE_FCHOWN
 -    if (uid == (uid_t)-1)
 +    if (uid == (uid_t) -1)
          uid = getuid();
 -    if (gid == (gid_t)-1)
 +    if (gid == (gid_t) -1)
          gid = getgid();
 -    (void) fchown(fd, uid, gid);
 +    if (fchown(fd, uid, gid) < 0)
 +        goto fail;
  #endif
  
  #ifdef HAVE_FCHMOD
@@@ -691,7 -689,39 +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) {
  #elif defined(OS_IS_WIN32)
      /* Windows only allows realtime scheduling to be set on a per process basis.
       * Therefore, instead of making the thread realtime, just give it the highest non-realtime priority. */
 -    if(SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) {
 +    if (SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) {
          pa_log_info("Successfully enabled THREAD_PRIORITY_TIME_CRITICAL scheduling for thread.");
          return 0;
      }
@@@ -938,7 -968,7 +974,7 @@@ const char *pa_sig2str(int sig) 
      }
  #else
  
 -    switch(sig) {
 +    switch (sig) {
  #ifdef SIGHUP
          case SIGHUP:    return "SIGHUP";
  #endif
@@@ -1225,11 -1255,11 +1261,11 @@@ int pa_lock_fd(int fd, int b) 
              return 0;
      }
  
 -    pa_log("%slock: %s", !b? "un" : "", pa_cstrerror(errno));
 +    pa_log("%slock: %s", !b ? "un" : "", pa_cstrerror(errno));
  #endif
  
  #ifdef OS_IS_WIN32
 -    HANDLE h = (HANDLE)_get_osfhandle(fd);
 +    HANDLE h = (HANDLE) _get_osfhandle(fd);
  
      if (b && LockFile(h, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF))
          return 0;
@@@ -1682,9 -1712,23 +1718,9 @@@ fail
   * stored there.*/
  FILE *pa_open_config_file(const char *global, const char *local, const char *env, char **result) {
      const char *fn;
 -#ifdef OS_IS_WIN32
 -    char buf[PATH_MAX];
 -
 -    if (!getenv(PULSE_ROOTENV))
 -        pa_set_root(NULL);
 -#endif
 +    FILE *f;
  
      if (env && (fn = getenv(env))) {
 -        FILE *f;
 -
 -#ifdef OS_IS_WIN32
 -        if (!ExpandEnvironmentStrings(fn, buf, PATH_MAX))
 -            /* FIXME: Needs to set errno! */
 -            return NULL;
 -        fn = buf;
 -#endif
 -
          if ((f = pa_fopen_cloexec(fn, "r"))) {
              if (result)
                  *result = pa_xstrdup(fn);
          const char *e;
          char *lfn;
          char *h;
 -        FILE *f;
  
          if ((e = getenv("PULSE_CONFIG_PATH")))
              fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local);
          } else
              return NULL;
  
 -#ifdef OS_IS_WIN32
 -        if (!ExpandEnvironmentStrings(lfn, buf, PATH_MAX)) {
 -            /* FIXME: Needs to set errno! */
 -            pa_xfree(lfn);
 -            return NULL;
 -        }
 -        fn = buf;
 -#endif
 -
          if ((f = pa_fopen_cloexec(fn, "r"))) {
              if (result)
                  *result = pa_xstrdup(fn);
      }
  
      if (global) {
 -        FILE *f;
 +        char *gfn;
  
  #ifdef OS_IS_WIN32
 -        if (!ExpandEnvironmentStrings(global, buf, PATH_MAX))
 -            /* FIXME: Needs to set errno! */
 -            return NULL;
 -        global = buf;
 +        if (strncmp(global, PA_DEFAULT_CONFIG_DIR, strlen(PA_DEFAULT_CONFIG_DIR)) == 0)
 +            gfn = pa_sprintf_malloc("%s" PA_PATH_SEP "etc" PA_PATH_SEP "pulse%s",
 +                                    pa_win32_get_toplevel(NULL),
 +                                    global + strlen(PA_DEFAULT_CONFIG_DIR));
 +        else
  #endif
 +        gfn = pa_xstrdup(global);
  
 -        if ((f = pa_fopen_cloexec(global, "r"))) {
 -
 +        if ((f = pa_fopen_cloexec(gfn, "r"))) {
              if (result)
 -                *result = pa_xstrdup(global);
 +                *result = gfn;
 +            else
 +                pa_xfree(gfn);
  
              return f;
          }
 +        pa_xfree(gfn);
      }
  
      errno = ENOENT;
  
  char *pa_find_config_file(const char *global, const char *local, const char *env) {
      const char *fn;
 -#ifdef OS_IS_WIN32
 -    char buf[PATH_MAX];
 -
 -    if (!getenv(PULSE_ROOTENV))
 -        pa_set_root(NULL);
 -#endif
  
      if (env && (fn = getenv(env))) {
 -
 -#ifdef OS_IS_WIN32
 -        if (!ExpandEnvironmentStrings(fn, buf, PATH_MAX))
 -            /* FIXME: Needs to set errno! */
 -            return NULL;
 -        fn = buf;
 -#endif
 -
          if (access(fn, R_OK) == 0)
              return pa_xstrdup(fn);
  
          } else
              return NULL;
  
 -#ifdef OS_IS_WIN32
 -        if (!ExpandEnvironmentStrings(lfn, buf, PATH_MAX)) {
 -            /* FIXME: Needs to set errno! */
 -            pa_xfree(lfn);
 -            return NULL;
 -        }
 -        fn = buf;
 -#endif
 -
          if (access(fn, R_OK) == 0) {
              char *r = pa_xstrdup(fn);
              pa_xfree(lfn);
      }
  
      if (global) {
 +        char *gfn;
 +
  #ifdef OS_IS_WIN32
 -        if (!ExpandEnvironmentStrings(global, buf, PATH_MAX))
 -            /* FIXME: Needs to set errno! */
 -            return NULL;
 -        global = buf;
 +        if (strncmp(global, PA_DEFAULT_CONFIG_DIR, strlen(PA_DEFAULT_CONFIG_DIR)) == 0)
 +            gfn = pa_sprintf_malloc("%s" PA_PATH_SEP "etc" PA_PATH_SEP "pulse%s",
 +                                    pa_win32_get_toplevel(NULL),
 +                                    global + strlen(PA_DEFAULT_CONFIG_DIR));
 +        else
  #endif
 +        gfn = pa_xstrdup(global);
  
 -        if (access(global, R_OK) == 0)
 -            return pa_xstrdup(global);
 +        if (access(gfn, R_OK) == 0)
 +            return gfn;
 +        pa_xfree(gfn);
      }
  
      errno = ENOENT;
@@@ -1823,7 -1891,7 +1859,7 @@@ char *pa_hexstr(const uint8_t* d, size_
      pa_assert(s);
      pa_assert(slength > 0);
  
 -    while (i < dlength && j+3 <= slength) {
 +    while (j+2 < slength && i < dlength) {
          s[j++] = hex[*d >> 4];
          s[j++] = hex[*d & 0xF];