Exemplo n.º 1
0
int main(int argc, const char **argv)
{
	struct dsp_node *node;
	int ret = 0;
	unsigned i;

	signal(SIGINT, signal_handler);

#ifdef DEBUG
	debug_level = 3;
#endif
	ntimes = 1000;

	argc--; argv++;
	handle_options(&argc, &argv);

	dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		pr_err("dsp open failed");
		return -1;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc)) {
		pr_err("dsp attach failed");
		ret = -1;
		goto leave;
	}

	node = create_node();
	if (!node) {
		pr_err("dsp node creation failed");
		ret = -1;
		goto leave;
	}

	run_task(node, ntimes);
	destroy_node(node);

leave:
	if (proc) {
		if (!dsp_detach(dsp_handle, proc)) {
			pr_err("dsp detach failed");
			ret = -1;
		}
		proc = NULL;
	}

	for (i = 0; i < ARRAY_SIZE(events); i++)
		free(events[i]);

	if (dsp_handle > 0) {
		if (dsp_close(dsp_handle) < 0) {
			pr_err("dsp close failed");
			return -1;
		}
	}

	return ret;
}
int main(int argc, const char **argv)
{
	struct dsp_node *node;
	int ret = 0;

	signal(SIGINT, signal_handler);

#ifdef DEBUG
	debug_level = 3;
#endif

	dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		pr_err("dsp open failed");
		return -1;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc)) {
		pr_err("dsp attach failed");
		ret = -1;
		goto leave;
	}

	node = create_node();
	if (!node) {
		pr_err("dsp node creation failed");
		ret = -1;
		goto leave;
	}

	run_task(node);
	
	destroy_node(node);

leave:
	if (proc) {
		if (!dsp_detach(dsp_handle, proc)) {
			pr_err("dsp detach failed");
			ret = -1;
		}
		proc = NULL;
	}

	if (dsp_handle > 0) {
		if (dsp_close(dsp_handle) < 0) {
			pr_err("dsp close failed");
			return -1;
		}
	}

	return ret;
}
Exemplo n.º 3
0
static bool do_list(void)
{
	struct dsp_ndb_props props;
	unsigned num = 0, i;
	void *proc_handle;
	struct node_info *node_table;
	void **tmp_table;
	unsigned node_count = 0, allocated_count = 0;

	if (!dsp_enum(dsp_handle, 0, &props, sizeof(props), &num)) {
		pr_err("failed to enumerate nodes");
		return false;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc_handle)) {
		pr_err("dsp attach failed");
		return false;
	}

	node_table = calloc(num, sizeof(*node_table));
	for (i = 0; i < num; i++) {
		if (dsp_enum(dsp_handle, i, &props, sizeof(props), &num)) {
			memcpy(&node_table[i].id, &props.node_id, sizeof(props.node_id));
			memcpy(&node_table[i].name, props.ac_name, sizeof(props.ac_name));
			node_table[i].type = props.ntype;
			node_table[i].state = -1;
		}
	}

	tmp_table = calloc(num, sizeof(*tmp_table));
	if (dsp_enum_nodes(dsp_handle, proc_handle, tmp_table, num,
				&node_count, &allocated_count))
	{
		for (i = 0; i < node_count; i++) {
			struct dsp_node_attr attr;
			struct dsp_node node = { .handle = tmp_table[i] };
			if (dsp_node_get_attr(dsp_handle, &node, &attr, sizeof(attr))) {
				unsigned j;
				for (j = 0; j < num; j++) {
					if (uuidcmp(&node_table[j].id, &attr.info.props.node_id)) {
						node_table[j].state = attr.info.state;
						break;
					}
				}
			}
		}
	} else {
Exemplo n.º 4
0
static gboolean
dsp_init(GstDspDummy *self)
{
	int dsp_handle;

	self->dsp_handle = dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		GST_ERROR("dsp open failed");
		return FALSE;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &self->proc)) {
		GST_ERROR("dsp attach failed");
		goto fail;
	}

	self->node = create_node(dsp_handle, self->proc);
	if (!self->node) {
		GST_ERROR("dsp node creation failed");
		goto fail;
	}

	return TRUE;

fail:
	if (self->proc) {
		if (!dsp_detach(dsp_handle, self->proc))
			GST_ERROR("dsp detach failed");
		self->proc = NULL;
	}

	if (self->dsp_handle >= 0) {
		if (dsp_close(dsp_handle) < 0)
			GST_ERROR("dsp close failed");
		self->dsp_handle = -1;
	}

	return FALSE;
}
Exemplo n.º 5
0
int main(int argc, const char **argv)
{
	int ret = 0;
	int dsp_handle;
	void *proc;
	char *cmd[1];

	if (argc != 2) {
		pr_err("Wrong arguments: %s <dsp_program>", argv[0]);
		return -1;
	}

	dsp_handle = dsp_open();

	if (dsp_handle < 0) {
		pr_err("dsp open failed");
		return -1;
	}

	if (!dsp_attach(dsp_handle, 0, NULL, &proc)) {
		pr_err("dsp attach failed");
		ret = -1;
		goto leave;
	}

	if (!dsp_stop(dsp_handle, proc)) {
		pr_err("dsp stop failed");
		ret = -1;
		goto leave;
	}

	cmd[0] = (char *) argv[1];
	if (!dsp_load(dsp_handle, proc, 1, cmd, NULL)) {
		pr_err("dsp load failed");
		ret = -1;
		goto leave;
	}

	if (!dsp_start(dsp_handle, proc)) {
		pr_err("dsp start failed");
		ret = -1;
	}

leave:
	if (proc) {
		if (!dsp_detach(dsp_handle, proc)) {
			pr_err("dsp detach failed");
			ret = -1;
		}
		proc = NULL;
	}

	if (dsp_handle > 0) {
		if (dsp_close(dsp_handle) < 0) {
			pr_err("dsp close failed");
			return -1;
		}
	}

	return ret;
}