Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b024bbf6 authored by Colin Cross's avatar Colin Cross Committed by Android Git Automerger
Browse files

am 6da66ef4: Merge "Handle screendumps for all framebuffer sizes"

* commit '6da66ef4':
  Handle screendumps for all framebuffer sizes
parents 0e9abad8 6da66ef4
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -55,13 +55,13 @@ struct fbinfo {
void framebuffer_service(int fd, void *cookie)
void framebuffer_service(int fd, void *cookie)
{
{
    struct fbinfo fbinfo;
    struct fbinfo fbinfo;
    unsigned int i;
    unsigned int i, bsize;
    char buf[640];
    char buf[640];
    int fd_screencap;
    int fd_screencap;
    int w, h, f;
    int w, h, f;
    int fds[2];
    int fds[2];


    if (pipe(fds) < 0) goto done;
    if (pipe(fds) < 0) goto pipefail;


    pid_t pid = fork();
    pid_t pid = fork();
    if (pid < 0) goto done;
    if (pid < 0) goto done;
@@ -164,17 +164,19 @@ void framebuffer_service(int fd, void *cookie)
    if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;
    if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;


    /* write data */
    /* write data */
    for(i = 0; i < fbinfo.size; i += sizeof(buf)) {
    for(i = 0; i < fbinfo.size; i += bsize) {
      if(readx(fd_screencap, buf, sizeof(buf))) goto done;
      bsize = sizeof(buf);
      if(writex(fd, buf, sizeof(buf))) goto done;
      if (i + bsize > fbinfo.size)
        bsize = fbinfo.size - i;
      if(readx(fd_screencap, buf, bsize)) goto done;
      if(writex(fd, buf, bsize)) goto done;
    }
    }
    if(readx(fd_screencap, buf, fbinfo.size % sizeof(buf))) goto done;
    if(writex(fd, buf, fbinfo.size % sizeof(buf))) goto done;


done:
done:
    TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
    TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));


    close(fds[0]);
    close(fds[0]);
    close(fds[1]);
    close(fds[1]);
pipefail:
    close(fd);
    close(fd);
}
}