diff options
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/artnet.c | 5 | ||||
| -rw-r--r-- | backends/evdev.c | 8 | ||||
| -rw-r--r-- | backends/jack.c | 52 | ||||
| -rw-r--r-- | backends/lua.c | 3 | ||||
| -rw-r--r-- | backends/osc.c | 14 | ||||
| -rw-r--r-- | backends/sacn.c | 9 | ||||
| -rw-r--r-- | backends/winmidi.c | 5 | 
7 files changed, 32 insertions, 64 deletions
| diff --git a/backends/artnet.c b/backends/artnet.c index caab6e0..c59a79d 100644 --- a/backends/artnet.c +++ b/backends/artnet.c @@ -378,11 +378,6 @@ static int artnet_handle(size_t num, managed_fd* fds){  		}  	} -	if(!num){ -		//early exit -		return 0; -	} -  	for(u = 0; u < num; u++){  		do{  			bytes_read = recv(fds[u].fd, recv_buf, sizeof(recv_buf), 0); diff --git a/backends/evdev.c b/backends/evdev.c index af5ec74..8a14200 100644 --- a/backends/evdev.c +++ b/backends/evdev.c @@ -357,10 +357,6 @@ static int evdev_handle(size_t num, managed_fd* fds){  	int read_status;  	struct input_event ev; -	if(!num){ -		return 0; -	} -  	for(fd = 0; fd < num; fd++){  		inst = (instance*) fds[fd].impl;  		if(!inst){ @@ -437,10 +433,6 @@ static int evdev_set(instance* inst, size_t num, channel** c, channel_value* v)  	int32_t value = 0;  	uint64_t range = 0; -	if(!num){ -		return 0; -	} -  	if(!data->output_enabled){  		LOGPF("Instance %s not enabled for output (%" PRIsize_t " channel events)", inst->name, num);  		return 0; diff --git a/backends/jack.c b/backends/jack.c index c862096..d430c60 100644 --- a/backends/jack.c +++ b/backends/jack.c @@ -549,38 +549,36 @@ static int mmjack_handle(size_t num, managed_fd* fds){  	ssize_t bytes;  	uint8_t recv_buf[1024]; -	if(num){ -		for(u = 0; u < num; u++){ -			inst = (instance*) fds[u].impl; -			data = (mmjack_instance_data*) inst->impl; -			bytes = recv(fds[u].fd, recv_buf, sizeof(recv_buf), 0); -			if(bytes < 0){ -				LOGPF("Failed to receive on feedback socket for instance %s", inst->name); -				return 1; -			} +	for(u = 0; u < num; u++){ +		inst = (instance*) fds[u].impl; +		data = (mmjack_instance_data*) inst->impl; +		bytes = recv(fds[u].fd, recv_buf, sizeof(recv_buf), 0); +		if(bytes < 0){ +			LOGPF("Failed to receive on feedback socket for instance %s", inst->name); +			return 1; +		} -			for(p = 0; p < data->ports; p++){ -				if(data->port[p].input && data->port[p].mark){ -					pthread_mutex_lock(&data->port[p].lock); -					switch(data->port[p].type){ -						case port_cv: -							mmjack_handle_cv(inst, p, data->port + p); -							break; -						case port_midi: -							mmjack_handle_midi(inst, p, data->port + p); -							break; -						default: -							LOGPF("Output handler not implemented for unknown channel type on %s.%s", inst->name, data->port[p].name); -							break; -					} - -					data->port[p].mark = 0; -					pthread_mutex_unlock(&data->port[p].lock); +		for(p = 0; p < data->ports; p++){ +			if(data->port[p].input && data->port[p].mark){ +				pthread_mutex_lock(&data->port[p].lock); +				switch(data->port[p].type){ +					case port_cv: +						mmjack_handle_cv(inst, p, data->port + p); +						break; +					case port_midi: +						mmjack_handle_midi(inst, p, data->port + p); +						break; +					default: +						LOGPF("Output handler not implemented for unknown channel type on %s.%s", inst->name, data->port[p].name); +						break;  				} + +				data->port[p].mark = 0; +				pthread_mutex_unlock(&data->port[p].lock);  			}  		}  	} -	 +  	if(config.jack_shutdown){  		LOG("Server disconnected");  		return 1; diff --git a/backends/lua.c b/backends/lua.c index 7f80cc7..968193e 100644 --- a/backends/lua.c +++ b/backends/lua.c @@ -471,7 +471,8 @@ static channel* lua_channel(instance* inst, char* spec, uint8_t flags){  			return NULL;  		} -		data->channel[u].in = data->channel[u].out = 0.0; +		//initialize new channel +		memset(data->channel + u, 0, sizeof(lua_channel_data));  		data->channel[u].name = strdup(spec);  		if(!data->channel[u].name){  			LOG("Failed to allocate memory"); diff --git a/backends/osc.c b/backends/osc.c index 754c290..f40f3f5 100644 --- a/backends/osc.c +++ b/backends/osc.c @@ -231,7 +231,7 @@ static int osc_path_validate(char* path, uint8_t allow_patterns){  	char pattern_chars[] = "?[]{}*";  	size_t u, c;  	uint8_t square_open = 0, curly_open = 0; -	 +  	if(path[0] != '/'){  		LOGPF("%s is not a valid OSC path: Missing root /", path);  		return 1; @@ -331,7 +331,7 @@ static int osc_path_match(char* pattern, char* path){  					}  					if(pattern[match_end + 1] == '-' && pattern[match_end + 2] != ']'){ -						if((pattern[match_end] > pattern[match_end + 2]  +						if((pattern[match_end] > pattern[match_end + 2]  									&& path[u] >= pattern[match_end + 2]  									&& path[u] <= pattern[match_end])  								|| (pattern[match_end] <= pattern[match_end + 2] @@ -666,7 +666,7 @@ static int osc_output_channel(instance* inst, size_t channel){  		memcpy(xmit_buf, data->root, strlen(data->root));  		offset += strlen(data->root);  	} -	 +  	memcpy(xmit_buf + offset, data->channel[channel].path, strlen(data->channel[channel].path));  	offset += strlen(data->channel[channel].path) + 1;  	offset = osc_align(offset); @@ -703,16 +703,12 @@ static int osc_output_channel(instance* inst, size_t channel){  static int osc_set(instance* inst, size_t num, channel** c, channel_value* v){  	size_t evt = 0, mark = 0;  	int rv = 0; +	osc_instance_data* data = (osc_instance_data*) inst->impl;  	osc_channel_ident ident = {  		.label = 0  	};  	osc_parameter_value current; -	if(!num){ -		return 0; -	} - -	osc_instance_data* data = (osc_instance_data*) inst->impl;  	if(!data->dest_len){  		LOGPF("Instance %s does not have a destination, output is disabled (%" PRIsize_t " channels)", inst->name, num);  		return 0; @@ -747,7 +743,7 @@ static int osc_set(instance* inst, size_t num, channel** c, channel_value* v){  			mark = 1;  		}  	} -	 +  	if(mark){  		//output all marked channels  		for(evt = 0; !rv && evt < num; evt++){ diff --git a/backends/sacn.c b/backends/sacn.c index bd5c75a..bce3887 100644 --- a/backends/sacn.c +++ b/backends/sacn.c @@ -330,10 +330,6 @@ static int sacn_set(instance* inst, size_t num, channel** c, channel_value* v){  	uint32_t frame_delta = 0;  	sacn_instance_data* data = (sacn_instance_data*) inst->impl; -	if(!num){ -		return 0; -	} -  	if(!data->xmit_prio){  		LOGPF("Instance %s not enabled for output (%" PRIsize_t " channel events)", inst->name, num);  		return 0; @@ -554,11 +550,6 @@ static int sacn_handle(size_t num, managed_fd* fds){  		}  	} -	//early exit -	if(!num){ -		return 0; -	} -  	for(u = 0; u < num; u++){  		do{  			bytes_read = recv(fds[u].fd, recv_buf, sizeof(recv_buf), 0); diff --git a/backends/winmidi.c b/backends/winmidi.c index d9b3047..753f25c 100644 --- a/backends/winmidi.c +++ b/backends/winmidi.c @@ -185,11 +185,6 @@ static int winmidi_set(instance* inst, size_t num, channel** c, channel_value* v  	};  	size_t u; -	//early exit -	if(!num){ -		return 0; -	} -  	if(!data->device_out){  		LOGPF("Instance %s has no output device", inst->name);  		return 0; | 
