コード例 #1
0
ファイル: upnp_control.c プロジェクト: alinzai/audio
void upnp_control_init(struct upnp_device *device) {
	upnp_control_get_service();

	// Set initial volume.
	float volume_fraction = 0;
	if (output_get_volume(&volume_fraction) == 0) {
		Log_info("control", "Output inital volume is %f; setting "
			 "control variables accordingly.", volume_fraction);
		change_volume_decibel(20 * log(volume_fraction) / log(10));
	}

	assert(control_service_.last_change == NULL);
	control_service_.last_change =
		UPnPLastChangeCollector_new(state_variables_, CONTROL_EVENT_XML_NS,
					    device,
					    CONTROL_SERVICE_ID);
	// According to UPnP-av-RenderingControl-v3-Service-20101231.pdf, 2.3.1
	// page 51, the A_ARG_TYPE* variables are not evented.
	UPnPLastChangeCollector_add_ignore(control_service_.last_change,
					   CONTROL_VAR_AAT_CHANNEL);
	UPnPLastChangeCollector_add_ignore(control_service_.last_change,
					   CONTROL_VAR_AAT_INSTANCE_ID);
	UPnPLastChangeCollector_add_ignore(control_service_.last_change,
					   CONTROL_VAR_AAT_PRESET_NAME);
}
コード例 #2
0
void upnp_control_init(void) {
	upnp_control_get_service();
	// This doesn't seem to work: asking gmstreamer initially will always
	// return 1.0.
	float volume_fraction = 0;
	if (output_get_volume(&volume_fraction) == 0) {
		fprintf(stderr, "Got fraction %f\n", volume_fraction);
		change_volume_decibel(NULL, 20 * log(volume_fraction) / log(10));
	}
}
コード例 #3
0
static int set_volume_db(struct action_event *event) {
	const char *str_decibel_in = upnp_get_string(event, "DesiredVolume");
	service_lock();
	float raw_decibel_in = atof(str_decibel_in);
	float decibel = change_volume_decibel(event, raw_decibel_in);

	output_set_volume(exp(decibel / 20 * log(10)));
	service_unlock();

	return 0;
}