]> uap-core.de Git - uwplayer.git/commitdiff
don't close the log pipe, because this can fuckup mpv
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 22 Jan 2022 21:42:55 +0000 (22:42 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 22 Jan 2022 21:42:55 +0000 (22:42 +0100)
application/player.c

index 8c1909cb8c6e50307ff1b31e195bde44f992f1ad..d9a88ce8142d3cced02feaba10364de727ea11a3 100644 (file)
@@ -108,6 +108,8 @@ static void* wait_for_process(void *data) {
     Player *player = data;
     int status = 0;
     waitpid(player->process, &status, 0);
+    
+    printf("waitpid: %d\n", status);
 
     player->isactive = FALSE;
     player->status = status;
@@ -143,7 +145,7 @@ static int start_player_process(Player *player, MainWindow *win) {
     args[ac++] = player_bin;
     args[ac++] = "-wid";
     args[ac++] = wid_arg;
-    args[ac++] = "--no-terminal";
+    //args[ac++] = "--no-terminal";
     args[ac++] = "--player-operation-mode=pseudo-gui";
     args[ac++] = log_arg;
     args[ac++] = ipc_arg;
@@ -215,7 +217,7 @@ static int wait_for_ipc(Player *player) {
     return 0;
 }
 
-static int connect_to_ipc(Player *player) {
+static int connect_to_ipc(Player *player) {  
     // connect to IPC socket
     int fd_ipc = socket(AF_UNIX, SOCK_STREAM, 0);
     if(fd_ipc < 0) {
@@ -256,7 +258,7 @@ static void* start_player(void *data) {
         PlayerDestroy(player);
         return NULL;
     }
-    close(player->log);
+    //close(player->log);
      
     if(connect_to_ipc(player)) {
         PlayerDestroy(player);
@@ -280,8 +282,11 @@ static void player_io(Player *p) {
     fds[0].fd = p->ipc;
     fds[0].events = POLLIN;
     fds[0].revents = 0;
+    fds[1].fd = p->log;
+    fds[1].events = POLLIN;
+    fds[1].revents = 0;
     JSONParser *js = json_parser_new();
-    
+     
     char buf[PLAYER_IN_BUFSIZE];
     while(p->isactive && poll(fds, 2, PLAYER_POLL_TIMEOUT)) {
         if(fds[0].revents == POLLIN) {
@@ -305,8 +310,12 @@ static void player_io(Player *p) {
                 break;
             }
         }
+        if(fds[1].revents == POLLIN) {
+            // just read to clean the log pipe
+            read(fds[1].fd, buf, PLAYER_IN_BUFSIZE);
+        }
         
-        char *cmd = "{ \"command\": [\"get_property\", \"playback-time\"], request_id=\"" REQ_ID_PLAYBACK_TIME "\" }\n";
+        //char *cmd = "{ \"command\": [\"get_property\", \"playback-time\"], request_id=\"" REQ_ID_PLAYBACK_TIME "\" }\n";
         //write(p->ipc, cmd, strlen(cmd));
     }