From 00133c99c214dfe2159c4b9347a782dd3eda8046 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 13 Feb 2014 15:36:57 +0100 Subject: ausrc/auplay api: change to 16-bit samples --- modules/coreaudio/player.c | 5 +---- modules/coreaudio/recorder.c | 23 +---------------------- 2 files changed, 2 insertions(+), 26 deletions(-) (limited to 'modules/coreaudio') diff --git a/modules/coreaudio/player.c b/modules/coreaudio/player.c index 1243450..fc53b8c 100644 --- a/modules/coreaudio/player.c +++ b/modules/coreaudio/player.c @@ -72,10 +72,7 @@ static void play_handler(void *userData, AudioQueueRef outQ, if (!wh) return; - if (!wh(outQB->mAudioData, outQB->mAudioDataByteSize, arg)) { - /* Set the buffer to silence */ - memset(outQB->mAudioData, 0, outQB->mAudioDataByteSize); - } + wh(outQB->mAudioData, outQB->mAudioDataByteSize/2, arg); AudioQueueEnqueueBuffer(outQ, outQB, 0, NULL); } diff --git a/modules/coreaudio/recorder.c b/modules/coreaudio/recorder.c index 57f2390..40156fa 100644 --- a/modules/coreaudio/recorder.c +++ b/modules/coreaudio/recorder.c @@ -20,7 +20,6 @@ struct ausrc_st { AudioQueueRef queue; AudioQueueBufferRef buf[BUFC]; pthread_mutex_t mutex; - struct mbuf *mb; ausrc_read_h *rh; void *arg; unsigned int ptime; @@ -49,7 +48,6 @@ static void ausrc_destructor(void *arg) AudioQueueDispose(st->queue, true); } - mem_deref(st->mb); mem_deref(st->as); pthread_mutex_destroy(&st->mutex); @@ -63,10 +61,8 @@ static void record_handler(void *userData, AudioQueueRef inQ, const AudioStreamPacketDescription *inPacketDesc) { struct ausrc_st *st = userData; - struct mbuf *mb = st->mb; unsigned int ptime; ausrc_read_h *rh; - size_t sz, sp; void *arg; (void)inStartTime; (void)inNumPackets; @@ -81,18 +77,7 @@ static void record_handler(void *userData, AudioQueueRef inQ, if (!rh) return; - sz = inQB->mAudioDataByteSize; - sp = mbuf_get_space(mb); - - if (sz >= sp) { - mbuf_write_mem(mb, inQB->mAudioData, sp); - rh(mb->buf, (uint32_t)mb->size, arg); - mb->pos = 0; - mbuf_write_mem(mb, (uint8_t *)inQB->mAudioData + sp, sz - sp); - } - else { - mbuf_write_mem(mb, inQB->mAudioData, sz); - } + rh(inQB->mAudioData, inQB->mAudioDataByteSize/2, arg); AudioQueueEnqueueBuffer(inQ, inQB, 0, NULL); @@ -134,12 +119,6 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as, sampc = prm->srate * prm->ch * prm->ptime / 1000; bytc = sampc * 2; - st->mb = mbuf_alloc(bytc); - if (!st->mb) { - err = ENOMEM; - goto out; - } - err = pthread_mutex_init(&st->mutex, NULL); if (err) goto out; -- cgit v1.2.3