mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	audioconvert2: implement control port
Add a control port when requested in the PortConfig. Fix the sequence loop. Make a copy of the sample pointers before changing them.
This commit is contained in:
		
							parent
							
								
									5a60fd7041
								
							
						
					
					
						commit
						c160cd0176
					
				
					 1 changed files with 33 additions and 10 deletions
				
			
		| 
						 | 
					@ -885,7 +885,7 @@ static int apply_midi(struct impl *this, const struct spa_pod *value)
 | 
				
			||||||
	if ((val[0] & 0xf0) != 0xb0 || val[1] != 7)
 | 
						if ((val[0] & 0xf0) != 0xb0 || val[1] != 7)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p->volume = val[2] / 127.0;
 | 
						p->volume = val[2] / 127.0f;
 | 
				
			||||||
	set_volume(this);
 | 
						set_volume(this);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -951,6 +951,10 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -ENOTSUP;
 | 
							return -ENOTSUP;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (direction == SPA_DIRECTION_INPUT && dir->control) {
 | 
				
			||||||
 | 
							i = dir->n_ports++;
 | 
				
			||||||
 | 
							init_port(this, direction, i, 0, false, false, true);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->info.change_mask |= SPA_NODE_CHANGE_MASK_FLAGS | SPA_NODE_CHANGE_MASK_PARAMS;
 | 
						this->info.change_mask |= SPA_NODE_CHANGE_MASK_FLAGS | SPA_NODE_CHANGE_MASK_PARAMS;
 | 
				
			||||||
	this->info.flags &= ~SPA_NODE_FLAG_NEED_CONFIGURE;
 | 
						this->info.flags &= ~SPA_NODE_FLAG_NEED_CONFIGURE;
 | 
				
			||||||
| 
						 | 
					@ -2030,8 +2034,8 @@ static int channelmix_process_control(struct impl *this, struct port *ctrlport,
 | 
				
			||||||
	struct spa_pod_control *c, *prev = NULL;
 | 
						struct spa_pod_control *c, *prev = NULL;
 | 
				
			||||||
	uint32_t avail_samples = n_samples;
 | 
						uint32_t avail_samples = n_samples;
 | 
				
			||||||
	uint32_t i;
 | 
						uint32_t i;
 | 
				
			||||||
	const float **s = (const float **)src;
 | 
						const float *s[MAX_PORTS], **ss = (const float**) src;
 | 
				
			||||||
	float **d = (float **)dst;
 | 
						float *d[MAX_PORTS], **sd = (float **) dst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SPA_POD_SEQUENCE_FOREACH(ctrlport->ctrl, c) {
 | 
						SPA_POD_SEQUENCE_FOREACH(ctrlport->ctrl, c) {
 | 
				
			||||||
		uint32_t chunk;
 | 
							uint32_t chunk;
 | 
				
			||||||
| 
						 | 
					@ -2060,26 +2064,45 @@ static int channelmix_process_control(struct impl *this, struct port *ctrlport,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		chunk = SPA_MIN(avail_samples, c->offset - ctrlport->ctrl_offset);
 | 
							chunk = SPA_MIN(avail_samples, c->offset - ctrlport->ctrl_offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_log_trace_fp(this->log, "%p: process %d %d", this,
 | 
							spa_log_trace_fp(this->log, "%p: process %d-%d %d", this,
 | 
				
			||||||
				c->offset, chunk);
 | 
									c->offset, ctrlport->ctrl_offset, chunk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		channelmix_process(&this->mix, dst, src, chunk);
 | 
							if (ss == (const float**)src) {
 | 
				
			||||||
			for (i = 0; i < this->mix.src_chan; i++)
 | 
								for (i = 0; i < this->mix.src_chan; i++)
 | 
				
			||||||
			s[i] += chunk;
 | 
									s[i] = ss[i];
 | 
				
			||||||
			for (i = 0; i < this->mix.dst_chan; i++)
 | 
								for (i = 0; i < this->mix.dst_chan; i++)
 | 
				
			||||||
			d[i] += chunk;
 | 
									d[i] = sd[i];
 | 
				
			||||||
 | 
								ss = s;
 | 
				
			||||||
 | 
								sd = d;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							channelmix_process(&this->mix, (void**)sd, (const void**)ss, chunk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (i = 0; i < this->mix.src_chan; i++)
 | 
				
			||||||
 | 
								ss[i] += chunk;
 | 
				
			||||||
 | 
							for (i = 0; i < this->mix.dst_chan; i++)
 | 
				
			||||||
 | 
								sd[i] += chunk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		avail_samples -= chunk;
 | 
							avail_samples -= chunk;
 | 
				
			||||||
		ctrlport->ctrl_offset += chunk;
 | 
							ctrlport->ctrl_offset += chunk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		prev = c;
 | 
							prev = c;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (prev) {
 | 
				
			||||||
 | 
							switch (prev->type) {
 | 
				
			||||||
 | 
							case SPA_CONTROL_Midi:
 | 
				
			||||||
 | 
								apply_midi(this, &prev->value);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case SPA_CONTROL_Properties:
 | 
				
			||||||
 | 
								apply_props(this, &prev->value);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	/* when we get here we run out of control points but still have some
 | 
						/* when we get here we run out of control points but still have some
 | 
				
			||||||
	 * remaining samples */
 | 
						 * remaining samples */
 | 
				
			||||||
	spa_log_trace_fp(this->log, "%p: remain %d", this, avail_samples);
 | 
						spa_log_trace_fp(this->log, "%p: remain %d", this, avail_samples);
 | 
				
			||||||
	if (avail_samples > 0)
 | 
						if (avail_samples > 0)
 | 
				
			||||||
		channelmix_process(&this->mix, dst, src, avail_samples);
 | 
							channelmix_process(&this->mix, (void**)sd, (const void**)ss, avail_samples);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue