btr: Rename btr_bytes_pending() and make it public.
[paraslash.git] / vss.c
diff --git a/vss.c b/vss.c
index c6e4053321c950e8ae03c352382610515de561cb..1a038f060bd1f0e2ecfd842e9f08fd7f704f70e2 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -11,7 +11,9 @@
  * senders.
  */
 
+#include <regex.h>
 #include <dirent.h>
+#include <osl.h>
 
 #include "para.h"
 #include "error.h"
@@ -498,8 +500,7 @@ static void compute_slice_timeout(struct timeval *timeout)
 static void set_eof_barrier(struct vss_task *vsst)
 {
        struct fec_client *fc;
-       struct timeval timeout = mmd->afd.afhi.eof_tv,
-               *chunk_tv = vss_chunk_time();
+       struct timeval timeout = {1, 0}, *chunk_tv = vss_chunk_time();
 
        if (!chunk_tv)
                goto out;
@@ -635,16 +636,12 @@ static void vss_eof(struct vss_task *vsst)
        para_munmap(vsst->map, mmd->size);
        vsst->map = NULL;
        mmd->chunks_sent = 0;
-       mmd->offset = 0;
+       //mmd->offset = 0;
        mmd->afd.afhi.seconds_total = 0;
        mmd->afd.afhi.chunk_tv.tv_sec = 0;
        mmd->afd.afhi.chunk_tv.tv_usec = 0;
        free(mmd->afd.afhi.chunk_table);
        mmd->afd.afhi.chunk_table = NULL;
-       free(mmd->afd.afhi.info_string);
-       mmd->afd.afhi.info_string = make_message("%s:\n%s:\n%s:\n", status_item_list[SI_AUDIO_FILE_INFO],
-               status_item_list[SI_TAGINFO1], status_item_list[SI_TAGINFO2]);
-       make_empty_status_items(mmd->afd.verbose_ls_output);
        mmd->mtime = 0;
        mmd->size = 0;
        mmd->events++;
@@ -680,6 +677,13 @@ static int need_to_request_new_audio_file(struct vss_task *vsst)
        return 1;
 }
 
+static void set_mmd_offset(void)
+{
+       struct timeval offset;
+       tv_scale(mmd->current_chunk, &mmd->afd.afhi.chunk_tv, &offset);
+       mmd->offset = tv2ms(&offset);
+}
+
 /**
  * Compute the timeout for the main select-loop of the scheduler.
  *
@@ -724,6 +728,7 @@ static void vss_pre_select(struct sched *s, struct task *t)
                mmd->chunks_sent = 0;
                mmd->current_chunk = mmd->repos_request;
                mmd->new_vss_status_flags &= ~VSS_REPOS;
+               set_mmd_offset();
        }
        if (need_to_request_new_audio_file(vsst)) {
                PARA_DEBUG_LOG("ready and playing, but no audio file\n");
@@ -793,7 +798,6 @@ static void recv_afs_result(struct vss_task *vsst)
        if (passed_fd < 0)
                goto err;
        shmid = afs_data;
-       free(mmd->afd.afhi.info_string);
        ret = load_afd(shmid, &mmd->afd);
        if (ret < 0)
                goto err;
@@ -879,11 +883,9 @@ static void vss_send(struct vss_task *vsst)
                size_t len;
 
                if (!mmd->chunks_sent) {
-                       struct timeval tmp;
                        mmd->stream_start = *now;
-                       tv_scale(mmd->current_chunk, &mmd->afd.afhi.chunk_tv, &tmp);
-                       mmd->offset = tv2ms(&tmp);
                        mmd->events++;
+                       set_mmd_offset();
                }
                /*
                 * We call the send function also in case of empty chunks as
@@ -970,7 +972,6 @@ void init_vss_task(int afs_socket)
        free(hn);
        free(home);
        mmd->sender_cmd_data.cmd_num = -1;
-       make_empty_status_items(mmd->afd.verbose_ls_output);
        if (conf.autoplay_given) {
                struct timeval tmp;
                mmd->vss_status_flags |= VSS_PLAYING;