aboutsummaryrefslogtreecommitdiff
path: root/audio/alsa-plugins
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2019-12-03 04:33:21 +0000
committerJan Beich <jbeich@FreeBSD.org>2019-12-03 04:33:21 +0000
commita185384bd9802516c36f5517a6fdded89a8c9e10 (patch)
tree0c2beda6a9245e333ab53217c2bb08f0bf8a70ba /audio/alsa-plugins
parenta3f26bc3b98f601952ded12dd10dc898bb0cf7e3 (diff)
downloadports-a185384bd9802516c36f5517a6fdded89a8c9e10.tar.gz
ports-a185384bd9802516c36f5517a6fdded89a8c9e10.zip
audio/alsa-plugins: move r505839 to the correct file
files/alsa-plugins.patch contains an assortment of FreeBSD-specific improvements that may not work on alternative OSS implementations. So, restore the ability to exclude the patch for debugging.
Notes
Notes: svn path=/head/; revision=518907
Diffstat (limited to 'audio/alsa-plugins')
-rw-r--r--audio/alsa-plugins/files/alsa-plugins.patch113
-rw-r--r--audio/alsa-plugins/files/patch-oss_pcm__oss.c137
2 files changed, 88 insertions, 162 deletions
diff --git a/audio/alsa-plugins/files/alsa-plugins.patch b/audio/alsa-plugins/files/alsa-plugins.patch
index 42b5c3219dd3..a2fb552327e5 100644
--- a/audio/alsa-plugins/files/alsa-plugins.patch
+++ b/audio/alsa-plugins/files/alsa-plugins.patch
@@ -82,30 +82,50 @@
unsigned int frame_bytes;
} snd_pcm_oss_t;
-@@ -49,8 +73,13 @@ static snd_pcm_sframes_t oss_write(snd_pcm_ioplug_t *i
+@@ -49,8 +73,21 @@ static snd_pcm_sframes_t oss_write(snd_pcm_ioplug_t *i
buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8;
size *= oss->frame_bytes;
result = write(oss->fd, buf, size);
+- if (result <= 0)
+- return result;
+#ifdef __FreeBSD__
-+ if (result == -1)
-+ return -errno;
++ if (result == -1) {
++ if (errno == EAGAIN)
++ return 0;
++ else
++ return -errno;
++ }
+#else
- if (result <= 0)
- return result;
++ if (result <= 0) {
++ if (result == -EAGAIN)
++ return 0;
++ else
++ return result;
++ }
+#endif
return result / oss->frame_bytes;
}
-@@ -67,14 +96,80 @@ static snd_pcm_sframes_t oss_read(snd_pcm_ioplug_t *io
+@@ -67,14 +104,88 @@ static snd_pcm_sframes_t oss_read(snd_pcm_ioplug_t *io
buf = (char *)areas->addr + (areas->first + areas->step * offset) / 8;
size *= oss->frame_bytes;
result = read(oss->fd, buf, size);
+- if (result <= 0)
+- return result;
+#ifdef __FreeBSD__
-+ if (result == -1)
-+ return -errno;
++ if (result == -1) {
++ if (errno == EAGAIN)
++ return 0;
++ else
++ return -errno;
++ }
+#else
- if (result <= 0)
- return result;
++ if (result <= 0) {
++ if (result == -EAGAIN)
++ return 0;
++ else
++ return result;
++ }
+#endif
return result / oss->frame_bytes;
}
@@ -177,7 +197,7 @@
struct count_info info;
int ptr;
-@@ -85,20 +180,59 @@ static snd_pcm_sframes_t oss_pointer(snd_pcm_ioplug_t
+@@ -85,20 +196,59 @@ static snd_pcm_sframes_t oss_pointer(snd_pcm_ioplug_t
}
ptr = snd_pcm_bytes_to_frames(io->pcm, info.ptr);
return ptr;
@@ -237,7 +257,7 @@
return 0;
}
-@@ -107,6 +241,10 @@ static int oss_stop(snd_pcm_ioplug_t *io)
+@@ -107,6 +257,10 @@ static int oss_stop(snd_pcm_ioplug_t *io)
snd_pcm_oss_t *oss = io->private_data;
int tmp = 0;
@@ -248,7 +268,7 @@
ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &tmp);
return 0;
}
-@@ -115,16 +253,25 @@ static int oss_drain(snd_pcm_ioplug_t *io)
+@@ -115,16 +269,44 @@ static int oss_drain(snd_pcm_ioplug_t *io)
{
snd_pcm_oss_t *oss = io->private_data;
@@ -261,6 +281,25 @@
return 0;
}
++static int oss_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp)
++{
++ snd_pcm_oss_t *oss = io->private_data;
++ int tmp;
++
++ if (oss->fd < 0)
++ return -EBADFD;
++
++ if (io->stream == SND_PCM_STREAM_PLAYBACK) {
++ if (ioctl(oss->fd, SNDCTL_DSP_GETODELAY, &tmp) < 0 || tmp < 0)
++ tmp = 0;
++ } else {
++ tmp = 0;
++ }
++ *delayp = snd_pcm_bytes_to_frames(io->pcm, tmp);
++
++ return (0);
++}
++
+#ifndef __FreeBSD__
static int oss_prepare(snd_pcm_ioplug_t *io)
{
@@ -274,7 +313,7 @@
ioctl(oss->fd, SNDCTL_DSP_RESET);
tmp = io->channels;
-@@ -145,16 +292,75 @@ static int oss_prepare(snd_pcm_ioplug_t *io)
+@@ -145,16 +327,75 @@ static int oss_prepare(snd_pcm_ioplug_t *io)
}
return 0;
}
@@ -350,7 +389,7 @@
switch (io->format) {
case SND_PCM_FORMAT_U8:
oss->format = AFMT_U8;
-@@ -166,9 +372,87 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
+@@ -166,9 +407,93 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
oss->format = AFMT_S16_BE;
break;
default:
@@ -362,20 +401,26 @@
+
+ ioctl(oss->fd, SNDCTL_DSP_RESET);
+
-+#define blksz_aligned() ((1 << blksz_shift) - \
-+ ((1 << blksz_shift) % oss->frame_bytes))
-+ blksz_shift = 16;
-+ tmp = io->period_size * oss->frame_bytes;
++ /* use a 16ms HW buffer by default */
++ tmp = ((16 * io->rate) / 1000) * oss->frame_bytes;
+
-+ while (blksz_shift > 4 && blksz_aligned() > tmp)
-+ blksz_shift--;
++ /* round up to nearest power of two */
++ while (tmp & (tmp - 1))
++ tmp += tmp & ~(tmp - 1);
++
++ /* get logarithmic value */
++ for (blksz_shift = 0; blksz_shift < 24; blksz_shift++) {
++ if (tmp == (1 << blksz_shift))
++ break;
++ }
+
-+ blkcnt = 2;
+ tmp = io->buffer_size * oss->frame_bytes;
+
-+ while (blkcnt < 4096 && (blksz_aligned() * blkcnt) < tmp &&
-+ ((1 << blksz_shift) * blkcnt) < 131072)
-+ blkcnt <<= 1;
++ /* compute HW buffer big enough to hold SW buffer */
++ for (blkcnt = FREEBSD_OSS_BLKCNT_MIN; blkcnt != FREEBSD_OSS_BLKCNT_MAX; blkcnt *= 2) {
++ if ((blkcnt << blksz_shift) >= tmp)
++ break;
++ }
+
+ tmp = blksz_shift | (blkcnt << 16);
+ if (ioctl(oss->fd, SNDCTL_DSP_SETFRAGMENT, &tmp) < 0) {
@@ -438,7 +483,7 @@
period_bytes = io->period_size * oss->frame_bytes;
oss->period_shift = 0;
for (i = 31; i >= 4; i--) {
-@@ -209,6 +493,7 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
+@@ -209,6 +534,7 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
goto _retry;
}
oss->fragment_set = 1;
@@ -446,7 +491,7 @@
if ((flags = fcntl(oss->fd, F_GETFL)) < 0) {
err = -errno;
-@@ -229,16 +514,152 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
+@@ -229,16 +555,152 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
return 0;
}
@@ -601,7 +646,7 @@
unsigned int format[5];
unsigned int nchannels;
unsigned int channel[6];
-@@ -317,6 +738,7 @@ static int oss_hw_constraint(snd_pcm_oss_t *oss)
+@@ -317,6 +779,7 @@ static int oss_hw_constraint(snd_pcm_oss_t *oss)
return err;
return 0;
@@ -609,7 +654,7 @@
}
-@@ -324,6 +746,10 @@ static int oss_close(snd_pcm_ioplug_t *io)
+@@ -324,6 +787,10 @@ static int oss_close(snd_pcm_ioplug_t *io)
{
snd_pcm_oss_t *oss = io->private_data;
@@ -620,7 +665,7 @@
close(oss->fd);
free(oss->device);
free(oss);
-@@ -337,7 +763,9 @@ static const snd_pcm_ioplug_callback_t oss_playback_ca
+@@ -337,8 +804,11 @@ static const snd_pcm_ioplug_callback_t oss_playback_ca
.pointer = oss_pointer,
.close = oss_close,
.hw_params = oss_hw_params,
@@ -628,9 +673,11 @@
.prepare = oss_prepare,
+#endif
.drain = oss_drain,
++ .delay = oss_delay,
};
-@@ -348,7 +776,9 @@ static const snd_pcm_ioplug_callback_t oss_capture_cal
+ static const snd_pcm_ioplug_callback_t oss_capture_callback = {
+@@ -348,8 +818,11 @@ static const snd_pcm_ioplug_callback_t oss_capture_cal
.pointer = oss_pointer,
.close = oss_close,
.hw_params = oss_hw_params,
@@ -638,9 +685,11 @@
.prepare = oss_prepare,
+#endif
.drain = oss_drain,
++ .delay = oss_delay,
};
-@@ -360,6 +790,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(oss)
+
+@@ -360,6 +833,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(oss)
int err;
snd_pcm_oss_t *oss;
diff --git a/audio/alsa-plugins/files/patch-oss_pcm__oss.c b/audio/alsa-plugins/files/patch-oss_pcm__oss.c
index 27a8c9336a7d..ff8cf7fe225e 100644
--- a/audio/alsa-plugins/files/patch-oss_pcm__oss.c
+++ b/audio/alsa-plugins/files/patch-oss_pcm__oss.c
@@ -10,58 +10,10 @@
+#include <sys/soundcard.h>
+#endif
- #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
-
-@@ -74,11 +78,19 @@ static snd_pcm_sframes_t oss_write(snd_pcm_ioplug_t *i
- size *= oss->frame_bytes;
- result = write(oss->fd, buf, size);
- #ifdef __FreeBSD__
-- if (result == -1)
-- return -errno;
-+ if (result == -1) {
-+ if (errno == EAGAIN)
-+ return 0;
-+ else
-+ return -errno;
-+ }
- #else
-- if (result <= 0)
-- return result;
-+ if (result <= 0) {
-+ if (result == -EAGAIN)
-+ return 0;
-+ else
-+ return result;
-+ }
- #endif
- return result / oss->frame_bytes;
- }
-@@ -97,11 +109,19 @@ static snd_pcm_sframes_t oss_read(snd_pcm_ioplug_t *io
- size *= oss->frame_bytes;
- result = read(oss->fd, buf, size);
- #ifdef __FreeBSD__
-- if (result == -1)
-- return -errno;
-+ if (result == -1) {
-+ if (errno == EAGAIN)
-+ return 0;
-+ else
-+ return -errno;
-+ }
- #else
-- if (result <= 0)
-- return result;
-+ if (result <= 0) {
-+ if (result == -EAGAIN)
-+ return 0;
-+ else
-+ return result;
-+ }
- #endif
- return result / oss->frame_bytes;
- }
-@@ -258,10 +278,29 @@ static int oss_drain(snd_pcm_ioplug_t *io)
- #endif
+ typedef struct snd_pcm_oss {
+ snd_pcm_ioplug_t io;
+@@ -116,7 +120,7 @@ static int oss_drain(snd_pcm_ioplug_t *io)
+ snd_pcm_oss_t *oss = io->private_data;
if (io->stream == SND_PCM_STREAM_PLAYBACK)
- ioctl(oss->fd, SNDCTL_DSP_SYNC);
@@ -69,87 +21,12 @@
return 0;
}
-+static int oss_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp)
-+{
-+ snd_pcm_oss_t *oss = io->private_data;
-+ int tmp;
-+
-+ if (oss->fd < 0)
-+ return -EBADFD;
-+
-+ if (io->stream == SND_PCM_STREAM_PLAYBACK) {
-+ if (ioctl(oss->fd, SNDCTL_DSP_GETODELAY, &tmp) < 0 || tmp < 0)
-+ tmp = 0;
-+ } else {
-+ tmp = 0;
-+ }
-+ *delayp = snd_pcm_bytes_to_frames(io->pcm, tmp);
-+
-+ return (0);
-+}
-+
- #ifndef __FreeBSD__
- static int oss_prepare(snd_pcm_ioplug_t *io)
- {
-@@ -272,7 +311,7 @@ static int oss_prepare(snd_pcm_ioplug_t *io)
- fprintf(stderr, "%s()\n", __func__);
- #endif
+@@ -125,7 +129,7 @@ static int oss_prepare(snd_pcm_ioplug_t *io)
+ snd_pcm_oss_t *oss = io->private_data;
+ int tmp;
- ioctl(oss->fd, SNDCTL_DSP_RESET);
+ ioctl(oss->fd, SNDCTL_DSP_RESET, NULL);
tmp = io->channels;
if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &tmp) < 0) {
-@@ -380,20 +419,26 @@ static int oss_hw_params(snd_pcm_ioplug_t *io,
-
- ioctl(oss->fd, SNDCTL_DSP_RESET);
-
--#define blksz_aligned() ((1 << blksz_shift) - \
-- ((1 << blksz_shift) % oss->frame_bytes))
-- blksz_shift = 16;
-- tmp = io->period_size * oss->frame_bytes;
-+ /* use a 16ms HW buffer by default */
-+ tmp = ((16 * io->rate) / 1000) * oss->frame_bytes;
-
-- while (blksz_shift > 4 && blksz_aligned() > tmp)
-- blksz_shift--;
-+ /* round up to nearest power of two */
-+ while (tmp & (tmp - 1))
-+ tmp += tmp & ~(tmp - 1);
-
-- blkcnt = 2;
-+ /* get logarithmic value */
-+ for (blksz_shift = 0; blksz_shift < 24; blksz_shift++) {
-+ if (tmp == (1 << blksz_shift))
-+ break;
-+ }
-+
- tmp = io->buffer_size * oss->frame_bytes;
-
-- while (blkcnt < 4096 && (blksz_aligned() * blkcnt) < tmp &&
-- ((1 << blksz_shift) * blkcnt) < 131072)
-- blkcnt <<= 1;
-+ /* compute HW buffer big enough to hold SW buffer */
-+ for (blkcnt = FREEBSD_OSS_BLKCNT_MIN; blkcnt != FREEBSD_OSS_BLKCNT_MAX; blkcnt *= 2) {
-+ if ((blkcnt << blksz_shift) >= tmp)
-+ break;
-+ }
-
- tmp = blksz_shift | (blkcnt << 16);
- if (ioctl(oss->fd, SNDCTL_DSP_SETFRAGMENT, &tmp) < 0) {
-@@ -767,6 +812,7 @@ static const snd_pcm_ioplug_callback_t oss_playback_ca
- .prepare = oss_prepare,
- #endif
- .drain = oss_drain,
-+ .delay = oss_delay,
- };
-
- static const snd_pcm_ioplug_callback_t oss_capture_callback = {
-@@ -780,6 +826,7 @@ static const snd_pcm_ioplug_callback_t oss_capture_cal
- .prepare = oss_prepare,
- #endif
- .drain = oss_drain,
-+ .delay = oss_delay,
- };
-
-