Esempio n. 1
0
/*
 * @note This function has REAL-TIME properties
 */
static void poll_aubuf_tx(struct audio *a)
{
	struct autx *tx = &a->tx;
	int16_t *sampv = tx->sampv;
	size_t sampc;
	struct le *le;
	int err = 0;

	sampc = tx->psize / 2;

	/* timed read from audio-buffer */
	aubuf_read_samp(tx->aubuf, tx->sampv, sampc);

	/* optional resampler */
	if (tx->resamp.resample) {
		size_t sampc_rs = AUDIO_SAMPSZ;

		err = auresamp(&tx->resamp,
			       tx->sampv_rs, &sampc_rs,
			       tx->sampv, sampc);
		if (err)
			return;

		sampv = tx->sampv_rs;
		sampc = sampc_rs;
	}

	/* Process exactly one audio-frame in list order */
	for (le = tx->filtl.head; le; le = le->next) {
		struct aufilt_enc_st *st = le->data;

		if (st->af && st->af->ench)
			err |= st->af->ench(st, sampv, &sampc);
	}
	if (err) {
		warning("audio: aufilter encode: %m\n", err);
	}

	/* Encode and send */
	encode_rtp_send(a, tx, sampv, sampc);
}
Esempio n. 2
0
/*
 * @note This function has REAL-TIME properties
 */
static void poll_aubuf_tx(struct audio *a)
{
	size_t sampc = a->tx.psize / 2;
	struct autx *tx = &a->tx;
	int16_t *sampv = tx->sampv;
	struct le *le;
	int err = 0;

	/* timed read from audio-buffer */
	if (aubuf_get_samp(tx->ab, tx->ptime, tx->sampv, sampc))
		return;

	/* optional resampler */
	if (tx->resamp) {
		size_t sampc_rs = AUDIO_SAMPSZ;

		err = auresamp_process(tx->resamp,
				       tx->sampv_rs, &sampc_rs,
				       tx->sampv, sampc);
		if (err)
			return;

		sampv = tx->sampv_rs;
		sampc = sampc_rs;
	}

	/* Process exactly one audio-frame in list order */
	for (le = a->filtl.head; le; le = le->next) {
		struct aufilt_st *st = le->data;

		if (st->af->ench)
			err |= st->af->ench(st, sampv, &sampc);
	}

	/* Encode and send */
	encode_rtp_send(a, tx, sampv, sampc);
}