summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-02-13 15:36:57 +0100
committerAlfred E. Heggestad <aeh@db.org>2014-02-13 15:36:57 +0100
commit00133c99c214dfe2159c4b9347a782dd3eda8046 (patch)
treeac0b301f7e2814fbdc47772e04d94b93768dd76c /src
parente4d71aca3cc153bbac505dac430b3b5574f15016 (diff)
ausrc/auplay api: change to 16-bit samples
Diffstat (limited to 'src')
-rw-r--r--src/audio.c30
-rw-r--r--src/play.c14
2 files changed, 24 insertions, 20 deletions
diff --git a/src/audio.c b/src/audio.c
index dd43b0a..a3f2600 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -349,8 +349,7 @@ static void poll_aubuf_tx(struct audio *a)
sampc = tx->psize / 2;
/* timed read from audio-buffer */
- if (aubuf_get_samp(tx->aubuf, tx->ptime, tx->sampv, sampc))
- return;
+ aubuf_read_samp(tx->aubuf, tx->sampv, sampc);
/* optional resampler */
if (tx->resamp.resample) {
@@ -422,16 +421,12 @@ static void check_telev(struct audio *a, struct autx *tx)
* @param buf Buffer to fill with audio samples
* @param sz Number of bytes in buffer
* @param arg Handler argument
- *
- * @return true for valid audio samples, false for silence
*/
-static bool auplay_write_handler(uint8_t *buf, size_t sz, void *arg)
+static void auplay_write_handler(int16_t *sampv, size_t sampc, void *arg)
{
struct aurx *rx = arg;
- aubuf_read(rx->aubuf, buf, sz);
-
- return true;
+ aubuf_read_samp(rx->aubuf, sampv, sampc);
}
@@ -446,18 +441,27 @@ static bool auplay_write_handler(uint8_t *buf, size_t sz, void *arg)
* @param sz Number of bytes in buffer
* @param arg Handler argument
*/
-static void ausrc_read_handler(const uint8_t *buf, size_t sz, void *arg)
+static void ausrc_read_handler(const int16_t *sampv, size_t sampc, void *arg)
{
struct audio *a = arg;
struct autx *tx = &a->tx;
if (tx->muted)
- memset((void *)buf, 0, sz);
+ memset((void *)sampv, 0, sampc*2);
- (void)aubuf_write(tx->aubuf, buf, sz);
+ (void)aubuf_write_samp(tx->aubuf, sampv, sampc);
- if (a->cfg.txmode == AUDIO_MODE_POLL)
- poll_aubuf_tx(a);
+ if (a->cfg.txmode == AUDIO_MODE_POLL) {
+ unsigned i;
+
+ for (i=0; i<16; i++) {
+
+ if (aubuf_cur_size(tx->aubuf) < tx->psize)
+ break;
+
+ poll_aubuf_tx(a);
+ }
+ }
/* Exact timing: send Telephony-Events from here */
check_telev(a, tx);
diff --git a/src/play.c b/src/play.c
index 9fceecf..c2faa7b 100644
--- a/src/play.c
+++ b/src/play.c
@@ -83,9 +83,10 @@ static void tmr_polling(void *arg)
/**
* NOTE: DSP cannot be destroyed inside handler
*/
-static bool write_handler(uint8_t *buf, size_t sz, void *arg)
+static void write_handler(int16_t *sampv, size_t sampc, void *arg)
{
struct play *play = arg;
+ size_t sz = sampc * 2;
lock_write_get(play->lock);
@@ -94,22 +95,21 @@ static bool write_handler(uint8_t *buf, size_t sz, void *arg)
if (mbuf_get_left(play->mb) < sz) {
- memset(buf, 0, sz);
- (void)mbuf_read_mem(play->mb, buf, mbuf_get_left(play->mb));
+ memset(sampv, 0, sz);
+ (void)mbuf_read_mem(play->mb, (void *)sampv,
+ mbuf_get_left(play->mb));
play->eof = true;
}
else {
- (void)mbuf_read_mem(play->mb, buf, sz);
+ (void)mbuf_read_mem(play->mb, (void *)sampv, sz);
}
silence:
if (play->eof)
- memset(buf, 0, sz);
+ memset(sampv, 0, sz);
lock_rel(play->lock);
-
- return true;
}