int i;
char *tmp;
+ PARA_NOTICE_LOG("EOF\n");
if (!map) {
for (i = 0; senders[i].name; i++)
senders[i].shutdown_clients();
static enum afs_socket_status afsss;
/**
- * compute the timeout for para_server's main select-loop
+ * Compute the timeout for para_server's main select-loop.
*
* This function gets called from para_server to determine the timeout value
* for its main select loop.
* and acted upon by calling appropriate functions from the lower layers.
* Possible actions include
*
- * - request a new file list from the current audio file selector
- * - shutdown of all senders (stop/pause command)
- * - reposition the stream (ff/jmp command)
+ * - request a new audio file from afs,
+ * - shutdown of all senders (stop/pause command),
+ * - reposition the stream (ff/jmp command).
*
* \return A pointer to a struct timeval containing the timeout for the next
* chunk of data to be sent, or NULL if we're not sending right now.
*/
struct timeval *vss_preselect(fd_set *rfds, fd_set *wfds, int *max_fileno)
{
- struct audio_format_handler *af = NULL;
- int i, format;
- struct timeval *ret;
+ int i;
+ struct timeval *tv;
para_fd_set(afs_socket, rfds, max_fileno);
-
-//again:
- format = mmd->audio_format;
- if (format >= 0)
- af = afl + format;
- else
+ if (!map)
for (i = 0; senders[i].name; i++)
senders[i].shutdown_clients();
- if (vss_next() && af) {
- vss_eof();
- return vss_compute_timeout();
+ else {
+ if (vss_next()) {
+ vss_eof();
+ return vss_compute_timeout();
+ }
}
if (vss_paused() || vss_repos()) {
for (i = 0; senders[i].name; i++)
senders[i].shutdown_clients();
- if (af) {
+ if (map) {
struct timeval now;
gettimeofday(&now, NULL);
if (!vss_paused() || mmd->chunks_sent)
mmd->new_vss_status_flags &= ~(VSS_REPOS);
mmd->current_chunk = mmd->repos_request;
}
- ret = vss_compute_timeout();
- if (!ret && !map && vss_playing() &&
+ tv = vss_compute_timeout();
+ if (tv)
+ return tv;
+ if (!map && vss_playing() &&
!(mmd->new_vss_status_flags & VSS_NOMORE)) {
PARA_DEBUG_LOG("%s", "ready and playing, but no audio file\n");
- //vss_get_audio_file();
if (afsss == AFS_SOCKET_READY) {
para_fd_set(afs_socket, wfds, max_fileno);
afsss = AFS_SOCKET_CHECK_FOR_WRITE;
}
-// goto again;
}
- return ret;
+ return tv;
}
static int recv_afs_msg(int *fd, uint32_t *code, uint32_t *data)
struct stat statbuf;
struct timeval now;
+ PARA_NOTICE_LOG("recv\n");
ret = recv_afs_msg(&passed_fd, &afs_code, &afs_data);
if (ret < 0)
goto err;
recv_afs_result();
if (afsss != AFS_SOCKET_CHECK_FOR_WRITE || !FD_ISSET(afs_socket, wfds))
return;
+ PARA_NOTICE_LOG("requesting new socket\n");
ret = send_buffer(afs_socket, "new");
afsss = AFS_SOCKET_AFD_PENDING;
}
size_t pos = mmd->afi.chunk_table[chunk_num];
*buf = map + pos;
*len = mmd->afi.chunk_table[chunk_num + 1] - pos;
+
+ if (chunk_num + 5 > mmd->afd.afhi.chunks_total)
+ PARA_NOTICE_LOG("chunk %lu/%lu\n, len: %zu\n", chunk_num,
+ mmd->afd.afhi.chunks_total, *len);
}
/**
int i;
struct audio_format_handler *af;
struct timeval now, due;
+ char *buf;
+ size_t len;
if (mmd->audio_format < 0 || !map || !vss_playing())
return;
mmd->offset = tv2ms(&tmp);
mmd->events++;
}
- for (i = 0; senders[i].name; i++) {
- char *buf;
- size_t len;
- get_chunk(mmd->current_chunk, &buf, &len);
+ get_chunk(mmd->current_chunk, &buf, &len);
+ for (i = 0; senders[i].name; i++)
senders[i].send(mmd->current_chunk, mmd->chunks_sent, buf, len);
- }
mmd->new_vss_status_flags |= VSS_PLAYING;
mmd->chunks_sent++;
mmd->current_chunk++;