#ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ #include #include #include #include #include #include #include #include "conf.h" #include "dir.h" #include "err.h" #include "player.h" #include "queue.h" /* Start playing item. * The exit functions should realy return error codes * but juke work that way that if a player returns an * error code. It's asumed to be because it failed to * open an audio device and the player is restarted. * We don't want that here. */ pid_t player_play (struct CONFIG *cfg, struct DIR_INFO *dinfo, int item) { int fd, i, args, format; char *path, *arg_list[CFG_ARGS], **s; pid_t pid; format = dinfo->item[item].type - 1; args = cfg->format[format].args; path = dir_build_path (dinfo, item); s = cfg->format[format].arg_list; for (i=0; ipid) { rpid = waitpid (p->pid, &status, WNOHANG | WUNTRACED); if (!rpid) return -1; if (rpid == p->pid) { if (WIFEXITED (status)) return (WEXITSTATUS (status)); else return 1; } } return 0; } /* Kill the player's process group and wait. */ void player_kill (struct PLAYER *p) { if (p->kill) { if (p->paused) kill (-p->kill, SIGCONT); kill (-p->kill, SIGTERM); waitpid (-p->kill, 0, 0); p->kill = 0; } } /* Send stop signal to the player's process group. */ void player_stop (struct PLAYER *p) { if (p->pid) kill (-p->pid, SIGSTOP); } /* Send continue signal to the player's process group. */ void player_cont (struct PLAYER *p) { if (p->pid) kill (-p->pid, SIGCONT); }