mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	context: improve negotiation
When a port doesn't implement the EnumFormat param, use NULL as the filter or the filter as the result.
This commit is contained in:
		
							parent
							
								
									591244c53e
								
							
						
					
					
						commit
						fc49c1697a
					
				
					 1 changed files with 23 additions and 16 deletions
				
			
		| 
						 | 
					@ -697,12 +697,15 @@ int pw_context_find_format(struct pw_context *context,
 | 
				
			||||||
						     input->direction, input->port_id,
 | 
											     input->direction, input->port_id,
 | 
				
			||||||
						     SPA_PARAM_EnumFormat, &iidx,
 | 
											     SPA_PARAM_EnumFormat, &iidx,
 | 
				
			||||||
						     filter, format, builder)) <= 0) {
 | 
											     filter, format, builder)) <= 0) {
 | 
				
			||||||
			if (res < 0)
 | 
								if (res == -ENOENT || res == 0) {
 | 
				
			||||||
 | 
									pw_log_debug(NAME" %p: no input format filter, using output format: %s",
 | 
				
			||||||
 | 
											context, spa_strerror(res));
 | 
				
			||||||
 | 
									*format = filter;
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
				*error = spa_aprintf("error input enum formats: %s", spa_strerror(res));
 | 
									*error = spa_aprintf("error input enum formats: %s", spa_strerror(res));
 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				*error = spa_aprintf("no input formats");
 | 
					 | 
				
			||||||
				goto error;
 | 
									goto error;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else if (out_state >= PW_IMPL_PORT_STATE_CONFIGURE && in_state > PW_IMPL_PORT_STATE_CONFIGURE) {
 | 
						} else if (out_state >= PW_IMPL_PORT_STATE_CONFIGURE && in_state > PW_IMPL_PORT_STATE_CONFIGURE) {
 | 
				
			||||||
		/* only output needs format */
 | 
							/* only output needs format */
 | 
				
			||||||
		spa_pod_builder_init(&fb, fbuf, sizeof(fbuf));
 | 
							spa_pod_builder_init(&fb, fbuf, sizeof(fbuf));
 | 
				
			||||||
| 
						 | 
					@ -723,12 +726,15 @@ int pw_context_find_format(struct pw_context *context,
 | 
				
			||||||
						     output->direction, output->port_id,
 | 
											     output->direction, output->port_id,
 | 
				
			||||||
						     SPA_PARAM_EnumFormat, &oidx,
 | 
											     SPA_PARAM_EnumFormat, &oidx,
 | 
				
			||||||
						     filter, format, builder)) <= 0) {
 | 
											     filter, format, builder)) <= 0) {
 | 
				
			||||||
			if (res < 0)
 | 
								if (res == -ENOENT || res == 0) {
 | 
				
			||||||
 | 
									pw_log_debug(NAME" %p: no output format filter, using input format: %s",
 | 
				
			||||||
 | 
											context, spa_strerror(res));
 | 
				
			||||||
 | 
									*format = filter;
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
				*error = spa_aprintf("error output enum formats: %s", spa_strerror(res));
 | 
									*error = spa_aprintf("error output enum formats: %s", spa_strerror(res));
 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				*error = spa_aprintf("no output format");
 | 
					 | 
				
			||||||
				goto error;
 | 
									goto error;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else if (in_state == PW_IMPL_PORT_STATE_CONFIGURE && out_state == PW_IMPL_PORT_STATE_CONFIGURE) {
 | 
						} else if (in_state == PW_IMPL_PORT_STATE_CONFIGURE && out_state == PW_IMPL_PORT_STATE_CONFIGURE) {
 | 
				
			||||||
	      again:
 | 
						      again:
 | 
				
			||||||
		/* both ports need a format */
 | 
							/* both ports need a format */
 | 
				
			||||||
| 
						 | 
					@ -738,16 +744,17 @@ int pw_context_find_format(struct pw_context *context,
 | 
				
			||||||
						     input->direction, input->port_id,
 | 
											     input->direction, input->port_id,
 | 
				
			||||||
						     SPA_PARAM_EnumFormat, &iidx,
 | 
											     SPA_PARAM_EnumFormat, &iidx,
 | 
				
			||||||
						     NULL, &filter, &fb)) != 1) {
 | 
											     NULL, &filter, &fb)) != 1) {
 | 
				
			||||||
			if (res == 0 && iidx == 0) {
 | 
								if (res == -ENOENT) {
 | 
				
			||||||
				*error = spa_aprintf("no compatible formats");
 | 
									pw_log_debug(NAME" %p: no input filter", context);
 | 
				
			||||||
				goto error;
 | 
									filter = NULL;
 | 
				
			||||||
			}
 | 
								} else {
 | 
				
			||||||
				if (res < 0)
 | 
									if (res < 0)
 | 
				
			||||||
					*error = spa_aprintf("error input enum formats: %s", spa_strerror(res));
 | 
										*error = spa_aprintf("error input enum formats: %s", spa_strerror(res));
 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
					*error = spa_aprintf("no more input formats");
 | 
										*error = spa_aprintf("no more input formats");
 | 
				
			||||||
				goto error;
 | 
									goto error;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		pw_log_debug(NAME" %p: enum output %d with filter: %p", context, oidx, filter);
 | 
							pw_log_debug(NAME" %p: enum output %d with filter: %p", context, oidx, filter);
 | 
				
			||||||
		pw_log_format(SPA_LOG_LEVEL_DEBUG, filter);
 | 
							pw_log_format(SPA_LOG_LEVEL_DEBUG, filter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -755,7 +762,7 @@ int pw_context_find_format(struct pw_context *context,
 | 
				
			||||||
						     output->direction, output->port_id,
 | 
											     output->direction, output->port_id,
 | 
				
			||||||
						     SPA_PARAM_EnumFormat, &oidx,
 | 
											     SPA_PARAM_EnumFormat, &oidx,
 | 
				
			||||||
						     filter, format, builder)) != 1) {
 | 
											     filter, format, builder)) != 1) {
 | 
				
			||||||
			if (res == 0) {
 | 
								if (res == 0 && filter != NULL) {
 | 
				
			||||||
				oidx = 0;
 | 
									oidx = 0;
 | 
				
			||||||
				goto again;
 | 
									goto again;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue