From 7a51f686d02cf4b2463d9aee2ca79addea4261f5 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 23 Oct 2007 20:30:42 +0200 Subject: [PATCH] Get rid of mmd->audio_format. 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 | 8 +++----- server.c | 5 ++--- server.h | 4 +--- vss.c | 18 ++++++++---------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/command.c b/command.c index 22e3aa94..977e4567 100644 --- 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; - 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); @@ -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_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, diff --git a/server.c b/server.c index 6703fabe..005a29b6 100644 --- 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->audio_format = -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) { - 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); } } diff --git a/server.h b/server.h index 7b2f3590..806a6b01 100644 --- 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]; - /** the last modification file of the current audio file */ + /** the last modification time of the current audio file */ 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. */ diff --git a/vss.c b/vss.c index e456f67a..27520ded 100644 --- 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; - 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; @@ -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 (mmd->audio_format < 0 || !vss_playing() || !map) + if (!vss_playing() || !map) 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; @@ -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; - mmd->audio_format = -1; 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) { - 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; @@ -245,7 +244,7 @@ const char *supported_audio_formats(void) */ struct timeval *vss_chunk_time(void) { - if (mmd->audio_format < 0) + if (!map) 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 */ - mmd->audio_format = mmd->afd.afsi.audio_format_id; 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) { - 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; @@ -469,7 +467,7 @@ void vss_send_chunk(void) 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); -- 2.39.5