2 * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file vss.c The virtual streaming system.
9 * This contains the audio streaming code of para_server which is independent
10 * of the current audio format, audio file selector and of the activated
18 #include "portable_io.h"
25 #include "server.cmdline.h"
33 extern struct misc_meta_data
*mmd
;
35 extern void dccp_send_init(struct sender
*);
36 extern void http_send_init(struct sender
*);
37 extern void udp_send_init(struct sender
*);
39 /** The list of supported senders. */
40 struct sender senders
[] = {
43 .init
= http_send_init
,
47 .init
= dccp_send_init
,
51 .init
= udp_send_init
,
58 /** The possible states of the afs socket. */
59 enum afs_socket_status
{
60 /** Socket is inactive. */
62 /** Socket fd was included in the write fd set for select(). */
63 AFS_SOCKET_CHECK_FOR_WRITE
,
64 /** vss wrote a request to the socket and waits for reply from afs. */
65 AFS_SOCKET_AFD_PENDING
68 /** The task structure for the virtual streaming system. */
70 /** Copied from the -announce_time command line option. */
71 struct timeval announce_tv
;
72 /** End of the announcing interval. */
73 struct timeval data_send_barrier
;
74 /** End of the EOF interval. */
75 struct timeval eof_barrier
;
76 /** Only used if --autoplay_delay was given. */
77 struct timeval autoplay_barrier
;
78 /** Used for afs-server communication. */
80 /** The current state of \a afs_socket. */
81 enum afs_socket_status afsss
;
82 /** The memory mapped audio file. */
84 /** Used by the scheduler. */
86 /** Pointer to the header of the mapped audio file. */
87 const char *header_buf
;
88 /** Length of the audio file header. */
92 static struct list_head fec_client_list
;
102 uint32_t first_chunk
;
104 struct timeval duration
;
105 struct timeval start
;
106 struct timeval slice_duration
;
110 struct fec_client_parms
*fcp
;
111 struct fec_parms
*parms
;
112 struct list_head node
;
113 struct timeval stream_start
;
114 int first_stream_chunk
;
115 struct fec_group group
;
116 struct fec_slice slice
;
117 const unsigned char **src_data
;
118 unsigned char *extra_src_buf
;
119 size_t extra_src_buf_size
;
120 unsigned char *enc_buf
;
125 * Get the chunk time of the current audio file.
127 * \return A pointer to a struct containing the chunk time, or NULL,
128 * if currently no audio file is selected.
130 struct timeval
*vss_chunk_time(void)
132 if (mmd
->afd
.afhi
.chunk_tv
.tv_sec
== 0 &&
133 mmd
->afd
.afhi
.chunk_tv
.tv_usec
== 0)
135 return &mmd
->afd
.afhi
.chunk_tv
;
138 static void setup_fec_group(struct fec_client
*fc
, struct vss_task
*vsst
)
140 uint32_t num_bytes
= 0, chunk_num
, max_group_size
, last_payload_size
;
141 int i
, k
= fc
->fcp
->data_slices_per_group
;
142 const char *start_buf
= NULL
;
143 struct timeval tmp
, *chunk_tv
= vss_chunk_time();
146 max_group_size
= (fc
->fcp
->max_slice_bytes
- FEC_HEADER_SIZE
) * k
;
147 chunk_num
= fc
->group
.first_chunk
;
152 if (chunk_num
>= mmd
->afd
.afhi
.chunks_total
)
154 afh_get_chunk(chunk_num
, &mmd
->afd
.afhi
, vsst
->map
, &buf
, &len
);
157 if (num_bytes
+ len
> max_group_size
)
163 fc
->group
.num_chunks
= chunk_num
- fc
->group
.first_chunk
;
165 fc
->group
.bytes
= num_bytes
;
167 fc
->slice
.bytes
= ROUND_UP(num_bytes
, k
) / k
;
169 /* The last slice will not be fully used */
170 last_payload_size
= num_bytes
% fc
->slice
.bytes
;
171 if (!last_payload_size
)
172 last_payload_size
= fc
->slice
.bytes
;
174 tv_scale(fc
->group
.num_chunks
, chunk_tv
, &fc
->group
.duration
);
175 tv_scale(fc
->group
.first_chunk
- fc
->first_stream_chunk
, chunk_tv
,
177 tv_add(&fc
->stream_start
, &tmp
, &fc
->group
.start
);
178 tv_divide(fc
->fcp
->slices_per_group
, &fc
->group
.duration
,
179 &fc
->group
.slice_duration
);
181 for (i
= 0; i
< k
; i
++)
182 fc
->src_data
[i
] = (const unsigned char *)start_buf
183 + i
* fc
->slice
.bytes
;
185 if (start_buf
+ k
* fc
->slice
.bytes
> vsst
->map
+ mmd
->size
) {
186 /* can not use last slice as it goes beyond the map */
187 if (fc
->extra_src_buf_size
< fc
->slice
.bytes
)
188 fc
->extra_src_buf
= para_realloc(fc
->extra_src_buf
, fc
->slice
.bytes
);
189 memcpy(fc
->extra_src_buf
, start_buf
+ (k
- 1) * fc
->slice
.bytes
,
191 memset(fc
->extra_src_buf
+ last_payload_size
, 0,
192 fc
->slice
.bytes
- last_payload_size
);
193 fc
->src_data
[k
- 1] = fc
->extra_src_buf
;
199 * Write a fec header to a buffer.
201 * \param buf The buffer to write to.
202 * \param h The fec header to write.
204 static void write_fec_header(struct fec_client
*fc
)
206 char *buf
= (char *)fc
->enc_buf
;
208 write_u32(buf
, FEC_MAGIC
);
210 write_u8(buf
+ 4, fc
->fcp
->slices_per_group
);
211 write_u8(buf
+ 5, fc
->fcp
->data_slices_per_group
);
212 write_u32(buf
+ 6, (uint32_t)0); /* audio header len */
214 write_u32(buf
+ 10, fc
->group
.num
);
215 write_u32(buf
+ 14, fc
->group
.bytes
);
217 write_u8(buf
+ 18, fc
->slice
.num
);
218 write_u16(buf
+ 20, fc
->slice
.bytes
);
219 memset(buf
+ 22, 0, 11);
223 * Return a buffer that marks the end of the stream.
225 * \return The length of the eof buffer.
227 * This is used for (multicast) udp streaming where closing the socket on the
228 * sender might not give rise to an eof condition at the peer.
230 size_t vss_get_fec_eof_packet(const char **buf
)
232 static const char fec_eof_packet
[FEC_HEADER_SIZE
] =
233 "\xec\x0d\xcc\xfe\0\0\0\0"
237 *buf
= fec_eof_packet
;
238 return FEC_HEADER_SIZE
;
241 static void compute_next_fec_slice(struct fec_client
*fc
, struct vss_task
*vsst
)
243 if (fc
->first_stream_chunk
< 0) {
244 fc
->stream_start
= *now
;
245 fc
->first_stream_chunk
= mmd
->current_chunk
;
246 fc
->group
.first_chunk
= mmd
->current_chunk
;
248 setup_fec_group(fc
, vsst
);
249 } else if (fc
->slice
.num
== fc
->fcp
->slices_per_group
) {
250 fc
->group
.first_chunk
+= fc
->group
.num_chunks
;
251 setup_fec_group(fc
, vsst
);
254 if (fc
->enc_buf_size
< fc
->slice
.bytes
+ FEC_HEADER_SIZE
) {
255 fc
->enc_buf_size
= fc
->slice
.bytes
+ FEC_HEADER_SIZE
;
256 fc
->enc_buf
= para_realloc(fc
->enc_buf
, fc
->enc_buf_size
);
258 write_fec_header(fc
);
259 fec_encode(fc
->parms
, fc
->src_data
, fc
->enc_buf
+ FEC_HEADER_SIZE
,
260 fc
->slice
.num
, fc
->slice
.bytes
);
264 * Add one entry to the list of active fec clients.
266 * \param fcp Describes the fec parameters to be used for this client.
267 * \param result An opaque pointer that must be used by remove the client later.
271 int vss_add_fec_client(struct fec_client_parms
*fcp
, struct fec_client
**result
)
274 struct fec_client
*fc
;
276 if (fcp
->max_slice_bytes
< FEC_HEADER_SIZE
+ fcp
->data_slices_per_group
)
277 return -ERRNO_TO_PARA_ERROR(EINVAL
);
278 fc
= para_calloc(sizeof(*fc
));
280 ret
= fec_new(fcp
->data_slices_per_group
, fcp
->slices_per_group
,
284 fc
->first_stream_chunk
= -1; /* stream not yet started */
285 fc
->src_data
= para_malloc(fc
->fcp
->slices_per_group
* sizeof(char *));
286 para_list_add(&fc
->node
, &fec_client_list
);
297 * Remove one entry from the list of active fec clients.
299 * \param result The client to be removed.
301 void vss_del_fec_client(struct fec_client
*fc
)
306 free(fc
->extra_src_buf
);
312 * Compute if/when next slice is due. If it isn't due yet and \a diff is
313 * not \p Null, compute the time difference next - now, where
315 * next = stream_start + (first_group_chunk - first_stream_chunk)
316 * * chunk_time + slice_num * slice_time
318 static int next_slice_is_due(struct fec_client
*fc
, struct timeval
*diff
)
320 struct timeval tmp
, next
;
323 if (fc
->first_stream_chunk
< 0)
325 tv_scale(fc
->slice
.num
, &fc
->group
.slice_duration
, &tmp
);
326 tv_add(&tmp
, &fc
->group
.start
, &next
);
327 ret
= tv_diff(&next
, now
, diff
);
328 return ret
< 0? 1 : 0;
331 static void compute_slice_timeout(struct timeval
*timeout
)
333 struct fec_client
*fc
;
335 assert(vss_playing());
336 list_for_each_entry(fc
, &fec_client_list
, node
) {
339 if (next_slice_is_due(fc
, &diff
)) {
341 timeout
->tv_usec
= 0;
344 /* timeout = min(timeout, diff) */
345 if (tv_diff(&diff
, timeout
, NULL
) < 0)
351 * Check if vss status flag \a P (playing) is set.
353 * \return Greater than zero if playing, zero otherwise.
356 unsigned int vss_playing(void)
358 return mmd
->new_vss_status_flags
& VSS_PLAYING
;
362 * Check if the \a N (next) status flag is set.
364 * \return Greater than zero if set, zero if not.
367 unsigned int vss_next(void)
369 return mmd
->new_vss_status_flags
& VSS_NEXT
;
373 * Check if a reposition request is pending.
375 * \return Greater than zero if true, zero otherwise.
378 unsigned int vss_repos(void)
380 return mmd
->new_vss_status_flags
& VSS_REPOS
;
384 * Check if the vss is currently paused.
386 * \return Greater than zero if paused, zero otherwise.
389 unsigned int vss_paused(void)
391 return !(mmd
->new_vss_status_flags
& VSS_NEXT
)
392 && !(mmd
->new_vss_status_flags
& VSS_PLAYING
);
396 * Check if the vss is currently stopped.
398 * \return Greater than zero if paused, zero otherwise.
401 unsigned int vss_stopped(void)
403 return (mmd
->new_vss_status_flags
& VSS_NEXT
)
404 && !(mmd
->new_vss_status_flags
& VSS_PLAYING
);
407 static int chk_barrier(const char *bname
, const struct timeval
*barrier
,
408 struct timeval
*diff
, int print_log
)
412 if (tv_diff(now
, barrier
, diff
) > 0)
416 PARA_DEBUG_LOG("%s barrier: %lims left\n", bname
, ms
);
421 * != NULL: timeout for next chunk
422 * NULL: nothing to do
424 static struct timeval
*vss_compute_timeout(struct vss_task
*vsst
)
426 static struct timeval the_timeout
;
427 struct timeval next_chunk
;
429 if (vss_next() && vsst
->map
) {
430 /* only sleep a bit, nec*/
431 the_timeout
.tv_sec
= 0;
432 the_timeout
.tv_usec
= 100;
435 if (chk_barrier("autoplay_delay", &vsst
->autoplay_barrier
,
436 &the_timeout
, 1) < 0)
438 if (chk_barrier("eof", &vsst
->eof_barrier
, &the_timeout
, 1) < 0)
440 if (chk_barrier("data send", &vsst
->data_send_barrier
,
441 &the_timeout
, 1) < 0)
443 if (!vss_playing() || !vsst
->map
)
445 compute_chunk_time(mmd
->chunks_sent
, &mmd
->afd
.afhi
.chunk_tv
,
446 &mmd
->stream_start
, &next_chunk
);
447 if (chk_barrier("chunk", &next_chunk
, &the_timeout
, 0) >= 0) {
448 /* chunk is due or bof */
449 the_timeout
.tv_sec
= 0;
450 the_timeout
.tv_usec
= 0;
453 /* compute min of current timeout and next slice time */
454 compute_slice_timeout(&the_timeout
);
458 static void vss_eof(struct vss_task
*vsst
)
461 mmd
->stream_start
= *now
;
464 if (mmd
->new_vss_status_flags
& VSS_NOMORE
)
465 mmd
->new_vss_status_flags
= VSS_NEXT
;
466 tv_add(&mmd
->afd
.afhi
.eof_tv
, now
, &vsst
->eof_barrier
);
467 para_munmap(vsst
->map
, mmd
->size
);
469 mmd
->chunks_sent
= 0;
471 mmd
->afd
.afhi
.seconds_total
= 0;
472 mmd
->afd
.afhi
.chunk_tv
.tv_sec
= 0;
473 mmd
->afd
.afhi
.chunk_tv
.tv_usec
= 0;
474 free(mmd
->afd
.afhi
.chunk_table
);
475 mmd
->afd
.afhi
.chunk_table
= NULL
;
476 free(mmd
->afd
.afhi
.info_string
);
477 mmd
->afd
.afhi
.info_string
= make_message("%s:\n%s:\n%s:\n", status_item_list
[SI_AUDIO_FILE_INFO
],
478 status_item_list
[SI_TAGINFO1
], status_item_list
[SI_TAGINFO2
]);
479 make_empty_status_items(mmd
->afd
.verbose_ls_output
);
486 * Get the list of all supported audio formats.
488 * \return Aa space separated list of all supported audio formats
489 * It is not allocated at runtime, i.e. there is no need to free
490 * the returned string in the caller.
492 const char *supported_audio_formats(void)
494 return SUPPORTED_AUDIO_FORMATS
;
497 static int need_to_request_new_audio_file(struct vss_task
*vsst
)
501 if (vsst
->map
) /* have audio file */
503 if (!vss_playing()) /* don't need one */
505 if (mmd
->new_vss_status_flags
& VSS_NOMORE
)
507 if (vsst
->afsss
== AFS_SOCKET_AFD_PENDING
) /* already requested one */
509 if (chk_barrier("autoplay_delay", &vsst
->autoplay_barrier
,
518 * Compute the timeout for para_server's main select-loop.
520 * This function gets called from para_server to determine the timeout value
521 * for its main select loop.
523 * \param s Pointer to the server scheduler.
524 * \param t Pointer to the vss task structure.
526 * Before the timeout is computed, the current vss status flags are evaluated
527 * and acted upon by calling appropriate functions from the lower layers.
528 * Possible actions include
530 * - request a new audio file from afs,
531 * - shutdown of all senders (stop/pause command),
532 * - reposition the stream (ff/jmp command).
534 static void vss_pre_select(struct sched
*s
, struct task
*t
)
537 struct timeval
*tv
, diff
;
538 struct vss_task
*vsst
= container_of(t
, struct vss_task
, task
);
540 if (!vsst
->map
|| vss_next() || vss_paused() || vss_repos()) {
541 struct fec_client
*fc
, *tmp
;
542 for (i
= 0; senders
[i
].name
; i
++)
543 if (senders
[i
].shutdown_clients
)
544 senders
[i
].shutdown_clients();
545 list_for_each_entry_safe(fc
, tmp
, &fec_client_list
, node
)
546 fc
->first_stream_chunk
= -1;
550 else if (vss_paused()) {
551 if (mmd
->chunks_sent
)
552 tv_add(&mmd
->afd
.afhi
.eof_tv
, now
, &vsst
->eof_barrier
);
553 mmd
->chunks_sent
= 0;
554 } else if (vss_repos()) {
555 tv_add(now
, &vsst
->announce_tv
, &vsst
->data_send_barrier
);
556 tv_add(&mmd
->afd
.afhi
.eof_tv
, now
, &vsst
->eof_barrier
);
557 mmd
->chunks_sent
= 0;
558 mmd
->current_chunk
= mmd
->repos_request
;
559 mmd
->new_vss_status_flags
&= ~VSS_REPOS
;
561 if (need_to_request_new_audio_file(vsst
)) {
562 PARA_DEBUG_LOG("ready and playing, but no audio file\n");
563 para_fd_set(vsst
->afs_socket
, &s
->wfds
, &s
->max_fileno
);
564 vsst
->afsss
= AFS_SOCKET_CHECK_FOR_WRITE
;
566 para_fd_set(vsst
->afs_socket
, &s
->rfds
, &s
->max_fileno
);
567 for (i
= 0; senders
[i
].name
; i
++) {
568 if (!senders
[i
].pre_select
)
570 senders
[i
].pre_select(&s
->max_fileno
, &s
->rfds
, &s
->wfds
);
572 tv
= vss_compute_timeout(vsst
);
573 if (tv
&& tv_diff(tv
, &s
->timeout
, &diff
) < 0)
577 static int recv_afs_msg(int afs_socket
, int *fd
, uint32_t *code
, uint32_t *data
)
579 char control
[255], buf
[8];
580 struct msghdr msg
= {.msg_iov
= NULL
};
581 struct cmsghdr
*cmsg
;
587 iov
.iov_len
= sizeof(buf
);
590 msg
.msg_control
= control
;
591 msg
.msg_controllen
= sizeof(control
);
592 memset(buf
, 0, sizeof(buf
));
593 ret
= recvmsg(afs_socket
, &msg
, 0);
595 return -ERRNO_TO_PARA_ERROR(errno
);
596 if (iov
.iov_len
!= sizeof(buf
))
597 return -E_AFS_SHORT_READ
;
598 *code
= *(uint32_t*)buf
;
599 *data
= *(uint32_t*)(buf
+ 4);
600 for (cmsg
= CMSG_FIRSTHDR(&msg
); cmsg
; cmsg
= CMSG_NXTHDR(&msg
, cmsg
)) {
601 if (cmsg
->cmsg_level
!= SOL_SOCKET
602 || cmsg
->cmsg_type
!= SCM_RIGHTS
)
604 if ((cmsg
->cmsg_len
- CMSG_LEN(0)) / sizeof(int) != 1)
606 *fd
= *(int *)CMSG_DATA(cmsg
);
611 static void recv_afs_result(struct vss_task
*vsst
)
613 int ret
, passed_fd
, shmid
;
614 uint32_t afs_code
= 0, afs_data
= 0;
617 vsst
->afsss
= AFS_SOCKET_READY
;
618 mmd
->afd
.afhi
.chunk_table
= NULL
;
619 ret
= recv_afs_msg(vsst
->afs_socket
, &passed_fd
, &afs_code
, &afs_data
);
622 PARA_DEBUG_LOG("fd: %d, code: %u, shmid: %u\n", passed_fd
, afs_code
,
625 if (afs_code
!= NEXT_AUDIO_FILE
)
630 ret
= load_afd(shmid
, &mmd
->afd
);
634 ret
= fstat(passed_fd
, &statbuf
);
636 PARA_ERROR_LOG("fstat error:\n");
637 ret
= -ERRNO_TO_PARA_ERROR(errno
);
640 mmd
->size
= statbuf
.st_size
;
641 mmd
->mtime
= statbuf
.st_mtime
;
642 ret
= para_mmap(mmd
->size
, PROT_READ
, MAP_PRIVATE
, passed_fd
,
647 mmd
->chunks_sent
= 0;
648 mmd
->current_chunk
= 0;
652 mmd
->new_vss_status_flags
&= (~VSS_NEXT
);
653 afh_get_header(&mmd
->afd
.afhi
, vsst
->map
, &vsst
->header_buf
,
657 free(mmd
->afd
.afhi
.chunk_table
);
660 PARA_ERROR_LOG("%s\n", para_strerror(-ret
));
661 mmd
->new_vss_status_flags
= VSS_NEXT
;
665 * Main sending function.
667 * This function gets called from vss_post_select(). It checks whether the next
668 * chunk of data should be pushed out. It obtains a pointer to the data to be
669 * sent out as well as its length from mmd->afd.afhi. This information is then
670 * passed to each supported sender's send() function as well as to the send()
671 * functions of each registered fec client.
673 static void vss_send(struct vss_task
*vsst
)
677 struct fec_client
*fc
, *tmp_fc
;
679 if (!vsst
->map
|| !vss_playing())
681 if (chk_barrier("eof", &vsst
->eof_barrier
, &due
, 1) < 0)
683 if (chk_barrier("data send", &vsst
->data_send_barrier
,
686 if (mmd
->current_chunk
>= mmd
->afd
.afhi
.chunks_total
) { /* eof */
687 mmd
->new_vss_status_flags
|= VSS_NEXT
;
690 if (!mmd
->chunks_sent
) {
692 mmd
->stream_start
= *now
;
693 tv_scale(mmd
->current_chunk
, &mmd
->afd
.afhi
.chunk_tv
, &tmp
);
694 mmd
->offset
= tv2ms(&tmp
);
697 compute_chunk_time(mmd
->chunks_sent
, &mmd
->afd
.afhi
.chunk_tv
,
698 &mmd
->stream_start
, &due
);
699 if (tv_diff(&due
, now
, NULL
) <= 0) {
703 * We call the send function also in case of empty chunks as
704 * they might have still some data queued which can be sent in
707 afh_get_chunk(mmd
->current_chunk
, &mmd
->afd
.afhi
, vsst
->map
,
709 for (i
= 0; senders
[i
].name
; i
++) {
710 if (!senders
[i
].send
)
712 senders
[i
].send(mmd
->current_chunk
, mmd
->chunks_sent
,
713 buf
, len
, vsst
->header_buf
, vsst
->header_len
);
716 list_for_each_entry_safe(fc
, tmp_fc
, &fec_client_list
, node
) {
717 if (!next_slice_is_due(fc
, NULL
))
719 compute_next_fec_slice(fc
, vsst
);
720 PARA_DEBUG_LOG("sending %d:%d (%zu bytes)\n", fc
->group
.num
,
721 fc
->slice
.num
, fc
->slice
.bytes
);
722 fc
->fcp
->send((char *)fc
->enc_buf
,
723 fc
->slice
.bytes
+ FEC_HEADER_SIZE
,
724 fc
->fcp
->private_data
);
727 mmd
->new_vss_status_flags
|= VSS_PLAYING
;
729 mmd
->current_chunk
++;
732 static void vss_post_select(struct sched
*s
, struct task
*t
)
735 struct vss_task
*vsst
= container_of(t
, struct vss_task
, task
);
737 if (mmd
->sender_cmd_data
.cmd_num
>= 0) {
738 int num
= mmd
->sender_cmd_data
.cmd_num
,
739 sender_num
= mmd
->sender_cmd_data
.sender_num
;
741 if (senders
[sender_num
].client_cmds
[num
])
742 senders
[sender_num
].client_cmds
[num
](&mmd
->sender_cmd_data
);
743 mmd
->sender_cmd_data
.cmd_num
= -1;
745 if (vsst
->afsss
!= AFS_SOCKET_CHECK_FOR_WRITE
) {
746 if (FD_ISSET(vsst
->afs_socket
, &s
->rfds
))
747 recv_afs_result(vsst
);
748 } else if (FD_ISSET(vsst
->afs_socket
, &s
->wfds
)) {
749 PARA_NOTICE_LOG("requesting new fd from afs\n");
750 ret
= send_buffer(vsst
->afs_socket
, "new");
751 vsst
->afsss
= AFS_SOCKET_AFD_PENDING
;
753 for (i
= 0; senders
[i
].name
; i
++) {
754 if (!senders
[i
].post_select
)
756 senders
[i
].post_select(&s
->rfds
, &s
->wfds
);
758 if ((vss_playing() && !(mmd
->vss_status_flags
& VSS_PLAYING
)) ||
759 (vss_next() && vss_playing()))
760 tv_add(now
, &vsst
->announce_tv
, &vsst
->data_send_barrier
);
765 * Initialize the virtual streaming system task.
767 * \param afs_socket The fd for communication with afs.
769 * This also initializes all supported senders and starts streaming
770 * if the --autoplay command line flag was given.
772 void init_vss_task(int afs_socket
)
774 static struct vss_task vss_task_struct
, *vsst
= &vss_task_struct
;
776 char *hn
= para_hostname(), *home
= para_homedir();
777 long unsigned announce_time
= conf
.announce_time_arg
> 0?
778 conf
.announce_time_arg
: 300,
779 autoplay_delay
= conf
.autoplay_delay_arg
> 0?
780 conf
.autoplay_delay_arg
: 0;
782 vsst
->afs_socket
= afs_socket
;
783 vsst
->task
.pre_select
= vss_pre_select
;
784 vsst
->task
.post_select
= vss_post_select
;
785 ms2tv(announce_time
, &vsst
->announce_tv
);
786 PARA_INFO_LOG("announce timeval: %lums\n", tv2ms(&vsst
->announce_tv
));
787 for (i
= 0; senders
[i
].name
; i
++) {
788 PARA_NOTICE_LOG("initializing %s sender\n", senders
[i
].name
);
789 senders
[i
].init(&senders
[i
]);
793 mmd
->sender_cmd_data
.cmd_num
= -1;
794 make_empty_status_items(mmd
->afd
.verbose_ls_output
);
795 if (conf
.autoplay_given
) {
797 mmd
->vss_status_flags
|= VSS_PLAYING
;
798 mmd
->new_vss_status_flags
|= VSS_PLAYING
;
799 ms2tv(autoplay_delay
, &tmp
);
800 tv_add(now
, &tmp
, &vsst
->autoplay_barrier
);
801 tv_add(&vsst
->autoplay_barrier
, &vsst
->announce_tv
,
802 &vsst
->data_send_barrier
);
804 INIT_LIST_HEAD(&fec_client_list
);
805 register_task(&vsst
->task
);