diff --git a/configure.in b/configure.in
index 45dd9724710e355f7e062bf49c367a5468047476..d8f322d8c27fea550006b0118cf3e3f8a6dcc6f2 100644
--- a/configure.in
+++ b/configure.in
@@ -141,6 +141,11 @@ else
 fi
 AC_SUBST(ALSA_LIBS)
 
+dnl Check for Sun audio
+
+AC_CHECK_HEADERS(sys/audioio.h)
+AM_CONDITIONAL(HAVE_SUN_AUDIO,test "${ac_cv_header_sys_audioio_h}" = yes)
+
 dnl Check for aRts
 
 AC_PATH_PROG(ARTSC_CONFIG, artsc-config)
@@ -168,4 +173,4 @@ AM_CONDITIONAL(HAVE_SOLARIS,test "x$have_solaris" = xyes)
 
 CFLAGS="$CFLAGS -DAO_PLUGIN_PATH=\\\"$plugindir\\\""
 
-AC_OUTPUT(Makefile src/Makefile doc/Makefile include/Makefile include/ao/Makefile include/ao/os_types.h src/plugins/Makefile src/plugins/esd/Makefile src/plugins/oss/Makefile src/plugins/alsa/Makefile src/plugins/arts/Makefile debian/Makefile)
+AC_OUTPUT(Makefile src/Makefile doc/Makefile include/Makefile include/ao/Makefile include/ao/os_types.h src/plugins/Makefile src/plugins/esd/Makefile src/plugins/oss/Makefile src/plugins/alsa/Makefile src/plugins/sun/Makefile src/plugins/arts/Makefile debian/Makefile)
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 27aed18ae8a20aaf97bcd8a6f452c01e0ef03a1c..e3f18bb61eff25748b930c04dc9c847b260c84b2 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -1,4 +1,4 @@
 ## Process this file with automake to produce Makefile.in
 
 AUTOMAKE_OPTIONS = foreign
-SUBDIRS = oss esd alsa arts # solaris irix
+SUBDIRS = oss sun esd alsa arts # irix
diff --git a/src/plugins/sun/.cvsignore b/src/plugins/sun/.cvsignore
new file mode 100644
index 0000000000000000000000000000000000000000..d523e05b9c054ecf02e99912c0d00197dd465622
--- /dev/null
+++ b/src/plugins/sun/.cvsignore
@@ -0,0 +1,6 @@
+*.la
+.libs
+.deps
+*.lo
+Makefile
+Makefile.in
diff --git a/src/plugins/sun/Makefile.am b/src/plugins/sun/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..47c3be51ee0e821bcdc6f0e20a11f6f3b9c4bbd6
--- /dev/null
+++ b/src/plugins/sun/Makefile.am
@@ -0,0 +1,27 @@
+## Process this file with automake to produce Makefile.in
+
+AUTOMAKE_OPTIONS = foreign
+
+if HAVE_SUN_AUDIO
+
+sunltlibs = libsun.la
+sunldflags = -export-dynamic -avoid-version
+sunsources = ao_sun.c
+
+else
+
+sunltlibs =
+sunldflags =
+sunsources =
+
+endif
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/include
+
+libdir = $(plugindir)
+lib_LTLIBRARIES = $(sunltlibs)
+
+libsun_la_LDFLAGS = $(sunldflags)
+libsun_la_SOURCES = $(sunsources)
+
+EXTRA_DIST = ao_sun.c
diff --git a/src/plugins/sun/ao_sun.c b/src/plugins/sun/ao_sun.c
new file mode 100644
index 0000000000000000000000000000000000000000..b65576493bfa06ab824496787e339d8841c0c826
--- /dev/null
+++ b/src/plugins/sun/ao_sun.c
@@ -0,0 +1,150 @@
+/*
+ *
+ *  ao_sun.c    Solaris/NetBSD/OpenBSD
+ *
+ *      Original Copyright (C) Aaron Holtzman - May 1999
+ *      Modifications Copyright (C) Stan Seibert - July 2000
+ *      and Copyright (C) Christian Weisgerber - March 2001
+ *
+ *  libao is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  libao is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GNU Make; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/audioio.h>
+
+#ifndef AUDIO_ENCODING_SLINEAR
+#define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR	/* Solaris */
+#endif
+
+#include <ao/ao.h>
+
+ao_info_t ao_sun_info = {
+	"Sun audio driver output",
+	"sun",
+	"Christian Weisgerber <naddy@openbsd.org>",
+	"Outputs to the sun audio system."
+};
+
+typedef struct ao_sun_internal_s {
+	char *dev;
+	int fd;
+} ao_sun_internal_t;
+
+void ao_sun_parse_options(ao_sun_internal_t *state, ao_option_t *options)
+{
+	state->dev = NULL;
+
+	while (options) {
+		if (!strcmp(options->key, "dev"))
+			state->dev = strdup(options->value);
+		options = options->next;
+	}
+}
+
+ao_internal_t *plugin_open(uint_32 bits, uint_32 rate, uint_32 channels, ao_option_t *options)
+{
+	ao_sun_internal_t *state;
+	audio_info_t info;
+
+	state = malloc(sizeof(ao_sun_internal_t));
+
+	if (state == NULL) {
+		fprintf(stderr,"libao: Error allocating state memory: %s\n",
+			strerror(errno));
+		goto ERR;
+	}
+
+	ao_sun_parse_options(state, options);
+
+	if (state->dev != NULL) {
+		/* open the user-specified path */
+		state->fd = open(state->dev, O_WRONLY);
+		if (state->fd < 0) {
+			fprintf(stderr, "libao: Error opening audio device %s: %s\n",
+				state->dev, strerror(errno));
+			goto ERR;
+		}
+	} else {
+		/* default */
+		state->dev = strdup("/dev/audio");
+		state->fd = open(state->dev, O_WRONLY);
+		if (state->fd < 0) {
+			fprintf(stderr,
+				"libao: Could not open default device %s: %s\n",
+				state->dev, strerror(errno));
+			goto ERR;
+		}
+	}
+
+	AUDIO_INITINFO(&info);
+#ifdef AUMODE_PLAY	/* NetBSD/OpenBSD */
+	info.mode = AUMODE_PLAY;
+#endif
+	info.play.encoding = AUDIO_ENCODING_SLINEAR;
+	info.play.precision = bits;
+	info.play.sample_rate = rate;
+	info.play.channels = channels;
+
+ 	if (ioctl(state->fd, AUDIO_SETINFO, &info) < 0) {
+		fprintf(stderr,
+			"libao: Cannot set device to %d bits, %d Hz, %d channels: %s\n",
+			bits, rate, channels, strerror(errno));
+		goto ERR;
+	}
+
+	return state;
+
+ERR:
+	if (state != NULL) {
+		if (state->fd >= 0)
+			close(state->fd);
+		if (state->dev)
+			free(state->dev);
+		free(state);
+	}
+	return NULL;
+}
+
+void plugin_play(ao_internal_t *state, void *output_samples, uint_32 num_bytes)
+{
+	write(((ao_sun_internal_t *)state)->fd, output_samples, num_bytes);
+}
+
+void plugin_close(ao_internal_t *state)
+{
+	ao_sun_internal_t *s = (ao_sun_internal_t *)state;
+	close(s->fd);
+	free(s->dev);
+	free(s);
+}
+
+int plugin_get_latency(ao_internal_t *state)
+{
+	/* dummy */
+	return 0;
+}
+
+ao_info_t *plugin_get_driver_info(void)
+{
+	return &ao_sun_info;
+}