mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: libcamera: source: store the request pointer in ring buffer
The request will be needed later, so store that directly in the
completion ring buffer for easy access.
This is fine even though `impl::requestComplete()` calls `Request::reuse()`
because only the request cookie is used in `libcamera_on_fd_events()` and
that remains constant during the lifetime of a request object.
(cherry picked from commit 099292d63d)
			
			
This commit is contained in:
		
							parent
							
								
									c80af0c2c0
								
							
						
					
					
						commit
						ad1dbf1541
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
					@ -80,7 +80,7 @@ struct port {
 | 
				
			||||||
	uint32_t n_buffers = 0;
 | 
						uint32_t n_buffers = 0;
 | 
				
			||||||
	struct spa_list queue;
 | 
						struct spa_list queue;
 | 
				
			||||||
	struct spa_ringbuffer ring = SPA_RINGBUFFER_INIT();
 | 
						struct spa_ringbuffer ring = SPA_RINGBUFFER_INIT();
 | 
				
			||||||
	uint32_t ring_ids[MAX_BUFFERS];
 | 
						libcamera::Request *ring_ids[MAX_BUFFERS];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static constexpr uint64_t info_all = SPA_PORT_CHANGE_MASK_FLAGS |
 | 
						static constexpr uint64_t info_all = SPA_PORT_CHANGE_MASK_FLAGS |
 | 
				
			||||||
		SPA_PORT_CHANGE_MASK_PROPS | SPA_PORT_CHANGE_MASK_PARAMS;
 | 
							SPA_PORT_CHANGE_MASK_PROPS | SPA_PORT_CHANGE_MASK_PARAMS;
 | 
				
			||||||
| 
						 | 
					@ -1042,9 +1042,11 @@ void libcamera_on_fd_events(struct spa_source *source)
 | 
				
			||||||
		spa_log_error(impl->log, "nothing is queued");
 | 
							spa_log_error(impl->log, "nothing is queued");
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	buffer_id = port->ring_ids[index & MASK_BUFFERS];
 | 
					
 | 
				
			||||||
 | 
						auto *request = port->ring_ids[index & MASK_BUFFERS];
 | 
				
			||||||
	spa_ringbuffer_read_update(&port->ring, index + 1);
 | 
						spa_ringbuffer_read_update(&port->ring, index + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						buffer_id = request->cookie();
 | 
				
			||||||
	b = &port->buffers[buffer_id];
 | 
						b = &port->buffers[buffer_id];
 | 
				
			||||||
	spa_list_append(&port->queue, &b->link);
 | 
						spa_list_append(&port->queue, &b->link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1286,7 +1288,7 @@ void impl::requestComplete(libcamera::Request *request)
 | 
				
			||||||
	request->reuse(libcamera::Request::ReuseFlag::ReuseBuffers);
 | 
						request->reuse(libcamera::Request::ReuseFlag::ReuseBuffers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_ringbuffer_get_write_index(&port->ring, &index);
 | 
						spa_ringbuffer_get_write_index(&port->ring, &index);
 | 
				
			||||||
	port->ring_ids[index & MASK_BUFFERS] = buffer_id;
 | 
						port->ring_ids[index & MASK_BUFFERS] = request;
 | 
				
			||||||
	spa_ringbuffer_write_update(&port->ring, index + 1);
 | 
						spa_ringbuffer_write_update(&port->ring, index + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (spa_system_eventfd_write(impl->system, impl->source.fd, 1) < 0)
 | 
						if (spa_system_eventfd_write(impl->system, impl->source.fd, 1) < 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue