summaryrefslogtreecommitdiff
path: root/modules/opensles/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/opensles/player.c')
-rw-r--r--modules/opensles/player.c16
1 files changed, 13 insertions, 3 deletions
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;