Exemple #1
0
int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as,
		      struct media_ctx **ctx,
		      struct ausrc_prm *prm, const char *device,
		      ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
{
	struct ausrc_st *st;
	int err;

	(void)ctx;
	(void)errh;

	if (!stp || !as || !prm)
		return EINVAL;

	st = mem_zalloc(sizeof(*st), ausrc_destructor);
	if (!st)
		return ENOMEM;

	st->as  = mem_ref(as);
	st->rh  = rh;
	st->arg = arg;

	err = read_stream_open(st, prm, find_dev(device));

	if (err)
		mem_deref(st);
	else
		*stp = st;

	return err;
}
Exemple #2
0
int sinwave_src_alloc(struct ausrc_st **stp, const struct ausrc *as,
		      struct media_ctx **ctx,
		      struct ausrc_prm *prm, const char *device,
		      ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
{
	struct ausrc_st *st;
	int err;

	(void)ctx;
	(void)errh;

	if (!stp || !as || !prm)
		return EINVAL;

	st = mem_zalloc(sizeof(*st), ausrc_destructor);
	if (!st)
		return ENOMEM;

	st->as  = as;
	st->rh  = rh;
	st->arg = arg;

	st->srate = prm->srate;
	st->ptime = prm->ptime;
	st->sampc = prm->srate * prm->ch * prm->ptime / 1000;
	
	// Initialize Wave Generator
	st->gen.amplitude   = 0.2f;
	st->gen.Hz          = 440.0f;
	st->gen.sample_rate = (float) prm->srate; //(float)(prm->srate * prm->ch * prm->ptime / 1000);

	err = read_stream_open(st, prm, find_dev(device));
//	st->hThread = CreateThread(NULL, 4096, sin_thread, st, 0, NULL);
//	err = (st->hThread == NULL);

	if (err) {
		mem_deref(st);
		st->rh = false;
	} else
		*stp = st;

	return err;
}
Exemple #3
0
static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
		     struct media_ctx **ctx,
		     struct ausrc_prm *prm, const char *device,
		     ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
{
	struct ausrc_st *st;
	int err;

	(void)ctx;
	(void)device;
	(void)errh;

	if (src_dev_count < 1) {
		DEBUG_WARNING("no winwave play devices\n");
		return ENODEV;
	}

	st = mem_zalloc(sizeof(*st), ausrc_destructor);
	if (!st)
		return ENOMEM;

	st->as = mem_ref(as);
	st->rh = rh;
	st->arg = arg;
	if (prm) {
		prm->fmt = AUFMT_S16LE;
		st->prm = *prm;
	}

	err = read_stream_open(st);

	if (err)
		mem_deref(st);
	else
		*stp = st;

	return err;
}