Exemplo n.º 1
0
static bool 
parameter_should_be_hidden(BParameter &parameter)
{
	// ToDo: note, this is probably completely stupid, but it's the only
	// way I could safely remove the null parameters that are not shown
	// by the R5 media theme
	if (parameter.Type() != BParameter::B_NULL_PARAMETER
		|| strcmp(parameter.Kind(), B_WEB_PHYSICAL_INPUT))
		return false;

	for (int32 i = 0; i < parameter.CountOutputs(); i++) {
		if (!strcmp(parameter.OutputAt(0)->Kind(), B_INPUT_MUX))
			return true;
	}

	return false;
}
Exemplo n.º 2
0
status_t
Controller::ConnectInterface(int i)
{
	if (i < 0) {
		printf("Controller::ConnectInterface: wrong index\n");
		return B_ERROR;
	}
	if (fCurrentInterface != -1) {
		printf("Controller::ConnectInterface: already connected\n");
		return B_ERROR;
	}

	BParameterWeb *web;
	status_t err;
	
	err = gDeviceRoster->MediaRoster()->GetParameterWebFor(gDeviceRoster->DeviceNode(i), &web);
	if (err != B_OK) {
		printf("Controller::ConnectInterface: can't get parameter web\n");
		return B_ERROR;
	}

	delete fWeb;
	fWeb = web;
	fCurrentInterface = i;
	
	// XXX we may need to monitor for parameter web changes
	// and reassing fWeb and fChannelParam on demand.

	// find the channel control	and assign it to fChannelParam
	fChannelParam = NULL;
	int count = fWeb->CountParameters();
	for (int i = 0; i < count; i++) {
		BParameter *parameter = fWeb->ParameterAt(i);	

		printf("parameter %d\n", i);
		printf("  name '%s'\n", parameter->Name());
		printf("  kind '%s'\n", parameter->Kind());
		printf("  unit '%s'\n", parameter->Unit());
		printf("  flags 0x%08" B_PRIx32 "\n", parameter->Flags());
		
		// XXX TODO: matching on Name is weak
		if (strcmp(parameter->Name(), "Channel") == 0 || strcmp(parameter->Kind(), B_TUNER_CHANNEL) == 0) {
			fChannelParam = dynamic_cast<BDiscreteParameter *>(parameter);
			if (fChannelParam)
				break;
		}
	}
	if (!fChannelParam) {
		printf("Controller::ConnectInterface: can't find channel parameter control\n");
		fCurrentChannel = -1;
	} else {
	if (fChannelParam->CountItems() == 0) {
			fCurrentChannel = -1;
			printf("Controller::ConnectInterface: channel control has 0 items\n");
		} else {
			int32 index;
			size_t size;
			status_t err;
			bigtime_t when;
			size = sizeof(index);
			err = fChannelParam->GetValue(&index, &size, &when);
			if (err == B_OK && size == sizeof(index)) {
				fCurrentChannel = index;
				printf("Controller::ConnectInterface: selected channel is %d\n", fCurrentChannel);
			} else {
				fCurrentChannel = -1;
				printf("Controller::ConnectInterface: can't get channel control value\n");
			}
		}
	}

	ConnectNodes();

	return B_OK;
}