From: Andre Noll Date: Sat, 12 Apr 2008 12:37:07 +0000 (+0200) Subject: vss: Include map in the vss task struct. X-Git-Tag: v0.3.3~83 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=3dca24604449f268274e8458fbd5447e55dd7cc8;p=paraslash.git vss: Include map in the vss task struct. --- diff --git a/vss.c b/vss.c index 98965efd..42d39db0 100644 --- a/vss.c +++ b/vss.c @@ -67,7 +67,6 @@ enum afs_socket_status { AFS_SOCKET_AFD_PENDING }; -static char *map; struct vss_task { struct timeval announce_tv; @@ -75,6 +74,7 @@ struct vss_task { struct timeval eof_barrier; struct timeval autoplay_barrier; enum afs_socket_status afsss; + char *map; }; static struct vss_task vss_task_struct, *vsst = &vss_task_struct; @@ -147,11 +147,11 @@ unsigned int vss_stopped(void) */ int vss_get_chunk(long unsigned chunk_num, char **buf, size_t *len) { - if (!map || !vss_playing()) + if (!vsst->map || !vss_playing()) return -E_CHUNK; if (chunk_num >= mmd->afd.afhi.chunks_total) return -E_CHUNK; - afh_get_chunk(chunk_num, &mmd->afd.afhi, map, buf, len); + afh_get_chunk(chunk_num, &mmd->afd.afhi, vsst->map, buf, len); return 1; } @@ -211,7 +211,7 @@ static struct timeval *vss_compute_timeout(void) static struct timeval the_timeout; struct timeval now, next_chunk; - if (vss_next() && map) { + if (vss_next() && vsst->map) { /* only sleep a bit, nec*/ the_timeout.tv_sec = 0; the_timeout.tv_usec = 100; @@ -226,7 +226,7 @@ static struct timeval *vss_compute_timeout(void) if (chk_barrier("data send", &now, &vsst->data_send_barrier, &the_timeout, 1) < 0) return &the_timeout; - if (!vss_playing() || !map) + if (!vss_playing() || !vsst->map) return NULL; compute_chunk_time(mmd->chunks_sent, &mmd->afd.afhi.chunk_tv, &mmd->stream_start, &next_chunk); @@ -243,14 +243,14 @@ static void vss_eof(void) struct timeval now; char *tmp; - if (!map) + if (!vsst->map) return; if (mmd->new_vss_status_flags & VSS_NOMORE) mmd->new_vss_status_flags = VSS_NEXT; gettimeofday(&now, NULL); tv_add(&mmd->afd.afhi.eof_tv, &now, &vsst->eof_barrier); - para_munmap(map, mmd->size); - map = NULL; + para_munmap(vsst->map, mmd->size); + vsst->map = NULL; mmd->chunks_sent = 0; mmd->offset = 0; mmd->afd.afhi.seconds_total = 0; @@ -277,7 +277,7 @@ static void vss_eof(void) */ void vss_get_header(char **buf, size_t *len) { - afh_get_header(&mmd->afd.afhi, map, buf, len); + afh_get_header(&mmd->afd.afhi, vsst->map, buf, len); } /** @@ -300,14 +300,14 @@ const char *supported_audio_formats(void) */ struct timeval *vss_chunk_time(void) { - if (!map) + if (!vsst->map) return NULL; return &mmd->afd.afhi.chunk_tv; } static int need_to_request_new_audio_file(void) { - if (map) /* have audio file */ + if (vsst->map) /* have audio file */ return 0; if (!vss_playing()) /* don't need one */ return 0; @@ -344,7 +344,7 @@ struct timeval *vss_preselect(fd_set *rfds, fd_set *wfds, int *max_fileno) int i; struct timeval now; - if (!map || vss_next() || vss_paused() || vss_repos()) + if (!vsst->map || vss_next() || vss_paused() || vss_repos()) for (i = 0; senders[i].name; i++) senders[i].shutdown_clients(); if (vss_next()) @@ -444,7 +444,7 @@ static void recv_afs_result(void) } mmd->size = statbuf.st_size; mmd->mtime = statbuf.st_mtime; - map = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE, + vsst->map = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE, passed_fd, 0); close(passed_fd); mmd->chunks_sent = 0; @@ -480,7 +480,7 @@ static void vss_send_chunk(void) char *buf; size_t len; - if (!map || !vss_playing()) + if (!vsst->map || !vss_playing()) return; gettimeofday(&now, NULL); compute_chunk_time(mmd->chunks_sent, &mmd->afd.afhi.chunk_tv, @@ -508,7 +508,7 @@ static void vss_send_chunk(void) mmd->offset = tv2ms(&tmp); mmd->events++; } - afh_get_chunk(mmd->current_chunk, &mmd->afd.afhi, map, &buf, &len); + afh_get_chunk(mmd->current_chunk, &mmd->afd.afhi, vsst->map, &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;