Esempio n. 1
0
int
mixer_check(struct mixer_s *mixer, unsigned group_count, unsigned control_count)
{
	int ret;

	/* sanity that presumes that a mixer includes a control no more than once */
	if (mixer->control_count > (group_count * control_count))
		return -2;

	/* validate the output scaler */
	ret = scale_check(&mixer->output_scaler);

	if (ret != 0)
		return ret;

	/* validate input scalers */
	for (unsigned i = 0; i < mixer->control_count; i++) {

		/* range-check input controls */
		if (mixer->control_scaler[i].control_group >= group_count)
			return -3;

		if (mixer->control_scaler[i].control_index >= control_count)
			return -3;

		/* validate the scaler */
		ret = scale_check(&mixer->control_scaler[i]);

		if (ret != 0)
			return (10 * i + ret);
	}

	return 0;
}
Esempio n. 2
0
int
SimpleMixer::check()
{
	int ret;
	float junk;

	/* sanity that presumes that a mixer includes a control no more than once */
	/* max of 32 groups due to groups_required API */
	if (_pinfo->control_count > 32) {
		return -2;
	}

	/* validate the output scaler */
	ret = scale_check(_pinfo->output_scaler);

	if (ret != 0) {
		return ret;
	}

	/* validate input scalers */
	for (unsigned i = 0; i < _pinfo->control_count; i++) {

		/* verify that we can fetch the control */
		if (_control_cb(_cb_handle,
				_pinfo->controls[i].control_group,
				_pinfo->controls[i].control_index,
				junk) != 0) {
			return -3;
		}

		/* validate the scaler */
		ret = scale_check(_pinfo->controls[i].scaler);

		if (ret != 0) {
			return (10 * i + ret);
		}
	}

	return 0;
}