X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=7bfad504f04b8626ea8fbd436ece8dcef34124ff;hp=922f04229c47ea3545f401bf3c6429ef86695e1d;hb=8221397af24a2df3c2edbc889847ce0ab15eb3e0;hpb=122af971c336b33df2e7233d3cea3287bbdae712 diff --git a/aft.c b/aft.c index 922f0422..7bfad504 100644 --- a/aft.c +++ b/aft.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 Andre Noll + * Copyright (C) 2007-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -20,6 +20,7 @@ #include "vss.h" #include "fd.h" #include "ipc.h" +#include "portable_io.h" static struct osl_table *audio_file_table; @@ -588,8 +589,6 @@ int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi) static int save_afd(struct audio_file_data *afd) { size_t size = sizeof(*afd) + sizeof_chunk_table(&afd->afhi); - - PARA_DEBUG_LOG("size: %zu\n", size); int shmid, ret = shm_new(size); void *shm_afd; char *buf; @@ -1009,6 +1008,13 @@ out: return ret; } +/** + * Write a list of audio-file related status items with empty values. + * + * \param buf Result pointer. + * + * This is used by vss when currently no audio file is open. + */ void make_empty_status_items(char *buf) { sprintf(buf, @@ -1031,6 +1037,10 @@ void make_empty_status_items(char *buf) "%s: \n" /* seconds total */ "%s: \n" /* num played */ "%s: \n" /* last played */ + "%s: \n" /* audio file info */ + "%s: \n" /* taginfo1 */ + "%s: \n" /* taginfo2 */ + "%s: \n" /* amplification */ , status_item_list[SI_PATH], status_item_list[SI_DIRECTORY], @@ -1050,7 +1060,11 @@ void make_empty_status_items(char *buf) status_item_list[SI_DURATION], status_item_list[SI_SECONDS_TOTAL], status_item_list[SI_NUM_PLAYED], - status_item_list[SI_LAST_PLAYED] + status_item_list[SI_LAST_PLAYED], + status_item_list[SI_AUDIO_FILE_INFO], + status_item_list[SI_TAGINFO1], + status_item_list[SI_TAGINFO2], + status_item_list[SI_AMPLIFICATION] ); } @@ -1253,8 +1267,8 @@ static int prepare_ls_row(struct osl_row *row, void *ls_opts) GET_NUM_DIGITS(d->afsi.num_played, &num_digits); w->num_played_width = PARA_MAX(w->num_played_width, num_digits); /* get the number of chars to print this amount of time */ - tmp = get_duration_width(d->afhi.seconds_total); - w->duration_width = PARA_MAX(w->duration_width, tmp); + num_digits = get_duration_width(d->afhi.seconds_total); + w->duration_width = PARA_MAX(w->duration_width, num_digits); GET_NUM_DIGITS(d->afsi.amp, &num_digits); w->amp_width = PARA_MAX(w->amp_width, num_digits); if (options->flags & LS_FLAG_ADMISSIBLE_ONLY) { @@ -1591,6 +1605,7 @@ static void com_add_callback(int fd, const struct osl_object *query) struct afs_info default_afsi = {.last_played = 0}; struct para_buffer msg = {.max_size = SHMMAX, .max_size_handler = pass_buffer_as_shm, .private_data = &fd}; + uint16_t afhi_offset, chunks_offset; hash = (HASH_TYPE *)buf + CAB_HASH_OFFSET; hash_to_asc(hash, asc);; @@ -1645,8 +1660,8 @@ static void com_add_callback(int fd, const struct osl_object *query) goto out; } /* no hs or force mode, child must have sent afhi */ - uint16_t afhi_offset = read_u16(buf + CAB_AFHI_OFFSET_POS); - uint16_t chunks_offset = read_u16(buf + CAB_CHUNKS_OFFSET_POS); + afhi_offset = read_u16(buf + CAB_AFHI_OFFSET_POS); + chunks_offset = read_u16(buf + CAB_CHUNKS_OFFSET_POS); objs[AFTCOL_AFHI].data = buf + afhi_offset; objs[AFTCOL_AFHI].size = chunks_offset - afhi_offset; @@ -1808,6 +1823,7 @@ static int add_one_audio_file(const char *path, void *private_data) afhi_ptr = &afhi; } munmap(map.data, map.size); + close(fd); if (pad->flags & ADD_FLAG_VERBOSE) { send_ret = send_va_buffer(pad->fd, "adding %s\n", path); if (send_ret < 0) @@ -2295,10 +2311,6 @@ static void com_cpsi_callback(int fd, const struct osl_object *query) }; int ret; char *source_path = (char *)query->data + sizeof(cad.flags); - - ret = get_afsi_of_path(source_path, &cad.source_afsi); - if (ret < 0) - goto out; struct pattern_match_data pmd = { .table = audio_file_table, .loop_col_num = AFTCOL_HASH, @@ -2309,6 +2321,10 @@ static void com_cpsi_callback(int fd, const struct osl_object *query) .data = &cad, .action = copy_selector_info }; + + ret = get_afsi_of_path(source_path, &cad.source_afsi); + if (ret < 0) + goto out; ret = for_each_matching_row(&pmd); out: if (ret < 0)