Esempio n. 1
0
/**
 * Write samples to Audio Player.
 *
 * @note This function has REAL-TIME properties
 *
 * @note The application is responsible for filling in silence in
 *       the case of underrun
 *
 * @note This function may be called from any thread
 *
 * @return true for valid audio samples, false for silence
 */
static bool auplay_write_handler(uint8_t *buf, size_t sz, void *arg)
{
	struct aurx *rx = arg;

	aubuf_read(rx->ab, buf, sz);

	return true;
}
Esempio n. 2
0
static void write_handler(void *sampv, size_t sampc, void *arg)
{
	struct audio_loop *al = arg;
	size_t num_bytes = sampc * aufmt_sample_size(al->fmt);

	al->n_write += sampc;

	/* read from beginning */
	aubuf_read(al->aubuf, sampv, num_bytes);
}
Esempio n. 3
0
static bool write_handler(uint8_t *buf, size_t sz, void *arg)
{
	struct audio_loop *al = arg;

	++al->n_write;

	/* read from beginning */
	if (al->ac) {
		(void)codec_read(al, buf, sz);
	}
	else {
		aubuf_read(al->ab, buf, sz);
	}

	return true;
}
Esempio n. 4
0
static void *play_thread(void *arg)
{
	uint64_t now, ts = tmr_jiffies();
	struct ausrc_st *st = arg;
	void *sampv;
	size_t num_bytes = st->sampc * st->sampsz;

	sampv = mem_alloc(num_bytes, NULL);
	if (!sampv)
		return NULL;

	while (st->run) {

		sys_msleep(4);

		now = tmr_jiffies();

		if (ts > now)
			continue;
#if 1
		if (now > ts + 100) {
			debug("rst: cpu lagging behind (%u ms)\n",
			      now - ts);
		}
#endif

		aubuf_read(st->aubuf, sampv, num_bytes);

		st->rh(sampv, st->sampc, st->arg);

		ts += st->ptime;
	}

	mem_deref(sampv);

	return NULL;
}