return 0;
}
+static void* wait_for_process(void *data) {
+ Player *player = data;
+ int status = 0;
+ waitpid(player->process, &status, 0);
+
+ player->isactive = FALSE;
+ player->status = status;
+
+ return NULL;
+}
+
static int start_player_process(Player *player, MainWindow *win) {
char log_arg[STR_BUFSIZE];
char ipc_arg[STR_BUFSIZE];
player->process = player_pid;
player->isactive = TRUE;
+ pthread_t tid;
+ if(pthread_create(&tid, NULL, wait_for_process, player)) {
+ perror("pthread_create");
+ }
+
return 0;
}
JSONParser *js = json_parser_new();
char buf[PLAYER_IN_BUFSIZE];
- while(poll(fds, 2, PLAYER_POLL_TIMEOUT)) {
+ while(p->isactive && poll(fds, 2, PLAYER_POLL_TIMEOUT)) {
if(fds[0].revents == POLLIN) {
// clean up fifo
read(fds[0].fd, buf, PLAYER_IN_BUFSIZE);
char *cmd = "{ \"command\": [\"get_property\", \"playback-time\"], request_id=\"" REQ_ID_PLAYBACK_TIME "\" }\n";
//write(p->ipc, cmd, strlen(cmd));
}
+
+ printf("PlayerEnd\n");
+ fflush(stdout);
}
"{ \"command\": [\"get_property\", \"width\"], request_id=\"" REQ_ID_WIDTH "\" }\n"
"{ \"command\": [\"get_property\", \"height\"], request_id=\"" REQ_ID_HEIGHT "\" }\n";
write(p->ipc, cmd, strlen(cmd));
+ } else if(!json_strcmp(event, "end-file")) {
+ JSONValue *reason = json_obj_get(&v->value.object, "reason");
+ if(reason && !json_strcmp(reason, "eof")) {
+ PlayerEOF(p);
+ }
}
}
}
}
+void PlayerEOF(Player *p) {
+ char *cmd = "{ \"command\": [\"set_property\", \"pause\"], true }\n";
+ //write(p->ipc, cmd, strlen(cmd));
+}