mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: libcamera: source: allocBuffers(): more error checking
First, check if the request pool is empty, and signal an error if it is not. Second, ensure that the number of allocated buffers matches.
This commit is contained in:
parent
348e703be0
commit
29b0c87d71
1 changed files with 11 additions and 2 deletions
|
|
@ -307,10 +307,19 @@ int allocBuffers(struct impl *impl, struct port *port, unsigned int count)
|
|||
libcamera::Stream *stream = port->streamConfig.stream();
|
||||
int res;
|
||||
|
||||
if (!impl->requestPool.empty())
|
||||
return -EBUSY;
|
||||
|
||||
if ((res = impl->allocator->allocate(stream)) < 0)
|
||||
return res;
|
||||
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
const auto& bufs = impl->allocator->buffers(stream);
|
||||
if (bufs.empty() || bufs.size() != count) {
|
||||
res = -ENOBUFS;
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < bufs.size(); i++) {
|
||||
std::unique_ptr<Request> request = impl->camera->createRequest(i);
|
||||
if (!request) {
|
||||
res = -ENOMEM;
|
||||
|
|
@ -324,7 +333,7 @@ int allocBuffers(struct impl *impl, struct port *port, unsigned int count)
|
|||
* video frame has to be addressed using more than one memory.
|
||||
* address. Therefore, need calculate the number of discontiguous
|
||||
* memory and allocate the specified amount of memory */
|
||||
port->buffers_blocks = count_unique_fds(impl->allocator->buffers(stream).front()->planes());
|
||||
port->buffers_blocks = count_unique_fds(bufs.front()->planes());
|
||||
if (port->buffers_blocks <= 0) {
|
||||
res = -ENOBUFS;
|
||||
goto err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue