mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	audioconvert: send the command to the children
Send the command on the converter to all children as well. Reset the resampler when we are paused so that we don't end up with old data. Fixes #288
This commit is contained in:
		
							parent
							
								
									310ed89aad
								
							
						
					
					
						commit
						e59c4675a7
					
				
					 7 changed files with 26 additions and 3 deletions
				
			
		| 
						 | 
					@ -791,7 +791,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
 | 
				
			||||||
static int impl_node_send_command(void *object, const struct spa_command *command)
 | 
					static int impl_node_send_command(void *object, const struct spa_command *command)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *this = object;
 | 
						struct impl *this = object;
 | 
				
			||||||
	int res;
 | 
						int res, i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_return_val_if_fail(this != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(this != NULL, -EINVAL);
 | 
				
			||||||
	spa_return_val_if_fail(command != NULL, -EINVAL);
 | 
						spa_return_val_if_fail(command != NULL, -EINVAL);
 | 
				
			||||||
| 
						 | 
					@ -802,7 +802,6 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
			return res;
 | 
								return res;
 | 
				
			||||||
		if ((res = setup_buffers(this, SPA_DIRECTION_INPUT)) < 0)
 | 
							if ((res = setup_buffers(this, SPA_DIRECTION_INPUT)) < 0)
 | 
				
			||||||
			return res;
 | 
								return res;
 | 
				
			||||||
		this->started = true;
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case SPA_NODE_COMMAND_Suspend:
 | 
						case SPA_NODE_COMMAND_Suspend:
 | 
				
			||||||
| 
						 | 
					@ -811,10 +810,23 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
	case SPA_NODE_COMMAND_Pause:
 | 
						case SPA_NODE_COMMAND_Pause:
 | 
				
			||||||
		this->started = false;
 | 
							this->started = false;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -ENOTSUP;
 | 
							return -ENOTSUP;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i = 0; i < this->n_nodes; i++) {
 | 
				
			||||||
 | 
							if ((res = spa_node_send_command(this->nodes[i], command)) < 0) {
 | 
				
			||||||
 | 
								spa_log_error(this->log, NAME " %p: can't send command to node %d: %s",
 | 
				
			||||||
 | 
										this, i, spa_strerror(res));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch (SPA_NODE_COMMAND_ID(command)) {
 | 
				
			||||||
 | 
						case SPA_NODE_COMMAND_Start:
 | 
				
			||||||
 | 
							this->started = true;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -442,6 +442,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
	case SPA_NODE_COMMAND_Start:
 | 
						case SPA_NODE_COMMAND_Start:
 | 
				
			||||||
		this->started = true;
 | 
							this->started = true;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
						case SPA_NODE_COMMAND_Suspend:
 | 
				
			||||||
 | 
							/* fallthrough */
 | 
				
			||||||
	case SPA_NODE_COMMAND_Pause:
 | 
						case SPA_NODE_COMMAND_Pause:
 | 
				
			||||||
		this->started = false;
 | 
							this->started = false;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -244,6 +244,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
	case SPA_NODE_COMMAND_Start:
 | 
						case SPA_NODE_COMMAND_Start:
 | 
				
			||||||
		this->started = true;
 | 
							this->started = true;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
						case SPA_NODE_COMMAND_Suspend:
 | 
				
			||||||
 | 
							/* fallthrough */
 | 
				
			||||||
	case SPA_NODE_COMMAND_Pause:
 | 
						case SPA_NODE_COMMAND_Pause:
 | 
				
			||||||
		this->started = false;
 | 
							this->started = false;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -347,6 +347,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
	case SPA_NODE_COMMAND_Start:
 | 
						case SPA_NODE_COMMAND_Start:
 | 
				
			||||||
		this->started = true;
 | 
							this->started = true;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
						case SPA_NODE_COMMAND_Suspend:
 | 
				
			||||||
 | 
							/* fallthrough */
 | 
				
			||||||
	case SPA_NODE_COMMAND_Pause:
 | 
						case SPA_NODE_COMMAND_Pause:
 | 
				
			||||||
		this->started = false;
 | 
							this->started = false;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -305,6 +305,8 @@ static void impl_native_process(struct resample *r,
 | 
				
			||||||
static void impl_native_reset (struct resample *r)
 | 
					static void impl_native_reset (struct resample *r)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct native_data *d = r->data;
 | 
						struct native_data *d = r->data;
 | 
				
			||||||
 | 
						if (d == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	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) - 1;
 | 
						d->hist = (d->n_taps / 2) - 1;
 | 
				
			||||||
	d->phase = 0;
 | 
						d->phase = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -252,6 +252,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
	case SPA_NODE_COMMAND_Suspend:
 | 
						case SPA_NODE_COMMAND_Suspend:
 | 
				
			||||||
		/* fallthrough */
 | 
							/* fallthrough */
 | 
				
			||||||
	case SPA_NODE_COMMAND_Pause:
 | 
						case SPA_NODE_COMMAND_Pause:
 | 
				
			||||||
 | 
							resample_reset(&this->resample);
 | 
				
			||||||
		this->started = false;
 | 
							this->started = false;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -329,6 +329,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
 | 
				
			||||||
	case SPA_NODE_COMMAND_Start:
 | 
						case SPA_NODE_COMMAND_Start:
 | 
				
			||||||
		this->started = true;
 | 
							this->started = true;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
						case SPA_NODE_COMMAND_Suspend:
 | 
				
			||||||
 | 
							/* fallthrough */
 | 
				
			||||||
	case SPA_NODE_COMMAND_Pause:
 | 
						case SPA_NODE_COMMAND_Pause:
 | 
				
			||||||
		this->started = false;
 | 
							this->started = false;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue