Date: Fri, 23 Apr 2010 05:31:13 +0200 From: "Aragon Gouveia" <aragon@phat.za.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/145965: New port: audio/alsa-plugins Compatibility layer for ALSA support Message-ID: <20100423033113.992C73D0C8@mail.geek.sh> Resent-Message-ID: <201004230340.o3N3e128058767@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 145965 >Category: ports >Synopsis: New port: audio/alsa-plugins Compatibility layer for ALSA support >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Apr 23 03:40:00 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Aragon Gouveia >Release: FreeBSD 8.0-STABLE amd64 >Organization: >Environment: System: FreeBSD igor.geek.sh 8.0-STABLE FreeBSD 8.0-STABLE #0: Mon Mar 8 01:27:41 SAST 2010 toor@igor.geek.sh:/usr/obj/usr/src/sys/IGOR amd64 >Description: This port provides FreeBSD with a compatibility layer for software that depends on ALSA support. It is based entirely on ariff@'s work at http://people.freebsd.org/~ariff/libasound/, but has been updated for the latest version of ALSA. Chromium for FreeBSD is an immediate beneficiary of this. This depends on ports/145964. Special thanks to sprewell@jaggeri.com for testing this, and ariff@ for making it! >How-To-Repeat: >Fix: --- alsa-plugins.shar begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # alsa-plugins # alsa-plugins/files # alsa-plugins/files/patch-alsa-plugins # alsa-plugins/distinfo # alsa-plugins/Makefile # alsa-plugins/pkg-descr # alsa-plugins/pkg-plist # echo c - alsa-plugins mkdir -p alsa-plugins > /dev/null 2>&1 echo c - alsa-plugins/files mkdir -p alsa-plugins/files > /dev/null 2>&1 echo x - alsa-plugins/files/patch-alsa-plugins sed 's/^X//' >alsa-plugins/files/patch-alsa-plugins << '753829a8e6934e242f5369f19b603c4e' X--- Makefile.in.orig 2009-08-31 21:16:47.000000000 +0800 X+++ Makefile.in 2009-09-14 21:59:01.000000000 +0800 X@@ -67,7 +67,7 @@ X uninstall-recursive X ETAGS = etags X CTAGS = ctags X-DIST_SUBDIRS = oss mix usb_stream arcam-av doc jack pulse rate a52 \ X+DIST_SUBDIRS = oss mix doc jack pulse rate a52 \ X rate-lavc maemo pph speex X DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) X distdir = $(PACKAGE)-$(VERSION) X@@ -214,7 +214,7 @@ X speexdsp_LIBS = @speexdsp_LIBS@ X sysconfdir = @sysconfdir@ X target_alias = @target_alias@ X-SUBDIRS = oss mix usb_stream arcam-av doc $(am__append_1) \ X+SUBDIRS = oss mix doc $(am__append_1) \ X $(am__append_2) $(am__append_3) $(am__append_4) \ X $(am__append_5) $(am__append_6) $(am__append_7) X EXTRA_DIST = gitcompile version COPYING.GPL m4/attributes.m4 X--- configure.orig 2009-08-31 21:16:47.000000000 +0800 X+++ configure 2009-09-14 21:59:12.000000000 +0800 X@@ -9645,7 +9645,7 @@ X echo $ECHO_N "(cached) $ECHO_C" >&6 X else X ac_check_lib_save_LIBS=$LIBS X-LIBS="-ldl $LIBS" X+LIBS="$LIBS" X cat >conftest.$ac_ext <<_ACEOF X /* confdefs.h. */ X _ACEOF X@@ -9717,7 +9717,7 @@ X { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 X echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } X if test $ac_cv_lib_dl_dlopen = yes; then X- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" X+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="" X else X X lt_cv_dlopen="dyld" X@@ -10015,7 +10015,7 @@ X echo $ECHO_N "(cached) $ECHO_C" >&6 X else X ac_check_lib_save_LIBS=$LIBS X-LIBS="-ldl $LIBS" X+LIBS="$LIBS" X cat >conftest.$ac_ext <<_ACEOF X /* confdefs.h. */ X _ACEOF X@@ -10087,7 +10087,7 @@ X { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 X echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } X if test $ac_cv_lib_dl_dlopen = yes; then X- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" X+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="" X else X { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 X echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; } X@@ -20270,7 +20270,7 @@ X echo $ECHO_N "(cached) $ECHO_C" >&6 X else X ac_check_lib_save_LIBS=$LIBS X-LIBS="-lasound -ldl $LIBS" X+LIBS="-lasound $LIBS" X cat >conftest.$ac_ext <<_ACEOF X /* confdefs.h. */ X _ACEOF X@@ -21493,7 +21493,7 @@ X echo "${ECHO_T}$SND_PLUGINS_VERSION" >&6; } X X X-ac_config_files="$ac_config_files Makefile oss/Makefile pph/Makefile jack/Makefile pulse/Makefile mix/Makefile rate/Makefile a52/Makefile rate-lavc/Makefile maemo/Makefile doc/Makefile usb_stream/Makefile speex/Makefile arcam-av/Makefile" X+ac_config_files="$ac_config_files Makefile oss/Makefile pph/Makefile jack/Makefile pulse/Makefile mix/Makefile rate/Makefile a52/Makefile rate-lavc/Makefile maemo/Makefile doc/Makefile speex/Makefile" X X cat >confcache <<\_ACEOF X # This file is a shell script that caches the results of configure X@@ -22134,9 +22134,7 @@ X "rate-lavc/Makefile") CONFIG_FILES="$CONFIG_FILES rate-lavc/Makefile" ;; X "maemo/Makefile") CONFIG_FILES="$CONFIG_FILES maemo/Makefile" ;; X "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; X- "usb_stream/Makefile") CONFIG_FILES="$CONFIG_FILES usb_stream/Makefile" ;; X "speex/Makefile") CONFIG_FILES="$CONFIG_FILES speex/Makefile" ;; X- "arcam-av/Makefile") CONFIG_FILES="$CONFIG_FILES arcam-av/Makefile" ;; X X *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 X echo "$as_me: error: invalid argument: $ac_config_target" >&2;} X--- jack/pcm_jack.c.orig 2009-09-16 04:33:36.000000000 +0800 X+++ jack/pcm_jack.c 2009-09-16 04:33:55.000000000 +0800 X@@ -20,7 +20,9 @@ X * X */ X X+#ifndef __FreeBSD__ X #include <byteswap.h> X+#endif X #include <sys/shm.h> X #include <sys/types.h> X #include <sys/socket.h> X--- oss/ctl_oss.c.orig 2009-08-31 21:09:41.000000000 +0800 X+++ oss/ctl_oss.c 2009-09-15 01:07:51.000000000 +0800 X@@ -26,7 +26,11 @@ X #include <sys/ioctl.h> X #include <alsa/asoundlib.h> X #include <alsa/control_external.h> X+#ifdef __FreeBSD__ X+#include <sys/soundcard.h> X+#else X #include <linux/soundcard.h> X+#endif X X typedef struct snd_ctl_oss { X snd_ctl_ext_t ext; X@@ -362,7 +366,9 @@ X { X snd_config_iterator_t it, next; X const char *device = "/dev/mixer"; X+#ifndef __FreeBSD__ X struct mixer_info mixinfo; X+#endif X int i, err, val; X snd_ctl_oss_t *oss; X X@@ -399,19 +405,29 @@ X goto error; X } X X+#ifndef __FreeBSD__ X if (ioctl(oss->fd, SOUND_MIXER_INFO, &mixinfo) < 0) { X err = -errno; X SNDERR("Cannot get mixer info for device %s", device); X goto error; X } X+#endif X X oss->ext.version = SND_CTL_EXT_VERSION; X oss->ext.card_idx = 0; /* FIXME */ X+#ifdef __FreeBSD__ X+ strncpy(oss->ext.id, "fbsd", sizeof(oss->ext.id) - 1); X+ strcpy(oss->ext.driver, "FreeBSD/OSS plugin"); X+ strncpy(oss->ext.name, "FreeBSD/OSS", sizeof(oss->ext.name) - 1); X+ strncpy(oss->ext.longname, "FreeBSD/OSS", sizeof(oss->ext.longname) - 1); X+ strncpy(oss->ext.mixername, "FreeBSD/OSS", sizeof(oss->ext.mixername) - 1); X+#else X strncpy(oss->ext.id, mixinfo.id, sizeof(oss->ext.id) - 1); X strcpy(oss->ext.driver, "OSS-Emulation"); X strncpy(oss->ext.name, mixinfo.name, sizeof(oss->ext.name) - 1); X strncpy(oss->ext.longname, mixinfo.name, sizeof(oss->ext.longname) - 1); X strncpy(oss->ext.mixername, mixinfo.name, sizeof(oss->ext.mixername) - 1); X+#endif X oss->ext.poll_fd = -1; X oss->ext.callback = &oss_ext_callback; X oss->ext.private_data = oss; X--- oss/pcm_oss.c.orig 2009-08-31 21:09:41.000000000 +0800 X+++ oss/pcm_oss.c 2009-09-28 14:54:12.000000000 +0800 X@@ -22,17 +22,57 @@ X #include <sys/ioctl.h> X #include <alsa/asoundlib.h> X #include <alsa/pcm_external.h> X+#ifdef __FreeBSD__ X+#include <sys/param.h> X+#include <sys/soundcard.h> X+#else X #include <linux/soundcard.h> X+#endif X+ X+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) X+ X+#ifdef __FreeBSD__ X+/* #define FREEBSD_OSS_USE_IO_PTR 1 */ X+/* #define FREEBSD_OSS_BLKCNT_P2 1 */ X+/* #define FREEBSD_OSS_DEBUG_VERBOSE 1 */ X+#undef FREEBSD_OSS_USE_IO_PTR /* _IPTR is buggy ... Grr... */ X+#undef FREEBSD_OSS_BLKCNT_P2 X+#undef FREEBSD_OSS_DEBUG_VERBOSE X+ X+#define FREEBSD_OSS_RATE_MIN 1 X+#define FREEBSD_OSS_RATE_MAX 384000 X+ X+#define FREEBSD_OSS_CHANNELS_MIN 1 X+#if __FreeBSD_version >= 800096 X+#define FREEBSD_OSS_CHANNELS_MAX 8 X+#else X+#define FREEBSD_OSS_CHANNELS_MAX 2 X+#endif X+ X+#define FREEBSD_OSS_BUFSZ_MAX 131072 X+#define FREEBSD_OSS_BLKCNT_MIN 2 X+#define FREEBSD_OSS_BLKSZ_MIN 16 /* (FREEBSD_OSS_CHANNEL_MAX * 4) */ X+ X+#define FREEBSD_OSS_BUFSZ_MIN (FREEBSD_OSS_BLKCNT_MIN * FREEBSD_OSS_BLKSZ_MIN) X+#define FREEBSD_OSS_BLKCNT_MAX (FREEBSD_OSS_BUFSZ_MAX / FREEBSD_OSS_BUFSZ_MIN) X+#define FREEBSD_OSS_BLKSZ_MAX (FREEBSD_OSS_BUFSZ_MAX / FREEBSD_OSS_BLKCNT_MIN) X+#endif X X typedef struct snd_pcm_oss { X snd_pcm_ioplug_t io; X char *device; X int fd; X+#ifdef __FreeBSD__ X+ int bufsz, ptr, ptr_align, last_bytes; X+#else X int fragment_set; X int caps; X+#endif X int format; X+#ifndef __FreeBSD__ X unsigned int period_shift; X unsigned int periods; X+#endif X unsigned int frame_bytes; X } snd_pcm_oss_t; X X@@ -49,8 +89,13 @@ X buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8; X size *= oss->frame_bytes; X result = write(oss->fd, buf, size); X+#ifdef __FreeBSD__ X+ if (result == -1) X+ return -errno; X+#else X if (result <= 0) X return result; X+#endif X return result / oss->frame_bytes; X } X X@@ -67,13 +112,79 @@ X buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8; X size *= oss->frame_bytes; X result = read(oss->fd, buf, size); X+#ifdef __FreeBSD__ X+ if (result == -1) X+ return -errno; X+#else X if (result <= 0) X return result; X+#endif X return result / oss->frame_bytes; X } X X static snd_pcm_sframes_t oss_pointer(snd_pcm_ioplug_t *io) X { X+#ifdef __FreeBSD__ X+ snd_pcm_oss_t *oss = io->private_data; X+#ifdef FREEBSD_OSS_USE_IO_PTR X+ struct count_info ci; X+#endif X+ audio_buf_info bi; X+ X+ if (io->state != SND_PCM_STATE_RUNNING) X+ return 0; X+ X+ if (io->state == SND_PCM_STATE_XRUN) X+ return -EPIPE; X+ X+#ifdef FREEBSD_OSS_USE_IO_PTR X+ if (ioctl(oss->fd, (io->stream == SND_PCM_STREAM_PLAYBACK) ? X+ SNDCTL_DSP_GETOPTR : SNDCTL_DSP_GETIPTR, &ci) < 0) X+ return -EINVAL; X+ X+ if (ci.ptr == oss->last_bytes && X+ ((ioctl(oss->fd, (io->stream == SND_PCM_STREAM_PLAYBACK) ? X+ SNDCTL_DSP_GETOSPACE : SNDCTL_DSP_GETISPACE, &bi) < 0) || X+ bi.bytes == oss->bufsz)) X+ return -EPIPE; X+ X+ if (ci.ptr < oss->last_bytes) X+ oss->ptr += oss->bufsz; X+ X+ oss->ptr += ci.ptr; X+ oss->ptr -= oss->last_bytes; X+ oss->ptr %= oss->ptr_align; X+ X+ oss->last_bytes = ci.ptr; X+#else /* !FREEBSD_OSS_USE_IO_PTR */ X+ if (ioctl(oss->fd, (io->stream == SND_PCM_STREAM_PLAYBACK) ? X+ SNDCTL_DSP_GETOSPACE : SNDCTL_DSP_GETISPACE, &bi) < 0) X+ return -EINVAL; X+ X+ if (bi.bytes == oss->bufsz && bi.bytes == oss->last_bytes) { X+#if 0 X+#ifdef SNDCTL_DSP_GETERROR X+ audio_errinfo ei; X+ if (ioctl(oss->fd, SNDCTL_DSP_GETERROR, &ei) < 0 || X+ (io->stream == SND_PCM_STREAM_PLAYBACK && X+ ei.play_underruns != 0) || X+ (io->stream == SND_PCM_STREAM_CAPTURE && X+ ei.rec_overruns != 0)) X+#endif X+#endif X+ return -EPIPE; X+ } X+ X+ if (bi.bytes > oss->last_bytes) { X+ oss->ptr += bi.bytes - oss->last_bytes; X+ oss->ptr %= oss->ptr_align; X+ } X+ X+ oss->last_bytes = bi.bytes; X+#endif /* FREEBSD_OSS_USE_IO_PTR */ X+ X+ return snd_pcm_bytes_to_frames(io->pcm, oss->ptr); X+#else X snd_pcm_oss_t *oss = io->private_data; X struct count_info info; X int ptr; X@@ -85,20 +196,59 @@ X } X ptr = snd_pcm_bytes_to_frames(io->pcm, info.ptr); X return ptr; X+#endif X } X X static int oss_start(snd_pcm_ioplug_t *io) X { X snd_pcm_oss_t *oss = io->private_data; X+#ifdef __FreeBSD__ X+ audio_buf_info bi; X+#ifdef FREEBSD_OSS_USE_IO_PTR X+ struct count_info ci; X+#endif X+#endif X int tmp = io->stream == SND_PCM_STREAM_PLAYBACK ? X PCM_ENABLE_OUTPUT : PCM_ENABLE_INPUT; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &tmp) < 0) { X fprintf(stderr, "*** OSS: trigger failed\n"); X+#ifdef __FreeBSD__ X+ return -EINVAL; X+#else X if (io->stream == SND_PCM_STREAM_CAPTURE) X /* fake read to trigger */ X read(oss->fd, &tmp, 0); X+#endif X } X+ X+#ifdef __FreeBSD__ X+ if (ioctl(oss->fd, (io->stream == SND_PCM_STREAM_PLAYBACK) ? X+ SNDCTL_DSP_GETOSPACE : SNDCTL_DSP_GETISPACE, &bi) < 0) X+ return -EINVAL; X+ X+ if (oss->bufsz != (bi.fragsize * bi.fragstotal)) { X+ fprintf(stderr, "%s(): WARNING - bufsz changed! %d -> %d\n", X+ __func__, oss->bufsz, bi.fragsize * bi.fragstotal); X+ oss->bufsz = bi.fragsize * bi.fragstotal; X+ } X+ X+#ifdef FREEBSD_OSS_USE_IO_PTR X+ if (ioctl(oss->fd, (io->stream == SND_PCM_STREAM_PLAYBACK) ? X+ SNDCTL_DSP_GETOPTR : SNDCTL_DSP_GETIPTR, &ci) < 0) X+ return -EINVAL; X+ X+ oss->last_bytes = ci.ptr; X+#else X+ oss->last_bytes = bi.bytes; X+#endif X+ oss->ptr = 0; X+#endif X+ X return 0; X } X X@@ -107,6 +257,10 @@ X snd_pcm_oss_t *oss = io->private_data; X int tmp = 0; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &tmp); X return 0; X } X@@ -115,16 +269,25 @@ X { X snd_pcm_oss_t *oss = io->private_data; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X if (io->stream == SND_PCM_STREAM_PLAYBACK) X ioctl(oss->fd, SNDCTL_DSP_SYNC); X return 0; X } X X+#ifndef __FreeBSD__ X static int oss_prepare(snd_pcm_ioplug_t *io) X { X snd_pcm_oss_t *oss = io->private_data; X int tmp; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X ioctl(oss->fd, SNDCTL_DSP_RESET); X X tmp = io->channels; X@@ -145,16 +308,75 @@ X } X return 0; X } X+#endif X+ X+#ifdef __FreeBSD__ X+static const struct { X+ int oss_format; X+ snd_pcm_format_t alsa_format; X+} oss_formats_tab[] = { X+ { AFMT_U8, SND_PCM_FORMAT_U8 }, X+ { AFMT_S8, SND_PCM_FORMAT_S8 }, X+ { AFMT_MU_LAW, SND_PCM_FORMAT_MU_LAW }, X+ { AFMT_A_LAW, SND_PCM_FORMAT_A_LAW }, X+ { AFMT_S16_LE, SND_PCM_FORMAT_S16_LE }, X+ { AFMT_S16_BE, SND_PCM_FORMAT_S16_BE }, X+ { AFMT_U16_LE, SND_PCM_FORMAT_U16_LE }, X+ { AFMT_U16_BE, SND_PCM_FORMAT_U16_BE }, X+ { AFMT_S24_LE, SND_PCM_FORMAT_S24_3LE }, X+ { AFMT_S24_BE, SND_PCM_FORMAT_S24_3BE }, X+ { AFMT_U24_LE, SND_PCM_FORMAT_U24_3LE }, X+ { AFMT_U24_BE, SND_PCM_FORMAT_U24_3BE }, X+ { AFMT_S32_LE, SND_PCM_FORMAT_S32_LE }, X+ { AFMT_S32_BE, SND_PCM_FORMAT_S32_BE }, X+ { AFMT_U32_LE, SND_PCM_FORMAT_U32_LE }, X+ { AFMT_U32_BE, SND_PCM_FORMAT_U32_BE }, X+ /* Special */ X+ { AFMT_S24_LE, SND_PCM_FORMAT_S20_3LE }, X+ { AFMT_S24_BE, SND_PCM_FORMAT_S20_3BE }, X+ { AFMT_U24_LE, SND_PCM_FORMAT_U20_3LE }, X+ { AFMT_U24_BE, SND_PCM_FORMAT_U20_3BE }, X+ { AFMT_S24_LE, SND_PCM_FORMAT_S18_3LE }, X+ { AFMT_S24_BE, SND_PCM_FORMAT_S18_3BE }, X+ { AFMT_U24_LE, SND_PCM_FORMAT_U18_3LE }, X+ { AFMT_U24_BE, SND_PCM_FORMAT_U18_3BE }, X+ { AFMT_S32_LE, SND_PCM_FORMAT_S24_LE }, X+ { AFMT_S32_BE, SND_PCM_FORMAT_S24_BE }, X+ { AFMT_U32_LE, SND_PCM_FORMAT_U24_LE }, X+ { AFMT_U32_BE, SND_PCM_FORMAT_U24_BE }, X+}; X+#endif X X static int oss_hw_params(snd_pcm_ioplug_t *io, X snd_pcm_hw_params_t *params ATTRIBUTE_UNUSED) X { X snd_pcm_oss_t *oss = io->private_data; X int i, tmp, err; X+#ifdef __FreeBSD__ X+ int blksz_shift, blkcnt; X+ audio_buf_info bi; X+#else X unsigned int period_bytes; X+#endif X long oflags, flags; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X oss->frame_bytes = (snd_pcm_format_physical_width(io->format) * io->channels) / 8; X+#ifdef __FreeBSD__ X+ oss->ptr_align = io->buffer_size * oss->frame_bytes; X+ X+ oss->format = 0; X+ for (i = 0; i < ARRAY_SIZE(oss_formats_tab); i++) { X+ if (oss_formats_tab[i].alsa_format == io->format) { X+ oss->format = oss_formats_tab[i].oss_format; X+ break; X+ } X+ } X+ if (oss->format == 0) { X+#else X switch (io->format) { X case SND_PCM_FORMAT_U8: X oss->format = AFMT_U8; X@@ -166,9 +388,87 @@ X oss->format = AFMT_S16_BE; X break; X default: X+#endif X fprintf(stderr, "*** OSS: unsupported format %s\n", snd_pcm_format_name(io->format)); X return -EINVAL; X } X+#ifdef __FreeBSD__ X+ X+ ioctl(oss->fd, SNDCTL_DSP_RESET); X+ X+#define blksz_aligned() ((1 << blksz_shift) - \ X+ ((1 << blksz_shift) % oss->frame_bytes)) X+ blksz_shift = 16; X+ tmp = io->period_size * oss->frame_bytes; X+ X+ while (blksz_shift > 4 && blksz_aligned() > tmp) X+ blksz_shift--; X+ X+ blkcnt = 2; X+ tmp = io->buffer_size * oss->frame_bytes; X+ X+ while (blkcnt < 4096 && (blksz_aligned() * blkcnt) < tmp && X+ ((1 << blksz_shift) * blkcnt) < 131072) X+ blkcnt <<= 1; X+ X+ tmp = blksz_shift | (blkcnt << 16); X+ if (ioctl(oss->fd, SNDCTL_DSP_SETFRAGMENT, &tmp) < 0) { X+ perror("SNDCTL_DSP_SETFRAGMENTS"); X+ return -EINVAL; X+ } X+ X+ tmp = oss->format; X+ if (ioctl(oss->fd, SNDCTL_DSP_SETFMT, &tmp) < 0 || X+ tmp != oss->format) { X+ perror("SNDCTL_DSP_SETFMT"); X+ return -EINVAL; X+ } X+ X+ tmp = io->channels; X+ if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &tmp) < 0 || X+ tmp != io->channels) { X+ perror("SNDCTL_DSP_CHANNELS"); X+ return -EINVAL; X+ } X+ X+ tmp = io->rate; X+ if (ioctl(oss->fd, SNDCTL_DSP_SPEED, &tmp) < 0 || X+ tmp > io->rate * 1.01 || tmp < io->rate * 0.99) { X+ perror("SNDCTL_DSP_SPEED"); X+ return -EINVAL; X+ } X+ X+ if (ioctl(oss->fd, (io->stream == SND_PCM_STREAM_PLAYBACK) ? X+ SNDCTL_DSP_GETOSPACE : SNDCTL_DSP_GETISPACE, &bi) < 0) { X+ perror("SNDCTL_DSP_GET[I/O]SPACE"); X+ return -EINVAL; X+ } X+ X+ oss->bufsz = bi.fragsize * bi.fragstotal; X+ X+#ifdef SNDCTL_DSP_LOW_WATER X+ tmp = ((io->period_size * oss->frame_bytes) * 3) / 4; X+ tmp -= tmp % oss->frame_bytes; X+ if (tmp < oss->frame_bytes) X+ tmp = oss->frame_bytes; X+ if (tmp > bi.fragsize) X+ tmp = bi.fragsize; X+ if (ioctl(oss->fd, SNDCTL_DSP_LOW_WATER, &tmp) < 0) X+ perror("SNDCTL_DSP_LOW_WATER"); X+#endif X+ X+#ifdef FREEBSD_OSS_DEBUG_VERBOSE X+ fprintf(stderr, X+ "\n\n[%lu -> %d] %lu ~ %d -> %d, %lu ~ %d -> %d [d:%ld lw:%d]\n\n", X+ io->buffer_size / io->period_size, bi.fragstotal, X+ io->buffer_size * oss->frame_bytes, X+ (1 << blksz_shift) * blkcnt, oss->bufsz, X+ io->period_size * oss->frame_bytes, 1 << blksz_shift, X+ bi.fragsize, X+ (long)(io->buffer_size * oss->frame_bytes) - X+ oss->bufsz, tmp); X+#endif X+#else X period_bytes = io->period_size * oss->frame_bytes; X oss->period_shift = 0; X for (i = 31; i >= 4; i--) { X@@ -209,6 +509,7 @@ X goto _retry; X } X oss->fragment_set = 1; X+#endif X X if ((flags = fcntl(oss->fd, F_GETFL)) < 0) { X err = -errno; X@@ -229,10 +530,128 @@ X return 0; X } X X-#define ARRAY_SIZE(ary) (sizeof(ary)/sizeof(ary[0])) X- X static int oss_hw_constraint(snd_pcm_oss_t *oss) X { X+#ifdef __FreeBSD__ X+ snd_pcm_ioplug_t *io = &oss->io; X+ static const snd_pcm_access_t access_list[] = { X+ SND_PCM_ACCESS_RW_INTERLEAVED, X+ SND_PCM_ACCESS_MMAP_INTERLEAVED X+ }; X+#ifdef FREEBSD_OSS_BLKCNT_P2 X+ unsigned int period_list[30]; X+#endif X+ unsigned int nformats; X+ unsigned int format[ARRAY_SIZE(oss_formats_tab)]; X+#if 0 X+ unsigned int nchannels; X+ unsigned int channel[FREEBSD_OSS_CHANNELS_MAX]; X+#endif X+ int i, err, tmp; X+ X+#ifdef FREEBSD_OSS_DEBUG_VERBOSE X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X+ /* check trigger */ X+ tmp = 0; X+ if (ioctl(oss->fd, SNDCTL_DSP_GETCAPS, &tmp) >= 0) { X+ if (!(tmp & DSP_CAP_TRIGGER)) X+ fprintf(stderr, "*** OSS: trigger is not supported!\n"); X+ } X+ X+ /* access type - interleaved only */ X+ if ((err = snd_pcm_ioplug_set_param_list(io, SND_PCM_IOPLUG_HW_ACCESS, X+ ARRAY_SIZE(access_list), access_list)) < 0) X+ return err; X+ X+ /* supported formats. */ X+ tmp = 0; X+ ioctl(oss->fd, SNDCTL_DSP_GETFMTS, &tmp); X+ nformats = 0; X+ for (i = 0; i < ARRAY_SIZE(oss_formats_tab); i++) { X+ if (tmp & oss_formats_tab[i].oss_format) X+ format[nformats++] = oss_formats_tab[i].alsa_format; X+ } X+ if (! nformats) X+ format[nformats++] = SND_PCM_FORMAT_S16; X+ if ((err = snd_pcm_ioplug_set_param_list(io, SND_PCM_IOPLUG_HW_FORMAT, X+ nformats, format)) < 0) X+ return err; X+ X+#if 0 X+ /* supported channels */ X+ nchannels = 0; X+ for (i = 0; i < ARRAY_SIZE(channel); i++) { X+ tmp = i + 1; X+ if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &tmp) >= 0 && X+ 1 + i == tmp) X+ channel[nchannels++] = tmp; X+ } X+ if (! nchannels) /* assume 2ch stereo */ X+ err = snd_pcm_ioplug_set_param_minmax(io, X+ SND_PCM_IOPLUG_HW_CHANNELS, 2, 2); X+ else X+ err = snd_pcm_ioplug_set_param_list(io, X+ SND_PCM_IOPLUG_HW_CHANNELS, nchannels, channel); X+ if (err < 0) X+ return err; X+#endif X+ err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_CHANNELS, X+ FREEBSD_OSS_CHANNELS_MIN, FREEBSD_OSS_CHANNELS_MAX); X+ if (err < 0) X+ return err; X+ X+ /* supported rates */ X+ err = snd_pcm_ioplug_set_param_minmax(io, SND_PCM_IOPLUG_HW_RATE, X+ FREEBSD_OSS_RATE_MIN, FREEBSD_OSS_RATE_MAX); X+ if (err < 0) X+ return err; X+ X+ /* X+ * Maximum buffer size on FreeBSD can go up to 131072 bytes without X+ * strict ^2 alignment so that s24le in 3bytes packing can be fed X+ * directly. X+ */ X+ X+#ifdef FREEBSD_OSS_BLKCNT_P2 X+ tmp = 0; X+ for (i = 1; i < 31 && tmp < ARRAY_SIZE(period_list); i++) { X+ if ((1 << i) > FREEBSD_OSS_BLKCNT_MAX) X+ break; X+ if ((1 << i) < FREEBSD_OSS_BLKCNT_MIN) X+ continue; X+ period_list[tmp++] = 1 << i; X+ } X+ X+ if (tmp > 0) X+ err = snd_pcm_ioplug_set_param_list(io, X+ SND_PCM_IOPLUG_HW_PERIODS, tmp, period_list); X+ else X+#endif X+ /* periods , not strictly ^2 but later on will be refined */ X+ err = snd_pcm_ioplug_set_param_minmax(io, X+ SND_PCM_IOPLUG_HW_PERIODS, FREEBSD_OSS_BLKCNT_MIN, X+ FREEBSD_OSS_BLKCNT_MAX); X+ if (err < 0) X+ return err; X+ X+ /* period size , not strictly ^2 */ X+ err = snd_pcm_ioplug_set_param_minmax(io, X+ SND_PCM_IOPLUG_HW_PERIOD_BYTES, FREEBSD_OSS_BLKSZ_MIN, X+ FREEBSD_OSS_BLKSZ_MAX); X+ if (err < 0) X+ return err; X+ X+ /* buffer size , not strictly ^2 */ X+ err = snd_pcm_ioplug_set_param_minmax(io, X+ SND_PCM_IOPLUG_HW_BUFFER_BYTES, FREEBSD_OSS_BUFSZ_MIN, X+ FREEBSD_OSS_BUFSZ_MAX); X+ if (err < 0) X+ return err; X+ X+ return 0; X+#else X snd_pcm_ioplug_t *io = &oss->io; X static const snd_pcm_access_t access_list[] = { X SND_PCM_ACCESS_RW_INTERLEAVED, X@@ -317,6 +736,7 @@ X return err; X X return 0; X+#endif X } X X X@@ -324,6 +744,10 @@ X { X snd_pcm_oss_t *oss = io->private_data; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X close(oss->fd); X free(oss->device); X free(oss); X@@ -337,7 +761,9 @@ X .pointer = oss_pointer, X .close = oss_close, X .hw_params = oss_hw_params, X+#ifndef __FreeBSD__ X .prepare = oss_prepare, X+#endif X .drain = oss_drain, X }; X X@@ -348,7 +774,9 @@ X .pointer = oss_pointer, X .close = oss_close, X .hw_params = oss_hw_params, X+#ifndef __FreeBSD__ X .prepare = oss_prepare, X+#endif X .drain = oss_drain, X }; X X@@ -360,6 +788,10 @@ X int err; X snd_pcm_oss_t *oss; X X+#if defined(__FreeBSD__) && defined(FREEBSD_OSS_DEBUG_VERBOSE) X+ fprintf(stderr, "%s()\n", __func__); X+#endif X+ X snd_config_for_each(i, next, conf) { X snd_config_t *n = snd_config_iterator_entry(i); X const char *id; 753829a8e6934e242f5369f19b603c4e echo x - alsa-plugins/distinfo sed 's/^X//' >alsa-plugins/distinfo << '59a11c0c6ddff0a5a41c5507cf313174' XMD5 (alsa-plugins-1.0.23.tar.bz2) = a671f8102366c5b388133e948e1c85cb XSHA256 (alsa-plugins-1.0.23.tar.bz2) = 5c1b2791ad33ef01f0f4f040004c931310da05e45aaa8d4146024c586f2b3183 XSIZE (alsa-plugins-1.0.23.tar.bz2) = 326504 59a11c0c6ddff0a5a41c5507cf313174 echo x - alsa-plugins/Makefile sed 's/^X//' >alsa-plugins/Makefile << 'e0ef385a1e116acd8e0edb2fac87c6fd' X# New ports collection makefile for: alsa-plugins X# Date created: June 29, 2009 X# Whom: Aragon Gouveia <aragon@phat.za.net> X# X XPORTNAME= alsa-plugins XPORTVERSION= 1.0.23 XCATEGORIES= audio XMASTER_SITES= ftp://ftp.silug.org/pub/alsa/plugins/ \ X ftp://gd.tuwien.ac.at/opsys/linux/alsa/plugins/ \ X http://dl.ambiweb.de/mirrors/ftp.alsa-project.org/plugins/ \ X ftp://ftp.alsa-project.org/pub/plugins/ XMAINTAINER= aragon@phat.za.net XCOMMENT= ALSA compatibility library plugins X XLIB_DEPENDS= asound.2:${PORTSDIR}/audio/alsa-lib XUSE_BZIP2= yes XHAS_CONFIGURE= yes XGNU_CONFIGURE= yes XCONFIGURE_ARGS+= --disable-jack --disable-pulseaudio --disable-samplerate XCONFIGURE_ENV= LDFLAGS="-L${LOCALBASE}/lib" X X.include <bsd.port.mk> e0ef385a1e116acd8e0edb2fac87c6fd echo x - alsa-plugins/pkg-descr sed 's/^X//' >alsa-plugins/pkg-descr << '93cdb243870e8be952766505df17950e' XThe Advanced Linux Sound Architecture (ALSA) plugins X XWWW: http://www.alsa-project.org/ 93cdb243870e8be952766505df17950e echo x - alsa-plugins/pkg-plist sed 's/^X//' >alsa-plugins/pkg-plist << '575b96e4e6217b56a46f302b48157452' Xlib/alsa-lib/libasound_module_ctl_oss.so Xlib/alsa-lib/libasound_module_ctl_oss.la Xlib/alsa-lib/libasound_module_pcm_oss.so Xlib/alsa-lib/libasound_module_pcm_oss.la Xlib/alsa-lib/libasound_module_pcm_upmix.so Xlib/alsa-lib/libasound_module_pcm_upmix.la Xlib/alsa-lib/libasound_module_pcm_vdownmix.so Xlib/alsa-lib/libasound_module_pcm_vdownmix.la Xlib/alsa-lib/libasound_module_rate_speexrate_best.so Xlib/alsa-lib/libasound_module_rate_speexrate_medium.so Xlib/alsa-lib/libasound_module_rate_speexrate.so Xlib/alsa-lib/libasound_module_rate_speexrate.la Xlib/alsa-lib/libasound_module_pcm_speex.so Xlib/alsa-lib/libasound_module_pcm_speex.la X@dirrm lib/alsa-lib 575b96e4e6217b56a46f302b48157452 exit --- alsa-plugins.shar ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100423033113.992C73D0C8>