X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=412318b27eb656acabbb5c66faa352c8f56494c3;hp=25058e7c079d75be59d1d93cf495718740f5df20;hb=7e37a7cf49df279b9ab467fa4f62dd376c791a26;hpb=e8089cd5efad59a5eec689117acf563a38b8c6c7 diff --git a/aft.c b/aft.c index 25058e7c..412318b2 100644 --- a/aft.c +++ b/aft.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2010 Andre Noll + * Copyright (C) 2007-2011 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -21,7 +21,6 @@ #include "afh.h" #include "afs.h" #include "net.h" -#include "vss.h" #include "fd.h" #include "ipc.h" #include "portable_io.h" @@ -435,12 +434,26 @@ static unsigned sizeof_chunk_table(struct afh_info *afhi) return 4 * (afhi->chunks_total + 1); } -static void save_chunk_table(struct afh_info *afhi, char *buf) +static uint32_t save_chunk_table(struct afh_info *afhi, char *buf) { int i; - - for (i = 0; i <= afhi->chunks_total; i++) - write_u32(buf + 4 * i, afhi->chunk_table[i]); + uint32_t max = 0, old = 0; + + for (i = 0; i <= afhi->chunks_total; i++) { + uint32_t val = afhi->chunk_table[i]; + write_u32(buf + 4 * i, val); + /* + * If the first chunk is the header, do not consider it for the + * calculation of the largest chunk size. + */ + if (i == 0 || (i == 1 && afhi->header_len > 0)) { + old = val; + continue; + } + max = PARA_MAX(max, val - old); + old = val; + } + return max; } static void load_chunk_table(struct afh_info *afhi, char *buf) @@ -641,10 +654,10 @@ static int save_afd(struct audio_file_data *afd) ret = shm_attach(shmid, ATTACH_RW, &shm_afd); if (ret < 0) goto err; - *(struct audio_file_data *)shm_afd = *afd; buf = shm_afd; buf += sizeof(*afd); - save_chunk_table(&afd->afhi, buf); + afd->max_chunk_size = save_chunk_table(&afd->afhi, buf); + *(struct audio_file_data *)shm_afd = *afd; shm_detach(shm_afd); return shmid; err: