Esempio n. 1
0
// utility - build the ToneProducer's parameter web
static BParameterWeb* make_parameter_web()
{
	FPRINTF(stderr, "make_parameter_web() called\n");

	BParameterWeb* web = new BParameterWeb;
	BParameterGroup* mainGroup = web->MakeGroup("Tone Generator Parameters");

	BParameterGroup* group = mainGroup->MakeGroup("Frequency");
	BParameter* nullParam = group->MakeNullParameter(FREQUENCY_NULL_PARAM, B_MEDIA_NO_TYPE, "Frequency", B_GENERIC);
	BContinuousParameter* param = group->MakeContinuousParameter(FREQUENCY_PARAM, B_MEDIA_NO_TYPE, "", B_GAIN, "Hz", 0, 2500, 0.1);
	nullParam->AddOutput(param);
	param->AddInput(nullParam);

	group = mainGroup->MakeGroup("Amplitude");
	nullParam = group->MakeNullParameter(GAIN_NULL_PARAM, B_MEDIA_NO_TYPE, "Amplitude", B_GENERIC);
	param = group->MakeContinuousParameter(GAIN_PARAM, B_MEDIA_NO_TYPE, "", B_GAIN, "", 0, 1, 0.01);
	nullParam->AddOutput(param);
	param->AddInput(nullParam);

	group = mainGroup->MakeGroup("Waveform");
	nullParam = group->MakeNullParameter(WAVEFORM_NULL_PARAM, B_MEDIA_NO_TYPE, "Waveform", B_GENERIC);
	BDiscreteParameter* waveParam = group->MakeDiscreteParameter(WAVEFORM_PARAM, B_MEDIA_NO_TYPE, "", B_GENERIC);
	waveParam->AddItem(SINE_WAVE, "Sine wave");
	waveParam->AddItem(TRIANGLE_WAVE, "Triangle");
	waveParam->AddItem(SAWTOOTH_WAVE, "Sawtooth");
	nullParam->AddOutput(waveParam);
	waveParam->AddInput(nullParam);

	return web;
}
Esempio n. 2
0
// build the LoggingConsumer's BParameterWeb
static BParameterWeb* build_parameter_web()
{
	BParameterWeb* web = new BParameterWeb;

	BParameterGroup* mainGroup = web->MakeGroup("LoggingConsumer Parameters");
	BParameterGroup* group = mainGroup->MakeGroup("Latency control");
	BParameter* nullParam = group->MakeNullParameter(INPUT_NULL_PARAM, B_MEDIA_NO_TYPE, "Latency", B_GENERIC);
	BParameter* latencyParam = group->MakeContinuousParameter(LATENCY_PARAM, B_MEDIA_NO_TYPE, "",
		B_GAIN, "ms", 5, 100, 5);
	nullParam->AddOutput(latencyParam);
	latencyParam->AddInput(nullParam);

	group = mainGroup->MakeGroup("CPU percentage");
	nullParam = group->MakeNullParameter(CPU_NULL_PARAM, B_MEDIA_NO_TYPE, "CPU spin percentage", B_GENERIC);
	BContinuousParameter* cpuParam = group->MakeContinuousParameter(CPU_SPIN_PARAM, B_MEDIA_NO_TYPE, "",
		B_GAIN, "percent", 5, 80, 5);
	nullParam->AddOutput(cpuParam);
	cpuParam->AddInput(nullParam);

	group = mainGroup->MakeGroup("Priority");
	nullParam = group->MakeNullParameter(PRIO_NULL_PARAM, B_MEDIA_NO_TYPE, "Thread priority", B_GENERIC);
	BDiscreteParameter* prioParam = group->MakeDiscreteParameter(PRIORITY_PARAM, B_MEDIA_NO_TYPE, "", B_GENERIC);
	prioParam->AddItem(5, "B_LOW_PRIORITY");
	prioParam->AddItem(10, "B_NORMAL_PRIORITY");
	prioParam->AddItem(15, "B_DISPLAY_PRIORITY");
	prioParam->AddItem(20, "B_URGENT_DISPLAY_PRIORITY");
	prioParam->AddItem(100, "B_REAL_TIME_DISPLAY_PRIORITY");
	prioParam->AddItem(110, "B_URGENT_PRIORITY");
	prioParam->AddItem(120, "B_REAL_TIME_PRIORITY");

	return web;
}
Esempio n. 3
0
void 
ESDSinkNode::SetParameterValue(int32 id, bigtime_t performance_time, const void* value, size_t size)
{
	CALLED();
	PRINT(("id : %li, performance_time : %lld, size : %li\n", id, performance_time, size));
	BParameter *parameter = NULL;
	for(int32 i=0; i<fWeb->CountParameters(); i++) {
		parameter = fWeb->ParameterAt(i);
		if(parameter->ID() == id)
			break;
	}
	switch (id) {
		case PARAM_ENABLED:
			if (size != sizeof(bool))
				return;
			fEnabled = *(bool *)value;
			return;
		case PARAM_HOST:
		{
			fprintf(stderr, "set HOST: %s\n", (const char *)value);
			fHostname = (const char *)value;
#if 0
			if (fDevice && fDevice->Connected()) {
				if (fDevice->Connect(fHostname.String(), fPort) >= 0) {
					fDevice->SetCommand();
					fDevice->SetFormat(ESD_FMT, 2);
					//fDevice->GetServerInfo();
					fInitCheckStatus = fDevice->SendDefaultCommand();
				}
			}
#endif
			return;
		}
		case PARAM_PORT:
		{
			fprintf(stderr, "set PORT: %s\n", (const char *)value);
			fPort = atoi((const char *)value);
#if 0
			if (fDevice && fDevice->Connected()) {
				if (fDevice->Connect(fHostname.String(), fPort) >= 0) {
					fDevice->SetCommand();
					fDevice->SetFormat(ESD_FMT, 2);
					//fDevice->GetServerInfo();
					fInitCheckStatus = fDevice->SendDefaultCommand();
				}
			}
#endif
			return;
		}
		default:
			break;
	}
}
Esempio n. 4
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;
}
Esempio n. 5
0
status_t 
ESDSinkNode::GetParameterValue(int32 id, bigtime_t* last_change, void* value, size_t* ioSize)
{
	CALLED();
	if (!fDevice)
		return B_ERROR;
	//PRINT(("id : %i\n", id));
	switch (id) {
		case PARAM_ENABLED:
			if (*ioSize < sizeof(bool))
				return B_NO_MEMORY;
			*(bool *)value = fEnabled;
			*ioSize = sizeof(bool);
			return B_OK;
		case PARAM_HOST:
		{
			BString s = fDevice->Host();
			*ioSize = MIN(*ioSize, s.Length());
			memcpy(value, s.String(), *ioSize);
			return B_OK;
		}
		case PARAM_PORT:
		{
			BString s;
			s << fDevice->Port();
			*ioSize = MIN(*ioSize, s.Length());
			memcpy(value, s.String(), *ioSize);
			return B_OK;
		}
		default:
			break;
	}
#if 0
	BParameter *parameter = NULL;
	for(int32 i=0; i<fWeb->CountParameters(); i++) {
		parameter = fWeb->ParameterAt(i);
		if(parameter->ID() == id)
			break;
	}
#endif
	
return EINVAL;
}
void VirtualRenderer::SetFilterParameters(media_node node, parameter_list *list)
{
	BParameterWeb	*web;
	BParameterGroup	*group;
	BParameter		*param;
	int				i, j;
	parameter_list_elem	*elem;
	
	BMediaRoster::Roster()->GetParameterWebFor(node, &web);
	group = web->GroupAt(0);
	for (i = 0; i < group->CountParameters(); i++)
	{
		param = group->ParameterAt(i);
		for (j = 0; j < list->CountItems(); j++)
		{
			elem = list->ItemAt(j);
			if (elem->id == param->ID())
			{
				param->SetValue(elem->value, elem->value_size, system_time());
				break;
			}
		}
	}
}
Esempio n. 7
0
status_t
ESDSinkNode::GetConfigurationFor(BMessage * into_message)
{
	CALLED();
	
	BParameter *parameter = NULL;
	void *buffer;
	size_t size = 128;
	bigtime_t last_change;
	status_t err;
	
	if (!into_message)
		return B_BAD_VALUE;
	
	buffer = malloc(size);
	
	for(int32 i=0; i<fWeb->CountParameters(); i++) {
		parameter = fWeb->ParameterAt(i);
		if(parameter->Type() != BParameter::B_CONTINUOUS_PARAMETER
			&& parameter->Type() != BParameter::B_DISCRETE_PARAMETER)
			continue;
			
		PRINT(("getting parameter %li\n", parameter->ID()));
		size = 128;
		while((err = GetParameterValue(parameter->ID(), &last_change, buffer, &size))==B_NO_MEMORY) {
			size += 128;
			free(buffer);
			buffer = malloc(size);
		}
		
		if(err == B_OK && size > 0) {
			into_message->AddInt32("parameterID", parameter->ID());
			into_message->AddData("parameterData", B_RAW_TYPE, buffer, size, false);
		} else {
			PRINT(("parameter %li err : %s\n", parameter->ID(), strerror(err)));
		}
	}
	
	//PRINT_OBJECT(*into_message);
	
	return B_OK;
}
Esempio n. 8
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;
}