static enum afs_socket_status afsss;
+static int need_to_request_new_audio_file(void)
+{
+ if (map) /* have audio file */
+ return 0;
+ if (!vss_playing()) /* don't need one */
+ return 0;
+ if (mmd->new_vss_status_flags & VSS_NOMORE)
+ return 0;
+ if (afsss == AFS_SOCKET_AFD_PENDING) /* already requested one */
+ return 0;
+ return 1;
+}
+
/**
* Compute the timeout for para_server's main select-loop.
*
int i;
struct timeval *tv;
- para_fd_set(afs_socket, rfds, max_fileno);
if (!map)
for (i = 0; senders[i].name; i++)
senders[i].shutdown_clients();
mmd->current_chunk = mmd->repos_request;
}
tv = vss_compute_timeout();
- if (tv)
- goto out;
- if (!map && vss_playing() &&
- !(mmd->new_vss_status_flags & VSS_NOMORE)) {
- if (afsss != AFS_SOCKET_AFD_PENDING) {
- PARA_DEBUG_LOG("ready and playing, but no audio file\n");
- para_fd_set(afs_socket, wfds, max_fileno);
- afsss = AFS_SOCKET_CHECK_FOR_WRITE;
- }
- }
out:
+ if (need_to_request_new_audio_file()) {
+ PARA_DEBUG_LOG("ready and playing, but no audio file\n");
+ para_fd_set(afs_socket, wfds, max_fileno);
+ afsss = AFS_SOCKET_CHECK_FOR_WRITE;
+ } else
+ para_fd_set(afs_socket, rfds, max_fileno);
return tv;
}
{
int ret;
- if (FD_ISSET(afs_socket, rfds))
- recv_afs_result();
- if (afsss != AFS_SOCKET_CHECK_FOR_WRITE || !FD_ISSET(afs_socket, wfds))
+ if (afsss != AFS_SOCKET_CHECK_FOR_WRITE) {
+ if (FD_ISSET(afs_socket, rfds))
+ recv_afs_result();
+ return;
+ }
+ if (!FD_ISSET(afs_socket, wfds))
return;
PARA_NOTICE_LOG("requesting new fd from afs\n");
ret = send_buffer(afs_socket, "new");
afsss = AFS_SOCKET_AFD_PENDING;
}
+
/**
* Get the data of the given chunk.
*