aboutsummaryrefslogtreecommitdiff
path: root/kms/client/kms_client.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-22 04:58:41 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-22 04:58:41 +0200
commitb5b4d6b2bdd1809b2e8af0b7ddec32a8d4f88e9a (patch)
tree4046ff268eb26106a8030e40a619d7ff96d7a27f /kms/client/kms_client.c
parentb077177081c61bce1b1e5247389a09383369a827 (diff)
Fix portal capture on intel, support multiple planes in one egl image (might fix capture on intel iris)
Diffstat (limited to 'kms/client/kms_client.c')
-rw-r--r--kms/client/kms_client.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c
index b579b50..966fa5e 100644
--- a/kms/client/kms_client.c
+++ b/kms/client/kms_client.c
@@ -36,11 +36,17 @@ static bool generate_random_characters(char *buffer, int buffer_size, const char
}
static void close_fds(gsr_kms_response *response) {
- for(int i = 0; i < response->num_fds; ++i) {
- if(response->fds[i].fd > 0)
- close(response->fds[i].fd);
- response->fds[i].fd = 0;
+ for(int i = 0; i < response->num_items; ++i) {
+ for(int j = 0; j < response->items[i].num_dma_bufs; ++j) {
+ gsr_kms_response_dma_buf *dma_buf = &response->items[i].dma_buf[j];
+ if(dma_buf->fd > 0) {
+ close(dma_buf->fd);
+ dma_buf->fd = -1;
+ }
+ }
+ response->items[i].num_dma_bufs = 0;
}
+ response->num_items = 0;
}
static int send_msg_to_server(int server_fd, gsr_kms_request *request) {
@@ -82,7 +88,7 @@ static int recv_msg_from_server(int server_pid, int server_fd, gsr_kms_response
response_message.msg_iov = &iov;
response_message.msg_iovlen = 1;
- char cmsgbuf[CMSG_SPACE(sizeof(int) * GSR_KMS_MAX_PLANES)];
+ char cmsgbuf[CMSG_SPACE(sizeof(int) * GSR_KMS_MAX_ITEMS)];
memset(cmsgbuf, 0, sizeof(cmsgbuf));
response_message.msg_control = cmsgbuf;
response_message.msg_controllen = sizeof(cmsgbuf);
@@ -106,12 +112,16 @@ static int recv_msg_from_server(int server_pid, int server_fd, gsr_kms_response
}
}
- if(res > 0 && response->num_fds > 0) {
+ if(res > 0 && response->num_items > 0) {
struct cmsghdr *cmsg = CMSG_FIRSTHDR(&response_message);
if(cmsg) {
int *fds = (int*)CMSG_DATA(cmsg);
- for(int i = 0; i < response->num_fds; ++i) {
- response->fds[i].fd = fds[i];
+ int fd_index = 0;
+ for(int i = 0; i < response->num_items; ++i) {
+ for(int j = 0; j < response->items[i].num_dma_bufs; ++j) {
+ gsr_kms_response_dma_buf *dma_buf = &response->items[i].dma_buf[j];
+ dma_buf->fd = fds[fd_index++];
+ }
}
} else {
close_fds(response);