commit - 3ad8bae849a3a44cbdde1c62f087b654a8439a74
commit + c2f554ff612cef4c72eea5a7da22d508b8c36d3c
blob - 12582d003f7216af6f4842e8920156b0cc644311
blob + 0686e1258936c821114600db32ee00b4d1a7f0fa
--- player.c
+++ player.c
/* process only one message */
static int
-player_dispatch(int64_t *s)
+player_dispatch(int64_t *s, int wait)
{
struct player_seek seek;
struct pollfd pfd;
if ((n = imsg_get(ibuf, &imsg)) == -1)
fatal("imsg_get");
if (n == 0) {
+ if (!wait)
+ return -1;
+
pfd.fd = ibuf->fd;
pfd.events = POLLIN;
if (poll(&pfd, 1, INFTIM) == -1)
{
int r;
- r = player_dispatch(s);
+ r = player_dispatch(s, 1);
return r == IMSG_RESUME || r == IMSG_CTL_SEEK;
}
static int
-player_shouldstop(int64_t *s)
+player_shouldstop(int64_t *s, int wait)
{
- switch (player_dispatch(s)) {
+ switch (player_dispatch(s, wait)) {
case IMSG_PAUSE:
if (player_pause(s))
break;
play(const void *buf, size_t len, int64_t *s)
{
size_t w;
- int nfds, revents, r;
+ int nfds, revents, r, wait;
*s = -1;
while (len != 0) {
if (r == -1)
fatal("poll");
- if (player_pfds[0].revents & (POLLHUP|POLLIN)) {
- if (player_shouldstop(s)) {
- sio_flush(hdl);
- stopped = 1;
- return 0;
- }
+ wait = player_pfds[0].revents & (POLLHUP|POLLIN);
+ if (player_shouldstop(s, wait)) {
+ sio_flush(hdl);
+ stopped = 1;
+ return 0;
}
revents = sio_revents(hdl, player_pfds + 1);
const char *errstr = NULL;
while (nextfd == -1)
- player_dispatch(NULL);
+ player_dispatch(NULL, 1);
r = player_playnext(&errstr);
if (r == -1)