]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - vss.c
new codename, reset version to git
[paraslash.git] / vss.c
diff --git a/vss.c b/vss.c
index 042db04110590b721482e09257018e905c501e16..a3c2e65063d267c26b20597f7ae5e1f8c81c24dc 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -268,7 +268,8 @@ static void vss_get_audio_file(void)
                audio_file = open(sl[i], O_RDONLY);
                if (audio_file < 0)
                        continue;
-               if (fstat(audio_file, &file_status) == -1) {
+               if (fstat(audio_file, &file_status) == -1 ||
+                               !file_status.st_size) {
                        close(audio_file);
                        continue;
                }
@@ -277,6 +278,7 @@ static void vss_get_audio_file(void)
                map = para_mmap(file_status.st_size, PROT_READ, MAP_PRIVATE,
                        audio_file, 0);
                strcpy(mmd->filename, sl[i]);
+               mmd->afi.header_len = 0; /* default: no header */
                if (update_mmd() < 0) { /* invalid file */
                        close(audio_file);
                        munmap(map, mmd->size);
@@ -361,13 +363,13 @@ static struct timeval *vss_compute_timeout(void)
        return &the_timeout;
 }
 
-static void vss_eof(struct audio_format_handler *af)
+static void vss_eof(void)
 {
        struct timeval now;
        int i;
        char *tmp;
 
-       if (!af || !map) {
+       if (!map) {
                for (i = 0; senders[i].name; i++)
                        senders[i].shutdown_clients();
                return;
@@ -378,14 +380,11 @@ static void vss_eof(struct audio_format_handler *af)
        map = NULL;
        close(audio_file);
        mmd->audio_format = -1;
-       af = NULL;
        mmd->chunks_sent = 0;
        mmd->offset = 0;
        mmd->afi.seconds_total = 0;
        free(mmd->afi.chunk_table);
        mmd->afi.chunk_table = NULL;
-       free(mmd->afi.header);
-       mmd->afi.header = NULL;
        tmp  = make_message("%s:\n%s:\n%s:\n", status_item_list[SI_AUDIO_INFO1],
                status_item_list[SI_AUDIO_INFO2], status_item_list[SI_AUDIO_INFO3]);
        strcpy(mmd->afi.info_string, tmp);
@@ -411,10 +410,10 @@ static void vss_eof(struct audio_format_handler *af)
  */
 char *vss_get_header(int *header_len)
 {
-       if (mmd->audio_format < 0)
+       if (mmd->audio_format < 0 || !map || !mmd->afi.header_len)
                return NULL;
        *header_len = mmd->afi.header_len;
-       return mmd->afi.header;
+       return map + mmd->afi.header_offset;
 }
 
 /**
@@ -472,7 +471,7 @@ again:
                for (i = 0; senders[i].name; i++)
                        senders[i].shutdown_clients();
        if (vss_next() && af) {
-               vss_eof(af);
+               vss_eof();
                return vss_compute_timeout();
        }
        if (vss_paused() || vss_repos()) {
@@ -535,7 +534,7 @@ void vss_send_chunk(void)
        mmd->new_vss_status_flags &= ~VSS_REPOS;
        if (mmd->current_chunk >= mmd->afi.chunks_total) { /* eof */
                mmd->new_vss_status_flags |= VSS_NEXT;
-               return vss_eof(af);
+               return vss_eof();
        }
        pos = mmd->afi.chunk_table[mmd->current_chunk];
        len = mmd->afi.chunk_table[mmd->current_chunk + 1] - pos;