From 2f701685d7230b39ce2e0f8ad230ee84bc156595 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 13 Feb 2014 16:25:11 +0100 Subject: update audio-driver modules with new ausrc/play API --- modules/opensles/player.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'modules/opensles/player.c') diff --git a/modules/opensles/player.c b/modules/opensles/player.c index a317e5d..b9c9b68 100644 --- a/modules/opensles/player.c +++ b/modules/opensles/player.c @@ -17,7 +17,8 @@ struct auplay_st { struct auplay *ap; /* inheritance */ - int16_t buf[160 * 2]; + int16_t *sampv; + size_t sampc; auplay_write_h *wh; void *arg; @@ -38,6 +39,7 @@ static void auplay_destructor(void *arg) if (st->outputMixObject != NULL) (*st->outputMixObject)->Destroy(st->outputMixObject); + mem_deref(st->sampv); mem_deref(st->ap); } @@ -46,9 +48,9 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) { struct auplay_st *st = context; - st->wh((void *)st->buf, sizeof(st->buf), st->arg); + st->wh(st->sampv, st->sampc, st->arg); - (*st->BufferQueue)->Enqueue(bq, st->buf, sizeof(st->buf)); + (*st->BufferQueue)->Enqueue(bq, st->sampv, st->sampc * 2); } @@ -151,6 +153,14 @@ int opensles_player_alloc(struct auplay_st **stp, struct auplay *ap, st->wh = wh; st->arg = arg; + st->sampc = prm->srate * prm->ch * prm->ptime / 1000; + + st->sampv = mem_alloc(2 * st->sampc, NULL); + if (!st->sampv) { + err = ENOMEM; + goto out; + } + err = createOutput(st); if (err) goto out; -- cgit v1.2.3