]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Get rid of mmd->audio_format.
authorAndre Noll <maan@systemlinux.org>
Tue, 23 Oct 2007 18:30:42 +0000 (20:30 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 23 Oct 2007 18:30:42 +0000 (20:30 +0200)
The current audio format is also stored in mmd->afd.afsi.audio_format_id,
so use the value stored there. However, most users of mmd->audio_format
used this value only to detect whether an audio file is open ATM. In
vss.c, use the map pointer instead to find out whether an audio file is
open.

command.c
server.c
server.h
vss.c

index 22e3aa94b7b1d037d1e2625577d55931f39baae9..977e45673086fc517237fa2099e7803c61f94149 100644 (file)
--- a/command.c
+++ b/command.c
@@ -104,10 +104,8 @@ static char *get_status(struct misc_meta_data *nmmd)
        struct timeval now;
        struct tm mtime_tm;
 
        struct timeval now;
        struct tm mtime_tm;
 
-       if (nmmd->audio_format >= 0) {
-               localtime_r(&nmmd->mtime, &mtime_tm);
-               strftime(mtime, 29, "%a %b %d %Y", &mtime_tm);
-       }
+       localtime_r(&nmmd->mtime, &mtime_tm);
+       strftime(mtime, 29, "%a %b %d %Y", &mtime_tm);
        /* report real status */
        status = vss_status_tohuman(nmmd->vss_status_flags);
        flags = vss_get_status_flags(nmmd->vss_status_flags);
        /* report real status */
        status = vss_status_tohuman(nmmd->vss_status_flags);
        flags = vss_get_status_flags(nmmd->vss_status_flags);
@@ -129,7 +127,7 @@ static char *get_status(struct misc_meta_data *nmmd)
                status_item_list[SI_SELECTOR], "FIXME",
 
                status_item_list[SI_OFFSET], offset,
                status_item_list[SI_SELECTOR], "FIXME",
 
                status_item_list[SI_OFFSET], offset,
-               status_item_list[SI_FORMAT], audio_format_name(nmmd->audio_format),
+               status_item_list[SI_FORMAT], audio_format_name(nmmd->afd.afsi.audio_format_id),
                status_item_list[SI_AFS_MODE], mmd->afs_mode_string,
                nmmd->afd.afhi.info_string,
 
                status_item_list[SI_AFS_MODE], mmd->afs_mode_string,
                nmmd->afd.afhi.info_string,
 
index 6703fabe256bbab611050e12bdd3927b696d16c6..005a29b63219e20f8c78a57f279cd42403bc7bd7 100644 (file)
--- a/server.c
+++ b/server.c
@@ -153,7 +153,6 @@ static void shm_init(void)
        mmd->num_connects = 0;
        mmd->active_connections = 0;
        strcpy(mmd->filename, "(none)");
        mmd->num_connects = 0;
        mmd->active_connections = 0;
        strcpy(mmd->filename, "(none)");
-       mmd->audio_format = -1;
        mmd->vss_status_flags = VSS_NEXT;
        mmd->new_vss_status_flags = VSS_NEXT;
        mmd->sender_cmd_data.cmd_num = -1;
        mmd->vss_status_flags = VSS_NEXT;
        mmd->new_vss_status_flags = VSS_NEXT;
        mmd->sender_cmd_data.cmd_num = -1;
@@ -388,8 +387,8 @@ out:
        prev_events = mmd->events;
        mmd->vss_status_flags = mmd->new_vss_status_flags;
        if (ret) {
        prev_events = mmd->events;
        mmd->vss_status_flags = mmd->new_vss_status_flags;
        if (ret) {
-               PARA_DEBUG_LOG("%d events, forcing status update, af = %d\n",
-                       mmd->events, mmd->audio_format);
+               PARA_DEBUG_LOG("%d events, forcing status update\n",
+                       mmd->events);
                killpg(0, SIGUSR1);
        }
 }
                killpg(0, SIGUSR1);
        }
 }
index 7b2f3590dd9bff3e41a9a4f4543180aca1982304..806a6b01db3c9a6c8f06390806e8d5693390a38c 100644 (file)
--- a/server.h
+++ b/server.h
@@ -63,10 +63,8 @@ struct misc_meta_data {
        size_t size;
        /** the full path of the current audio file */
        char filename[_POSIX_PATH_MAX];
        size_t size;
        /** the full path of the current audio file */
        char filename[_POSIX_PATH_MAX];
-       /** the last modification file of the current audio file */
+       /** the last modification time of the current audio file */
        time_t mtime;
        time_t mtime;
-       /** the number of the current audio format */
-       int audio_format;
        /** the "old" status flags -- commands may only read them */
        unsigned int vss_status_flags;
        /** The new status flags -- commands may set them. */
        /** the "old" status flags -- commands may only read them */
        unsigned int vss_status_flags;
        /** The new status flags -- commands may set them. */
diff --git a/vss.c b/vss.c
index e456f67a92bb0fe88bf2b7abdab4e3a55eceb037..27520ded29a8a4c8c330269c9f0b9b9a775844f9 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -149,7 +149,7 @@ static struct timeval *vss_compute_timeout(void)
        static struct timeval the_timeout;
        struct timeval now, next_chunk;
 
        static struct timeval the_timeout;
        struct timeval now, next_chunk;
 
-       if (vss_next() && mmd->audio_format >= 0) {
+       if (vss_next() && map) {
                /* only sleep a bit, nec*/
                the_timeout.tv_sec = 0;
                the_timeout.tv_usec = 100;
                /* only sleep a bit, nec*/
                the_timeout.tv_sec = 0;
                the_timeout.tv_usec = 100;
@@ -164,11 +164,11 @@ static struct timeval *vss_compute_timeout(void)
        if (chk_barrier("data send", &now, &data_send_barrier,
                        &the_timeout, 1) < 0)
                return &the_timeout;
        if (chk_barrier("data send", &now, &data_send_barrier,
                        &the_timeout, 1) < 0)
                return &the_timeout;
-       if (mmd->audio_format < 0 || !vss_playing() || !map)
+       if (!vss_playing() || !map)
                return NULL;
        vss_next_chunk_time(&next_chunk);
                return NULL;
        vss_next_chunk_time(&next_chunk);
-       if (chk_barrier(audio_format_name(mmd->audio_format), &now, &next_chunk,
-                       &the_timeout, 0) < 0)
+       if (chk_barrier(audio_format_name(mmd->afd.afsi.audio_format_id),
+                       &now, &next_chunk, &the_timeout, 0) < 0)
                return &the_timeout;
        /* chunk is due or bof */
        the_timeout.tv_sec = 0;
                return &the_timeout;
        /* chunk is due or bof */
        the_timeout.tv_sec = 0;
@@ -192,7 +192,6 @@ static void vss_eof(void)
        tv_add(&mmd->afd.afhi.eof_tv, &now, &eof_barrier);
        munmap(map, mmd->size);
        map = NULL;
        tv_add(&mmd->afd.afhi.eof_tv, &now, &eof_barrier);
        munmap(map, mmd->size);
        map = NULL;
-       mmd->audio_format = -1;
        mmd->chunks_sent = 0;
        mmd->offset = 0;
        mmd->afd.afhi.seconds_total = 0;
        mmd->chunks_sent = 0;
        mmd->offset = 0;
        mmd->afd.afhi.seconds_total = 0;
@@ -219,7 +218,7 @@ static void vss_eof(void)
  */
 char *vss_get_header(size_t *header_len)
 {
  */
 char *vss_get_header(size_t *header_len)
 {
-       if (mmd->audio_format < 0 || !map || !mmd->afd.afhi.header_len)
+       if (!map || !mmd->afd.afhi.header_len)
                return NULL;
        *header_len = mmd->afd.afhi.header_len;
        return map + mmd->afd.afhi.header_offset;
                return NULL;
        *header_len = mmd->afd.afhi.header_len;
        return map + mmd->afd.afhi.header_offset;
@@ -245,7 +244,7 @@ const char *supported_audio_formats(void)
  */
 struct timeval *vss_chunk_time(void)
 {
  */
 struct timeval *vss_chunk_time(void)
 {
-       if (mmd->audio_format < 0)
+       if (!map)
                return NULL;
        return &mmd->afd.afhi.chunk_tv;
 }
                return NULL;
        return &mmd->afd.afhi.chunk_tv;
 }
@@ -394,7 +393,6 @@ static void recv_afs_result(void)
        close(passed_fd);
        strcpy(mmd->filename, mmd->afd.path); /* FIXME: check length */
        mmd->afd.afhi.header_len = 0; /* default: no header */
        close(passed_fd);
        strcpy(mmd->filename, mmd->afd.path); /* FIXME: check length */
        mmd->afd.afhi.header_len = 0; /* default: no header */
-       mmd->audio_format = mmd->afd.afsi.audio_format_id;
        mmd->chunks_sent = 0;
        mmd->current_chunk = 0;
        mmd->offset = 0;
        mmd->chunks_sent = 0;
        mmd->current_chunk = 0;
        mmd->offset = 0;
@@ -445,7 +443,7 @@ static void get_chunk(long unsigned chunk_num, char **buf, size_t *len)
  */
 int vss_get_chunk(long unsigned chunk_num, char **buf, size_t *len)
 {
  */
 int vss_get_chunk(long unsigned chunk_num, char **buf, size_t *len)
 {
-       if (mmd->audio_format < 0 || !map || !vss_playing())
+       if (!map || !vss_playing())
                return -E_CHUNK;
        if (chunk_num >= mmd->afd.afhi.chunks_total)
                return -E_CHUNK;
                return -E_CHUNK;
        if (chunk_num >= mmd->afd.afhi.chunks_total)
                return -E_CHUNK;
@@ -469,7 +467,7 @@ void vss_send_chunk(void)
        char *buf;
        size_t len;
 
        char *buf;
        size_t len;
 
-       if (mmd->audio_format < 0 || !map || !vss_playing())
+       if (!map || !vss_playing())
                return;
        gettimeofday(&now, NULL);
        vss_next_chunk_time(&due);
                return;
        gettimeofday(&now, NULL);
        vss_next_chunk_time(&due);