X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=d0580bba8a5fa3c271c0119d368794c09b7c81b3;hp=ed9d2584c4953b5322fabdf25adb01cfd379cba0;hb=fa2e4b062432412b90ad7ba6e85d27764544f1c8;hpb=05b41a869044de934df883b8d7689fc232200d58;ds=inline diff --git a/aft.c b/aft.c index ed9d2584..d0580bba 100644 --- a/aft.c +++ b/aft.c @@ -524,7 +524,10 @@ int get_afsi_of_path(const char *path, struct afs_info *afsi) * \param row Pointer to a row in the audio file table. * \param path Result pointer. * - * \return Positive on success, negative on errors. + * The result is a pointer to mmapped data. The caller must not attempt + * to free it. + * + * \return Standard. */ int get_audio_file_path_of_row(const struct osl_row *row, char **path) { @@ -595,35 +598,10 @@ int get_afhi_of_row(const struct osl_row *row, struct audio_format_info *afhi) return 1; } -#if 0 -/** - * Get the chunk table of an audio file, given a row of the audio file table. - * - * \param row Pointer to a row of the audio file table. - * \param afhi Result pointer. - * - * \return The return value of the underlying call to osl_open_disk_object(). - * - * \sa get_afhi_of_row(). - */ -static int get_chunk_table_of_row(const struct osl_row *row, struct audio_format_info *afhi) -{ - struct osl_object obj; - int ret = osl_open_disk_object(audio_file_table, row, AFTCOL_CHUNKS, - &obj); - if (ret < 0) - return ret; - ret = load_chunk_info(&obj, afhi); - osl_close_disk_object(&obj); - return ret; -} -#endif - /* returns shmid on success */ static int save_afd(struct audio_file_data *afd) { - size_t path_size = strlen(afd->path) + 1; - size_t size = sizeof(*afd) + path_size + size_t size = sizeof(*afd) + 4 * (afd->afhi.chunks_total + 1); PARA_NOTICE_LOG("size: %zu\n", size); @@ -640,8 +618,6 @@ static int save_afd(struct audio_file_data *afd) *(struct audio_file_data *)shm_afd = *afd; buf = shm_afd; buf += sizeof(*afd); - strcpy(buf, afd->path); - buf += path_size; save_chunk_table(&afd->afhi, buf); shm_detach(shm_afd); return shmid; @@ -662,8 +638,6 @@ int load_afd(int shmid, struct audio_file_data *afd) *afd = *(struct audio_file_data *)shm_afd; buf = shm_afd; buf += sizeof(*afd); - afd->path = para_strdup(buf); - buf += strlen(buf) + 1; afd->afhi.chunk_table = para_malloc((afd->afhi.chunks_total + 1) * 4); load_chunk_table(&afd->afhi, buf); shm_detach(shm_afd); @@ -690,12 +664,15 @@ int open_and_update_audio_file(struct osl_row *aft_row, struct audio_file_data * int ret = get_hash_of_row(aft_row, &aft_hash); struct afsi_change_event_data aced; struct osl_object map, chunk_table_obj; + char *tmp, *path; if (ret < 0) return ret; - ret = get_audio_file_path_of_row(aft_row, &afd->path); + ret = get_audio_file_path_of_row(aft_row, &path); if (ret < 0) return ret; + strncpy(afd->path, path, sizeof(afd->path) - 1); + afd->path[sizeof(afd->path) - 1] = '\0'; ret = get_afsi_object_of_row(aft_row, &afsi_obj); if (ret < 0) return ret; @@ -709,7 +686,7 @@ int open_and_update_audio_file(struct osl_row *aft_row, struct audio_file_data * AFTCOL_CHUNKS, &chunk_table_obj); if (ret < 0) return ret; - ret = mmap_full_file(afd->path, O_RDONLY, &map.data, + ret = mmap_full_file(path, O_RDONLY, &map.data, &map.size, &afd->fd); if (ret < 0) goto err; @@ -728,6 +705,12 @@ int open_and_update_audio_file(struct osl_row *aft_row, struct audio_file_data * ret = load_chunk_info(&chunk_table_obj, &afd->afhi); if (ret < 0) goto err; + ret = get_attribute_text(&afd->afsi.attributes, " ", &tmp); + if (ret < 0) + goto err; + tmp[sizeof(afd->attributes_string) - 1] = '\0'; + strcpy(afd->attributes_string, tmp); /* OK */ + free(tmp); aced.aft_row = aft_row; aced.old_afsi = &afd->afsi;