summaryrefslogtreecommitdiff
path: root/modules/oss/oss.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/oss/oss.c')
-rw-r--r--modules/oss/oss.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/modules/oss/oss.c b/modules/oss/oss.c
index f0644e2..38d34f3 100644
--- a/modules/oss/oss.c
+++ b/modules/oss/oss.c
@@ -23,7 +23,8 @@
struct ausrc_st {
struct ausrc *as; /* inheritance */
int fd;
- struct mbuf *mb;
+ int16_t *sampv;
+ size_t sampc;
ausrc_read_h *rh;
ausrc_error_h *errh;
void *arg;
@@ -153,7 +154,7 @@ static void ausrc_destructor(void *arg)
(void)close(st->fd);
}
- mem_deref(st->mb);
+ mem_deref(st->sampv);
mem_deref(st->as);
}
@@ -161,22 +162,14 @@ static void ausrc_destructor(void *arg)
static void read_handler(int flags, void *arg)
{
struct ausrc_st *st = arg;
- struct mbuf *mb = st->mb;
int n;
(void)flags;
- n = read(st->fd, mbuf_buf(mb), mbuf_get_space(mb));
+ n = read(st->fd, st->sampv, st->sampc*2);
if (n <= 0)
return;
- mb->pos += n;
-
- if (mb->pos < mb->size)
- return;
-
- st->rh(mb->buf, mb->size, st->arg);
-
- mb->pos = 0;
+ st->rh(st->sampv, n/2, st->arg);
}
@@ -206,7 +199,6 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
{
struct ausrc_st *st;
- unsigned sampc;
int err;
(void)ctx;
@@ -227,10 +219,10 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!device)
device = oss_dev;
- sampc = prm->srate * prm->ch * prm->ptime / 1000;
+ st->sampc = prm->srate * prm->ch * prm->ptime / 1000;
- st->mb = mbuf_alloc(2 * sampc);
- if (!st->mb) {
+ st->sampv = mem_alloc(2 * st->sampc, NULL);
+ if (!st->sampv) {
err = ENOMEM;
goto out;
}
@@ -245,7 +237,7 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (err)
goto out;
- err = oss_reset(st->fd, prm->srate, prm->ch, sampc, 1);
+ err = oss_reset(st->fd, prm->srate, prm->ch, st->sampc, 1);
if (err)
goto out;
@@ -296,7 +288,7 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap,
goto out;
}
- err = oss_reset(st->fd, prm->srate, prm->ch, sampc, 0);
+ err = oss_reset(st->fd, prm->srate, prm->ch, st->sampc, 0);
if (err)
goto out;