mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: libcamera: source: clear buffers when format is changed
pipewire assumes that the buffers are removed from a port when its format is
changed even without an explicit call to `port_use_buffer()`.
So if the format is not just tested, clear the buffers, as well as the libcamera
requests and buffers because they are also recreated when a new format is set.
This matches the behaviour of the v4l2 plugin. Furthermore, this change also
removes the call to `spa_libcamera_use_buffers()` because that function does
nothing. And finally this change necessitates that the current format is always
reset (when not testing), not just before reaching `spa_libcamera_set_format()`.
(cherry picked from commit c517e712ed)
			
			
This commit is contained in:
		
							parent
							
								
									a6ec4521f7
								
							
						
					
					
						commit
						657e55a65b
					
				
					 1 changed files with 5 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1836,16 +1836,16 @@ int port_set_format(struct impl *impl, struct port *port,
 | 
			
		|||
{
 | 
			
		||||
	const bool try_only = SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_TEST_ONLY);
 | 
			
		||||
 | 
			
		||||
	if (format == nullptr) {
 | 
			
		||||
		if (try_only || !port->current_format)
 | 
			
		||||
			return 0;
 | 
			
		||||
 | 
			
		||||
	if (!try_only) {
 | 
			
		||||
		spa_libcamera_stream_off(impl);
 | 
			
		||||
		spa_libcamera_clear_buffers(impl, port);
 | 
			
		||||
		freeBuffers(impl, port);
 | 
			
		||||
		port->current_format.reset();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		spa_libcamera_close(impl);
 | 
			
		||||
	if (format == nullptr) {
 | 
			
		||||
		if (!try_only)
 | 
			
		||||
			spa_libcamera_close(impl);
 | 
			
		||||
	} else {
 | 
			
		||||
		spa_video_info info;
 | 
			
		||||
		int res;
 | 
			
		||||
| 
						 | 
				
			
			@ -1882,11 +1882,6 @@ int port_set_format(struct impl *impl, struct port *port,
 | 
			
		|||
			return -EINVAL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (port->current_format && !try_only) {
 | 
			
		||||
			spa_libcamera_use_buffers(impl, port, nullptr, 0);
 | 
			
		||||
			port->current_format.reset();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		res = spa_libcamera_set_format(impl, port, &info, try_only);
 | 
			
		||||
		if (res < 0)
 | 
			
		||||
			return res;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue