From 7732421a27870a832d7121bc8342503f2fbf3c2a Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 22 Sep 2009 11:27:57 +0800 Subject: [PATCH] CoreAudio: add audio device module This patch adds support for CoreAudio driven devices under Mac OS X. It is typically instanciated by the CoreAudio device detection module and handles all available streams on a specific device. Sinks are created according to the reported stream configuration. Float32 is used as default audio sample format at it is the only format CoreAudio speaks natively. Hardware volume control is not implemented yet. --- src/Makefile.am | 9 +- src/modules/coreaudio/module-coreaudio-device.c | 820 ++++++++++++++++++++++++ 2 files changed, 828 insertions(+), 1 deletion(-) create mode 100644 src/modules/coreaudio/module-coreaudio-device.c diff --git a/src/Makefile.am b/src/Makefile.am index 70ab5b07..fa5d1702 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1068,7 +1068,8 @@ endif if HAVE_COREAUDIO modlibexec_LTLIBRARIES += \ - module-coreaudio-detect.la + module-coreaudio-detect.la \ + module-coreaudio-device.la endif pulselibexec_PROGRAMS = @@ -1244,6 +1245,7 @@ SYMDEF_FILES = \ modules/alsa/module-alsa-source-symdef.h \ modules/alsa/module-alsa-card-symdef.h \ modules/coreaudio/module-coreaudio-detect-symdef.h \ + modules/coreaudio/module-coreaudio-device-symdef.h \ modules/module-solaris-symdef.h \ modules/module-waveout-symdef.h \ modules/module-detect-symdef.h \ @@ -1483,6 +1485,11 @@ module_coreaudio_detect_la_LDFLAGS = $(MODULE_LDFLAGS) \ -Wl,-framework -Wl,AudioUnit -framework AudioUnit module_coreaudio_detect_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la +module_coreaudio_device_la_SOURCES = modules/coreaudio/module-coreaudio-device.c +module_coreaudio_device_la_LDFLAGS = $(MODULE_LDFLAGS) \ + -Wl,-framework -Wl,Cocoa -framework CoreAudio \ + -Wl,-framework -Wl,AudioUnit -framework AudioUnit +module_coreaudio_device_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la # ALSA libalsa_util_la_SOURCES = modules/alsa/alsa-util.c modules/alsa/alsa-util.h modules/alsa/alsa-mixer.c modules/alsa/alsa-mixer.h modules/alsa/alsa-sink.c modules/alsa/alsa-sink.h modules/alsa/alsa-source.c modules/alsa/alsa-source.h modules/reserve-wrap.c modules/reserve-wrap.h diff --git a/src/modules/coreaudio/module-coreaudio-device.c b/src/modules/coreaudio/module-coreaudio-device.c new file mode 100644 index 00000000..a3699e68 --- /dev/null +++ b/src/modules/coreaudio/module-coreaudio-device.c @@ -0,0 +1,820 @@ +/*** + This file is part of PulseAudio. + + Copyright 2009 Daniel Mack + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, + or (at your option) any later version. + + PulseAudio 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 Lesser General Public License + along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +/* TODO: + - implement hardware volume controls + - handle audio device stream format changes (will require changes to the core) +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "module-coreaudio-device-symdef.h" + +#define DEFAULT_FRAMES_PER_IOPROC 512 + +PA_MODULE_AUTHOR("Daniel Mack"); +PA_MODULE_DESCRIPTION("CoreAudio device"); +PA_MODULE_VERSION(PACKAGE_VERSION); +PA_MODULE_LOAD_ONCE(FALSE); +PA_MODULE_USAGE("device_id= " + "ioproc_frames=