示例#1
0
/**
 * Read samples from Audio Source
 *
 * @note This function has REAL-TIME properties
 *
 * @note This function may be called from any thread
 *
 * @param buf Buffer with audio samples
 * @param sz  Number of bytes in buffer
 * @param arg Handler argument
 */
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 *)sampv, 0, sampc*2);

	(void)aubuf_write_samp(tx->aubuf, sampv, sampc);

	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);
}
示例#2
0
/**
 * Read samples from Audio Source
 *
 * @note This function has REAL-TIME properties
 *
 * @note This function may be called from any thread
 */
static void ausrc_read_handler(const uint8_t *buf, size_t sz, void *arg)
{
	struct audio *a = arg;
	struct autx *tx = &a->tx;
	uint8_t *silence = NULL;
	const uint8_t *txbuf = buf;

	/* NOTE:
	 * some devices behave strangely if they receive no RTP,
	 * so we send silence when muted
	 */
	if (tx->muted) {
		silence = mem_zalloc(sizeof(*silence) * sz, NULL);
		txbuf = silence;
	}

	if (tx->ab) {
		if (aubuf_write(tx->ab, txbuf, sz))
			goto out;

		/* XXX: on limited CPU and specifically coreaudio module
		 * calling this procedure, which results in audio encoding,
		 * seems to have an overall negative impact on system
		 * performance! (coming from interrupt context?)
		 */
		if (a->cfg.txmode == AUDIO_MODE_POLL)
			poll_aubuf_tx(a);
	}

 out:
	/* Exact timing: send Telephony-Events from here */
	check_telev(a, tx);
	mem_deref(silence);
}
示例#3
0
文件: audio.c 项目: soramimi/qSIP
/**
 * Read samples from Audio Source
 *
 * @note This function has REAL-TIME properties
 *
 * @note This function may be called from any thread
 */
static void ausrc_read_handler(const uint8_t *buf, size_t sz, void *arg)
{
	struct audio *a = arg;
	struct autx *tx = &a->tx;

	if (tx->muted) {
		memset((void *)buf, 0, sz);
	}

	aubuf_write(tx->ab, buf, sz);

	if (a->cfg.txmode == AUDIO_MODE_POLL) {
		poll_aubuf_tx(a);
	}

	/* Exact timing: send Telephony-Events from here */
	check_telev(a, tx);
}