mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	small cleanups
resample: remove unused index variable
This commit is contained in:
		
							parent
							
								
									98d10bbd1f
								
							
						
					
					
						commit
						0154e6eaac
					
				
					 6 changed files with 12 additions and 16 deletions
				
			
		| 
						 | 
					@ -592,6 +592,8 @@ impl_node_port_set_io(void *object,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
 | 
						spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_log_debug(this->log, NAME " %p: io %d %p %zd", this, id, data, size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (id) {
 | 
						switch (id) {
 | 
				
			||||||
	case SPA_IO_Buffers:
 | 
						case SPA_IO_Buffers:
 | 
				
			||||||
		this->io = data;
 | 
							this->io = data;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,6 @@ struct native_data {
 | 
				
			||||||
	uint32_t n_phases;
 | 
						uint32_t n_phases;
 | 
				
			||||||
	uint32_t in_rate;
 | 
						uint32_t in_rate;
 | 
				
			||||||
	uint32_t out_rate;
 | 
						uint32_t out_rate;
 | 
				
			||||||
	uint32_t index;
 | 
					 | 
				
			||||||
	uint32_t phase;
 | 
						uint32_t phase;
 | 
				
			||||||
	uint32_t inc;
 | 
						uint32_t inc;
 | 
				
			||||||
	uint32_t frac;
 | 
						uint32_t frac;
 | 
				
			||||||
| 
						 | 
					@ -66,7 +65,7 @@ DEFINE_RESAMPLER(copy,arch)							\
 | 
				
			||||||
	if (r->channels == 0)							\
 | 
						if (r->channels == 0)							\
 | 
				
			||||||
		return;								\
 | 
							return;								\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
	index = data->index;							\
 | 
						index = 0;								\
 | 
				
			||||||
	if (offs < olen && index + n_taps <= ilen) {				\
 | 
						if (offs < olen && index + n_taps <= ilen) {				\
 | 
				
			||||||
		uint32_t to_copy = SPA_MIN(olen - offs,				\
 | 
							uint32_t to_copy = SPA_MIN(olen - offs,				\
 | 
				
			||||||
				ilen - (index + n_taps) + 1);			\
 | 
									ilen - (index + n_taps) + 1);			\
 | 
				
			||||||
| 
						 | 
					@ -80,7 +79,6 @@ DEFINE_RESAMPLER(copy,arch)							\
 | 
				
			||||||
	}									\
 | 
						}									\
 | 
				
			||||||
	*in_len = index;							\
 | 
						*in_len = index;							\
 | 
				
			||||||
	*out_len = offs;							\
 | 
						*out_len = offs;							\
 | 
				
			||||||
	data->index = index;							\
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MAKE_RESAMPLER_FULL(arch)						\
 | 
					#define MAKE_RESAMPLER_FULL(arch)						\
 | 
				
			||||||
| 
						 | 
					@ -99,7 +97,7 @@ DEFINE_RESAMPLER(full,arch)							\
 | 
				
			||||||
		const float *s = src[c];					\
 | 
							const float *s = src[c];					\
 | 
				
			||||||
		float *d = dst[c];						\
 | 
							float *d = dst[c];						\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
		index = data->index;						\
 | 
							index = 0;						\
 | 
				
			||||||
		phase = data->phase;						\
 | 
							phase = data->phase;						\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
		for (o = offs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
							for (o = offs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
				
			||||||
| 
						 | 
					@ -118,7 +116,6 @@ DEFINE_RESAMPLER(full,arch)							\
 | 
				
			||||||
	}									\
 | 
						}									\
 | 
				
			||||||
	*in_len = index;							\
 | 
						*in_len = index;							\
 | 
				
			||||||
	*out_len = o;								\
 | 
						*out_len = o;								\
 | 
				
			||||||
	data->index = index;							\
 | 
					 | 
				
			||||||
	data->phase = phase;							\
 | 
						data->phase = phase;							\
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,7 +136,7 @@ DEFINE_RESAMPLER(inter,arch)							\
 | 
				
			||||||
		const float *s = src[c];					\
 | 
							const float *s = src[c];					\
 | 
				
			||||||
		float *d = dst[c];						\
 | 
							float *d = dst[c];						\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
		index = data->index;						\
 | 
							index = 0;							\
 | 
				
			||||||
		phase = data->phase;						\
 | 
							phase = data->phase;						\
 | 
				
			||||||
										\
 | 
															\
 | 
				
			||||||
		for (o = offs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
							for (o = offs; o < olen && index + n_taps <= ilen; o++) {	\
 | 
				
			||||||
| 
						 | 
					@ -165,7 +162,6 @@ DEFINE_RESAMPLER(inter,arch)							\
 | 
				
			||||||
	}									\
 | 
						}									\
 | 
				
			||||||
	*in_len = index;							\
 | 
						*in_len = index;							\
 | 
				
			||||||
	*out_len = o;								\
 | 
						*out_len = o;								\
 | 
				
			||||||
	data->index = index;							\
 | 
					 | 
				
			||||||
	data->phase = phase;							\
 | 
						data->phase = phase;							\
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,8 +171,8 @@ static void impl_native_process(struct resample *r,
 | 
				
			||||||
		in = hist + refill;
 | 
							in = hist + refill;
 | 
				
			||||||
		out = *out_len;
 | 
							out = *out_len;
 | 
				
			||||||
		data->func(r, (const void**)history, &in, dst, 0, &out);
 | 
							data->func(r, (const void**)history, &in, dst, 0, &out);
 | 
				
			||||||
		spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d idx:%d hist:%d",
 | 
							spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d hist:%d",
 | 
				
			||||||
				r, hist + refill, in, *out_len, out, data->index, hist);
 | 
									r, hist + refill, in, *out_len, out, hist);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		out = in = 0;
 | 
							out = in = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -180,7 +180,6 @@ static void impl_native_process(struct resample *r,
 | 
				
			||||||
	if (in >= hist) {
 | 
						if (in >= hist) {
 | 
				
			||||||
		/* we are past the history and can now work on the new
 | 
							/* we are past the history and can now work on the new
 | 
				
			||||||
		 * input data */
 | 
							 * input data */
 | 
				
			||||||
		data->index -= hist;
 | 
					 | 
				
			||||||
		in = *in_len;
 | 
							in = *in_len;
 | 
				
			||||||
		data->func(r, src, &in, dst, out, out_len);
 | 
							data->func(r, src, &in, dst, out, out_len);
 | 
				
			||||||
		spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d",
 | 
							spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d",
 | 
				
			||||||
| 
						 | 
					@ -219,7 +218,6 @@ static void impl_native_process(struct resample *r,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	data->hist = remain;
 | 
						data->hist = remain;
 | 
				
			||||||
	data->index = 0;
 | 
					 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -228,7 +226,6 @@ static void impl_native_reset (struct resample *r)
 | 
				
			||||||
	struct native_data *d = r->data;
 | 
						struct native_data *d = r->data;
 | 
				
			||||||
	memset(d->hist_mem, 0, r->channels * sizeof(float) * d->n_taps * 2);
 | 
						memset(d->hist_mem, 0, r->channels * sizeof(float) * d->n_taps * 2);
 | 
				
			||||||
	d->hist = d->n_taps / 2;
 | 
						d->hist = d->n_taps / 2;
 | 
				
			||||||
	d->index = 0;
 | 
					 | 
				
			||||||
	d->phase = 0;
 | 
						d->phase = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,7 +276,7 @@ static int impl_native_init(struct resample *r)
 | 
				
			||||||
			64);
 | 
								64);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (d == NULL)
 | 
						if (d == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	r->data = d;
 | 
						r->data = d;
 | 
				
			||||||
	d->n_taps = n_taps;
 | 
						d->n_taps = n_taps;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,7 +112,7 @@ static int impl_peaks_init(struct resample *r)
 | 
				
			||||||
	r->reset = impl_peaks_reset;
 | 
						r->reset = impl_peaks_reset;
 | 
				
			||||||
	d = r->data = calloc(1, sizeof(struct peaks_data) * sizeof(float) * r->channels);
 | 
						d = r->data = calloc(1, sizeof(struct peaks_data) * sizeof(float) * r->channels);
 | 
				
			||||||
	if (r->data == NULL)
 | 
						if (r->data == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d->i_count = d->o_count = 0;
 | 
						d->i_count = d->o_count = 0;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -182,8 +182,8 @@ execute_command_module_load(struct pw_command *command, struct pw_core *core, ch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	module = pw_module_load(core, command->args[1], command->args[2], NULL, NULL, NULL);
 | 
						module = pw_module_load(core, command->args[1], command->args[2], NULL, NULL, NULL);
 | 
				
			||||||
	if (module == NULL) {
 | 
						if (module == NULL) {
 | 
				
			||||||
		asprintf(err, "could not load module \"%s\"", command->args[1]);
 | 
							asprintf(err, "could not load module \"%s\": %m", command->args[1]);
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -errno;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -211,6 +211,7 @@ static void try_link_controls(struct impl *impl)
 | 
				
			||||||
	if (!impl->use_converter)
 | 
						if (!impl->use_converter)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_log_warn(NAME " %p: controls", impl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((res = spa_node_port_set_io(impl->slave_node,
 | 
						if ((res = spa_node_port_set_io(impl->slave_node,
 | 
				
			||||||
			impl->direction, 0,
 | 
								impl->direction, 0,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue