mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	v4l2: always stop and clear buffer when setting a format
The caller frees the buffers after setting a new format.
This commit is contained in:
		
							parent
							
								
									8f8083b963
								
							
						
					
					
						commit
						6e74edc14e
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
					@ -576,12 +576,14 @@ static int port_set_format(void *object,
 | 
				
			||||||
	struct port *port = GET_PORT(this, direction, port_id);
 | 
						struct port *port = GET_PORT(this, direction, port_id);
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (port->have_format) {
 | 
				
			||||||
 | 
							spa_v4l2_stream_off(this);
 | 
				
			||||||
 | 
							spa_v4l2_clear_buffers(this);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (format == NULL) {
 | 
						if (format == NULL) {
 | 
				
			||||||
		if (!port->have_format)
 | 
							if (!port->have_format)
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_v4l2_stream_off(this);
 | 
					 | 
				
			||||||
		spa_v4l2_clear_buffers(this);
 | 
					 | 
				
			||||||
		port->have_format = false;
 | 
							port->have_format = false;
 | 
				
			||||||
		port->dev.have_format = false;
 | 
							port->dev.have_format = false;
 | 
				
			||||||
		spa_v4l2_close(&port->dev);
 | 
							spa_v4l2_close(&port->dev);
 | 
				
			||||||
| 
						 | 
					@ -634,15 +636,14 @@ static int port_set_format(void *object,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (port->have_format && !(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
 | 
						if (port->have_format && !SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
 | 
				
			||||||
		spa_v4l2_use_buffers(this, NULL, 0);
 | 
					 | 
				
			||||||
		port->have_format = false;
 | 
							port->have_format = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (spa_v4l2_set_format(this, &info, flags) < 0)
 | 
						if (spa_v4l2_set_format(this, &info, flags) < 0)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
 | 
						if (!SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
 | 
				
			||||||
		port->current_format = info;
 | 
							port->current_format = info;
 | 
				
			||||||
		port->have_format = true;
 | 
							port->have_format = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue