Index: src/utils.c
===================================================================
--- src/utils.c	(revision 719)
+++ src/utils.c	(working copy)
@@ -289,4 +289,30 @@
 		return sr;
 	return NULL;
 }
-#endif /* HAVE_STRCASESTR */
+#endif /* !HAVE_STRCASESTR */
+
+
+#ifndef HAVE_STRDUP
+char * strdup(char * str) {
+
+	char * dup = (char *)malloc(strlen(str) + 1);
+	if (dup) {
+		strcpy(dup,str);
+	}
+	return dup;
+}
+#endif /* !HAVE_STRDUP */
+
+
+#ifndef HAVE_STRNDUP
+char * strndup(char * str, size_t len) {
+
+	char * dup = (char *)malloc(len + 1);
+	if (dup) {
+		strncpy(dup, str, len);
+		dup[len]= '\0';
+	}
+	return dup;
+}
+#endif /* !HAVE_STRNDUP */
+
Index: src/playlist.c
===================================================================
--- src/playlist.c	(revision 719)
+++ src/playlist.c	(working copy)
@@ -250,11 +250,11 @@
 
 	AQUALUNG_COND_INIT(pl->thread_wait);
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	pl->thread_mutex = g_mutex_new();
 	pl->wait_mutex = g_mutex_new();
 	pl->thread_wait = g_cond_new();
-#endif
+#endif /* _WIN32 || _DARWIN */
 
 	if (name != NULL) {
 		strncpy(pl->name, name, MAXLEN-1);
@@ -275,11 +275,11 @@
 
 	playlists = g_list_remove(playlists, pl);
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	g_mutex_free(pl->thread_mutex);
 	g_mutex_free(pl->wait_mutex);
 	g_cond_free(pl->thread_wait);
-#endif
+#endif /* _WIN32 || _DARWIN */
 
 	free(pl);
 }
Index: src/utils.h
===================================================================
--- src/utils.h	(revision 719)
+++ src/utils.h	(working copy)
@@ -34,7 +34,14 @@
 
 #ifndef HAVE_STRCASESTR
 char * strcasestr(char * haystack, char * needle);
-#endif /* HAVE_STRCASESTR */
+#endif /* !HAVE_STRCASESTR */
 
+#ifndef HAVE_STRDUP
+char * strdup(char * str);
+#endif /* !HAVE_STRDUP */
 
+#ifndef HAVE_STRNDUP
+char * strndup(char * str, size_t len);
+#endif /* !HAVE_STRNDUP */
+
 #endif /* _UTILS_H */
Index: src/volume.c
===================================================================
--- src/volume.c	(revision 719)
+++ src/volume.c	(working copy)
@@ -26,11 +26,11 @@
 #include <gtk/gtk.h>
 #include <math.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 #include "common.h"
 #include "core.h"
@@ -79,11 +79,11 @@
 
 	AQUALUNG_COND_INIT(vol->thread_wait);
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	vol->thread_mutex = g_mutex_new();
 	vol->wait_mutex = g_mutex_new();
 	vol->thread_wait = g_cond_new();
-#endif
+#endif /* _WIN32 || _DARWIN */
 
 	return vol;
 }
@@ -114,11 +114,11 @@
 void
 volume_free(volume_t * vol) {
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	g_mutex_free(vol->thread_mutex);
 	g_mutex_free(vol->wait_mutex);
 	g_cond_free(vol->thread_wait);
-#endif
+#endif /* _WIN32 || _DARWIN */
 
 	if (vol->volumes != NULL) {
 		free(vol->volumes);
Index: src/cddb_lookup.c
===================================================================
--- src/cddb_lookup.c	(revision 719)
+++ src/cddb_lookup.c	(working copy)
@@ -28,11 +28,11 @@
 #include <gtk/gtk.h>
 #include <cddb/cddb.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 #include "common.h"
 #include "i18n.h"
Index: src/gui_main.c
===================================================================
--- src/gui_main.c	(revision 719)
+++ src/gui_main.c	(working copy)
@@ -33,11 +33,11 @@
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 #ifdef HAVE_LADSPA
 #include <lrdf.h>
Index: src/cd_ripper.c
===================================================================
--- src/cd_ripper.c	(revision 719)
+++ src/cd_ripper.c	(working copy)
@@ -25,11 +25,11 @@
 #include <string.h>
 #include <gtk/gtk.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 #include "common.h"
 #include "utils.h"
Index: src/decoder/dec_mpeg.c
===================================================================
--- src/decoder/dec_mpeg.c	(revision 719)
+++ src/decoder/dec_mpeg.c	(working copy)
@@ -30,11 +30,11 @@
 #include <limits.h>
 #include <string.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 #include "../i18n.h"
 #ifdef HAVE_MOD
Index: src/decoder/file_decoder.c
===================================================================
--- src/decoder/file_decoder.c	(revision 719)
+++ src/decoder/file_decoder.c	(working copy)
@@ -31,11 +31,11 @@
 #include <sys/stat.h>
 #include <gtk/gtk.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 
 #include "file_decoder.h"
Index: src/decoder/dec_cdda.c
===================================================================
--- src/decoder/dec_cdda.c	(revision 719)
+++ src/decoder/dec_cdda.c	(working copy)
@@ -208,9 +208,9 @@
 cdda_decoder_init(file_decoder_t * fdec) {
 
         decoder_t * dec = NULL;
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	cdda_pdata_t * pd = NULL;
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
         if ((dec = calloc(1, sizeof(decoder_t))) == NULL) {
                 fprintf(stderr, "dec_cdda.c: cdda_decoder_new() failed: calloc error\n");
@@ -230,10 +230,10 @@
 	dec->close = cdda_decoder_close;
 	dec->read = cdda_decoder_read;
 	dec->seek = cdda_decoder_seek;
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	pd = (cdda_pdata_t *)dec->pdata;
 	pd->cdda_reader_mutex = g_mutex_new();
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 	return dec;
 }
@@ -242,10 +242,10 @@
 void
 cdda_decoder_destroy(decoder_t * dec) {
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	cdda_pdata_t * pd = (cdda_pdata_t *)dec->pdata;
 	g_mutex_free(pd->cdda_reader_mutex);
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 	free(dec->pdata);
 	free(dec);
 }
Index: src/decoder/dec_cdda.h
===================================================================
--- src/decoder/dec_cdda.h	(revision 719)
+++ src/decoder/dec_cdda.h	(working copy)
@@ -39,11 +39,11 @@
 #undef _TMP_HAVE_CDDB
 #endif /* _TMP_HAVE_CDDB */
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32*/
+#endif /* _WIN32 || _DARWIN */
 
 #include "../cdda.h"
 #endif /* HAVE_CDDA */
Index: src/core.c
===================================================================
--- src/core.c	(revision 719)
+++ src/core.c	(working copy)
@@ -35,11 +35,11 @@
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 #ifdef HAVE_SRC
 #include <samplerate.h>
@@ -601,7 +601,7 @@
 	sleep:
 		{
 			/* suspend thread, wake up after 100 ms */
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 			GTimeVal time;
 			GTimeVal * timeout = &time;
 			g_get_current_time(timeout);
@@ -617,7 +617,7 @@
 				timeout.tv_nsec -= 1000000000;
 				timeout.tv_sec += 1;
 			}
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 			AQUALUNG_COND_TIMEDWAIT(disk_thread_wake, disk_thread_lock, timeout)
 		}
 	}
@@ -2087,9 +2087,9 @@
 	char ** argv_def = NULL;
 
 	thread_info_t thread_info;
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(_DARWIN)
 	struct sched_param param;
-#endif /* !_WIN32 */
+#endif /* !_WIN32 && !_DARWIN */
 
 	int c;
 	int longopt_index = 0;
@@ -2152,18 +2152,18 @@
 #endif /* jack || alsa || oss */
 
 
-#ifdef HAVE_JACK
+#if defined(HAVE_JACK) && !defined(_DARWIN)
 	/* unlock memory (implicitly locked by libjack when Jack runs realtime) */
 	if (munlockall() < 0) {
 		fprintf(stderr, "aqualung main(): munlockall() failed\n");
 	}
-#endif /* HAVE_JACK */
+#endif /* HAVE_JACK && !_DARWIN */
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	g_thread_init(NULL);
 	disk_thread_lock = g_mutex_new();
 	disk_thread_wake = g_cond_new();
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 	file_decoder_init();
 
@@ -2769,8 +2769,8 @@
 	AQUALUNG_THREAD_CREATE(thread_info.disk_thread_id, NULL, disk_thread, &thread_info)
 
 	if (disk_try_realtime) {
-#ifdef _WIN32
-		printf("Warning: setting thread priorities is unsupported under Win32.\n");
+#if defined(_WIN32) || defined(_DARWIN)
+		printf("Warning: setting thread priorities is unsupported under Darwin and Win32.\n");
 #else
 		int x;
 		memset(&param, 0, sizeof(param));
@@ -2781,7 +2781,7 @@
 				"Warning: cannot use real-time scheduling for disk thread (FIFO/%d) "
 				"(%d: %s)\n", param.sched_priority, x, strerror(x));
 		}
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 	}
 
 
@@ -2802,8 +2802,8 @@
 		AQUALUNG_THREAD_CREATE(thread_info.alsa_thread_id, NULL, alsa_thread, &thread_info)
 
 		if (try_realtime) {
-#ifdef _WIN32
-			printf("Warning: setting thread priorities is unsupported under Win32.\n");
+#if defined(_WIN32) || defined(_DARWIN)
+			printf("Warning: setting thread priorities is unsupported under Darwin and Win32.\n");
 #else
 			int x;
 			memset(&param, 0, sizeof(param));
@@ -2814,7 +2814,7 @@
 					"Warning: cannot use real-time scheduling for ALSA output thread (FIFO/%d) "
 					"(%d: %s)\n", param.sched_priority, x, strerror(x));
 			}
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 		}
 	}
 #endif /* HAVE_ALSA */
@@ -2864,10 +2864,12 @@
 	if (output == WIN32_DRIVER) {
 		AQUALUNG_THREAD_JOIN(thread_info.win32_thread_id)
 	}
+#endif /* _WIN32 */
 
+#if defined(_WIN32) || defined(_DARWIN)
 	g_mutex_free(disk_thread_lock);
 	g_cond_free(disk_thread_wake);
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 	if (device_name != NULL)
 		free(device_name);
Index: src/core.h
===================================================================
--- src/core.h	(revision 719)
+++ src/core.h	(working copy)
@@ -25,11 +25,11 @@
 
 #include <sys/types.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif
+#endif /* _WIN32 || _DARWIN */
 
 #include "common.h"
 
Index: src/plugin.c
===================================================================
--- src/plugin.c	(revision 719)
+++ src/plugin.c	(working copy)
@@ -41,11 +41,11 @@
 #include "trashlist.h"
 #include "plugin.h"
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(_DARWIN)
 #define dirent64 dirent
 #define scandir64 scandir
 #define alphasort64 alphasort
-#endif /* __FreeBSD__ */
+#endif /* __FreeBSD__ || _DARWIN */
 
 extern options_t options;
 
@@ -152,7 +152,11 @@
 	if ((str = getenv("LADSPA_RDF_PATH"))) {
 		snprintf(lrdf_path, MAXLEN-1, "%s:", str);
 	} else {
-                strncat(lrdf_path, "/usr/local/share/ladspa/rdf:/usr/share/ladspa/rdf:", MAXLEN-1);
+#ifdef _DARWIN
+        strncat(lrdf_path, "/Library/Audio/Plug-Ins/LADSPA/rdf:", MAXLEN-1);
+#else
+        strncat(lrdf_path, "/usr/local/share/ladspa/rdf:/usr/share/ladspa/rdf:", MAXLEN-1);
+#endif /* _DARWIN */
 	}
 
 	for (i = 0; lrdf_path[i] != '\0'; i++) {
@@ -298,8 +302,12 @@
 	char * directory;
 
 	if (!(ladspa_path = getenv("LADSPA_PATH"))) {
+#ifdef _DARWIN
+		find_plugins("/Library/Audio/Plug-Ins/LADSPA");
+#else
 		find_plugins("/usr/lib/ladspa");
 		find_plugins("/usr/local/lib/ladspa");
+#endif /* _DARWIN */
 	} else {
 		ladspa_path = strdup(ladspa_path);
 		directory = strtok(ladspa_path, ":");
Index: src/build_store.c
===================================================================
--- src/build_store.c	(revision 719)
+++ src/build_store.c	(working copy)
@@ -32,11 +32,11 @@
 #include <gtk/gtk.h>
 #include <sys/stat.h>
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 #include <glib.h>
 #else
 #include <pthread.h>
-#endif /* _WIN32*/
+#endif /* _WIN32 || _DARWIN */
 
 #include "common.h"
 #include "utils.h"
Index: src/cdda.c
===================================================================
--- src/cdda.c	(revision 719)
+++ src/cdda.c	(working copy)
@@ -28,9 +28,9 @@
 #include <unistd.h>
 #include <glib.h>
 #include <glib/gstdio.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(_DARWIN)
 #include <pthread.h>
-#endif /* !_WIN32 */
+#endif /* !_WIN32 && !_DARWIN */
 
 #ifdef HAVE_CDDB
 #define _TMP_HAVE_CDDB 1
@@ -539,9 +539,9 @@
 		return;
 
 	cdda_notify_rb = rb_create(CDDA_NOTIFY_RB_SIZE);
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	cdda_mutex = g_mutex_new();
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 	cdda_timeout_start();
 
@@ -559,9 +559,9 @@
 	cdda_timeout_callback(NULL); /* cleanup any leftover messages */
 	cdda_timeout_stop();
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_DARWIN)
 	g_mutex_free(cdda_mutex);
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 	rb_free(cdda_notify_rb);
 }
Index: src/common.h
===================================================================
--- src/common.h	(revision 719)
+++ src/common.h	(working copy)
@@ -32,7 +32,7 @@
 #define INSENSITIVE 4
 
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined (_DARWIN)
 
 #define AQUALUNG_THREAD_DECLARE(thread_id) GThread * thread_id;
 #define AQUALUNG_THREAD_CREATE(id, attr, func, args) id=g_thread_create(func, args, TRUE, NULL);
@@ -72,7 +72,7 @@
 #define AQUALUNG_COND_TIMEDWAIT(cond, mutex, timeout) pthread_cond_timedwait(&(cond), &(mutex), &(timeout));
 #define AQUALUNG_COND_WAIT(cond, mutex) pthread_cond_wait(&(cond), &(mutex));
 
-#endif /* _WIN32 */
+#endif /* _WIN32 || _DARWIN */
 
 
 #endif /* _COMMON_H */
Index: configure.ac
===================================================================
--- configure.ac	(revision 719)
+++ configure.ac	(working copy)
@@ -32,6 +32,7 @@
    PLATFORM_LIBS="-lintl -lwinmm"
    win32="yes"
    freebsd="no"
+   darwin="no"
    if test "$buildtype" = "debug"; then
 	   AC_MSG_ERROR([Sorry, debug build under Cygwin is unsupported!])
    fi
@@ -43,14 +44,29 @@
    PLATFORM_LIBS=""
    win32="no"
    freebsd="yes"
+   darwin="no"
    platform="FreeBSD"
    AC_MSG_RESULT(FreeBSD)
 fi
+if test `uname -a | grep Darwin | wc -l` = "1"  ; then
+   PLATFORM_CFLAGS=""
+   PLATFORM_LIBS=""
+   win32="no"
+   freebsd="no"
+   darwin="yes"
+   platform="Darwin"
+   if test "$buildtype" = "debug"; then
+	   AC_MSG_ERROR([Sorry, debug build under Darwin is unsupported!])
+   fi
+   AC_DEFINE([_DARWIN], [1], [Defined if compiling on Darwin (Mac OS X)])
+   AC_MSG_RESULT(Darwin)
+fi
 if test `uname -a | grep Linux | wc -l` = "1"  ; then
    PLATFORM_CFLAGS=""
    PLATFORM_LIBS=""
    win32="no"
    freebsd="no"
+   darwin="no"
    platform="Linux"
    AC_MSG_RESULT(Linux)
 fi
@@ -79,7 +95,7 @@
 AC_PROG_GCC_TRADITIONAL
 AC_FUNC_MALLOC
 AC_FUNC_STAT
-AC_CHECK_FUNCS([floor memset mkdir strdup strrchr strstr strcasestr])
+AC_CHECK_FUNCS([floor memset mkdir strdup strndup strrchr strstr strcasestr])
 
 
 
@@ -90,7 +106,7 @@
 
 
 
-if test $win32 = "no" ; then
+if test $win32 = "no" -a $darwin = "no" ; then
 AC_CHECK_LIB(pthread,
 	pthread_create,
 	[],
@@ -332,7 +348,11 @@
 else
 	AC_CHECK_LIB(vorbis, ov_open, [lib=yes], [lib=no], [-lvorbisfile])
 	if test "$lib" = "yes"; then
-		ogg_LIBS="-lvorbis -lvorbisfile"
+        if test $darwin = "yes" ; then
+    		ogg_LIBS="-logg -lvorbis -lvorbisfile"
+        else
+    		ogg_LIBS="-lvorbis -lvorbisfile"
+        fi
 		AC_DEFINE([HAVE_OGG_VORBIS], [1], [Defined if compile with Ogg Vorbis support])
 	fi
 	if test "$lib" = "no" -a "$ogg" = "yes"; then
