From fa578bf1d070161cafcbcc69ca7b810414ee1a4b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 6 Oct 2010 22:21:07 +0200 Subject: [PATCH 1/1] Kill afhi->header_offset. It is always zero, and stored _twice_ in the osl table. Since we must not change the layout of the on-disk afhi structure, rename these fields to AFHI_UNUSED1_OFFSET and AFHI_UNUSED2_OFFSET, and set them to zero in save_afhi(). --- afh.h | 5 ----- afh_common.c | 3 +-- aft.c | 14 ++++++-------- wma_afh.c | 1 - 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/afh.h b/afh.h index f6286b24..494a4e15 100644 --- a/afh.h +++ b/afh.h @@ -42,11 +42,6 @@ struct afh_info { uint32_t *chunk_table; /** Period of time between sending data chunks. */ struct timeval chunk_tv; - /** - * The position of the header within the audio file. Ignored if \a - * header_len equals zero. - */ - uint32_t header_offset; /** * The header is needed by senders in case a new client connects in the * middle of the stream. The length of the header defaults to zero diff --git a/afh_common.c b/afh_common.c index dd2ae650..10376ba6 100644 --- a/afh_common.c +++ b/afh_common.c @@ -160,7 +160,6 @@ int compute_afhi(const char *path, char *data, size_t size, int fd, { int ret, i, format; - afhi->header_offset = 0; afhi->header_len = 0; afhi->techinfo = NULL; afhi->tags.artist = NULL; @@ -265,5 +264,5 @@ void afh_get_header(struct afh_info *afhi, void *map, const char **buf, size_t * return; } *len = afhi->header_len; - *buf = map + afhi->header_offset; + *buf = map; } diff --git a/aft.c b/aft.c index 412318b2..9f39d705 100644 --- a/aft.c +++ b/aft.c @@ -344,16 +344,16 @@ enum afhi_offsets { AFHI_BITRATE_OFFSET = 4, /** Position of the frequency. */ AFHI_FREQUENCY_OFFSET = 8, - /** Location of the audio file header. */ - AFHI_HEADER_OFFSET_OFFSET = 12, + /** Was: Location of the audio file header. */ + AFHI_UNUSED1_OFFSET = 12, /* Length of the audio file header. Zero means: No header. */ AFHI_HEADER_LEN_OFFSET = 16, /** The total number of chunks (4 bytes). */ CHUNKS_TOTAL_OFFSET = 20, /** The length of the audio file header (4 bytes). */ HEADER_LEN_OFFSET = 24, - /** The start of the audio file header (4 bytes). */ - HEADER_OFFSET_OFFSET = 28, + /** Was: The start of the audio file header (4 bytes). */ + AFHI_UNUSED2_OFFSET = 28, /** The seconds part of the chunk time (4 bytes). */ CHUNK_TV_TV_SEC_OFFSET = 32, /** The microseconds part of the chunk time (4 bytes). */ @@ -388,12 +388,12 @@ static void save_afhi(struct afh_info *afhi, char *buf) write_u32(buf + AFHI_SECONDS_TOTAL_OFFSET, afhi->seconds_total); write_u32(buf + AFHI_BITRATE_OFFSET, afhi->bitrate); write_u32(buf + AFHI_FREQUENCY_OFFSET, afhi->frequency); - write_u32(buf + AFHI_HEADER_OFFSET_OFFSET, afhi->header_offset); + write_u32(buf + AFHI_UNUSED1_OFFSET, 0); write_u32(buf + AFHI_HEADER_LEN_OFFSET, afhi->header_len); write_u8(buf + AFHI_CHANNELS_OFFSET, afhi->channels); write_u32(buf + CHUNKS_TOTAL_OFFSET, afhi->chunks_total); write_u32(buf + HEADER_LEN_OFFSET, afhi->header_len); - write_u32(buf + HEADER_OFFSET_OFFSET, afhi->header_offset); + write_u32(buf + AFHI_UNUSED2_OFFSET, 0); write_u32(buf + CHUNK_TV_TV_SEC_OFFSET, afhi->chunk_tv.tv_sec); write_u32(buf + CHUNK_TV_TV_USEC_OFFSET, afhi->chunk_tv.tv_usec); p = buf + AFHI_INFO_STRING_OFFSET; @@ -411,12 +411,10 @@ static void load_afhi(const char *buf, struct afh_info *afhi) afhi->seconds_total = read_u32(buf + AFHI_SECONDS_TOTAL_OFFSET); afhi->bitrate = read_u32(buf + AFHI_BITRATE_OFFSET); afhi->frequency = read_u32(buf + AFHI_FREQUENCY_OFFSET); - afhi->header_offset = read_u32(buf + AFHI_HEADER_OFFSET_OFFSET); afhi->header_len = read_u32(buf + AFHI_HEADER_LEN_OFFSET); afhi->channels = read_u8(buf + AFHI_CHANNELS_OFFSET); afhi->chunks_total = read_u32(buf + CHUNKS_TOTAL_OFFSET); afhi->header_len = read_u32(buf + HEADER_LEN_OFFSET); - afhi->header_offset = read_u32(buf + HEADER_OFFSET_OFFSET); afhi->chunk_tv.tv_sec = read_u32(buf + CHUNK_TV_TV_SEC_OFFSET); afhi->chunk_tv.tv_usec = read_u32(buf + CHUNK_TV_TV_USEC_OFFSET); afhi->techinfo = (char *)buf + AFHI_INFO_STRING_OFFSET; diff --git a/wma_afh.c b/wma_afh.c index 9b7d85b3..255342dc 100644 --- a/wma_afh.c +++ b/wma_afh.c @@ -257,7 +257,6 @@ static int wma_get_file_info(char *map, size_t numbytes, __a_unused int fd, afhi->frequency = ahi.sample_rate; afhi->channels = ahi.channels; afhi->header_len = ahi.header_len; - afhi->header_offset = 0; wma_make_chunk_table(map + ahi.header_len, numbytes - ahi.header_len, ahi.block_align, afhi); read_asf_tags(map, ahi.header_len, &afhi->tags); -- 2.39.2