"%s: %lu\n" /* seconds total */
"%s: %s\n" /* last played time */
"%s: %d\n" /* num_played */
- "%s\n", /* tag info */
+ "%s" /* tag info */
+ "%s: %lu\n" /* chunk time */
+ "%s: %lu\n", /* num chunks */
filename_lines,
have_score? status_item_list[SI_SCORE] : "",
have_score? ": " : "",
status_item_list[SI_SECONDS_TOTAL], afhi->seconds_total,
status_item_list[SI_LAST_PLAYED], last_played_time,
status_item_list[SI_NUM_PLAYED], afsi->num_played,
- afhi->info_string
+ afhi->info_string,
+ status_item_list[SI_CHUNK_TIME], tv2ms(&afhi->chunk_tv),
+ status_item_list[SI_NUM_CHUNKS], afhi->chunks_total
);
if (opts->mode == LS_MODE_MBOX) {
struct osl_object lyrics_def;
static int add_one_audio_file(const char *path, const void *private_data)
{
- int ret, ret2;
+ int ret, send_ret = 1;
uint8_t format_num = -1;
const struct private_add_data *pad = private_data;
struct afh_info afhi, *afhi_ptr = NULL;
ret = 1;
if (pb && (pad->flags & ADD_FLAG_LAZY)) { /* lazy is really cheap */
if (pad->flags & ADD_FLAG_VERBOSE)
- ret = send_va_buffer(pad->fd, "lazy-ignore: %s\n", path);
+ send_ret = send_va_buffer(pad->fd, "lazy-ignore: %s\n", path);
goto out_free;
}
/* We still want to add this file. Compute its hash. */
goto out_free;
hash_function(map.data, map.size, hash);
- /* Check whether database contains file with the same hash. */
+ /* Check whether the database contains a file with the same hash. */
query.data = hash;
query.size = HASH_SIZE;
ret = send_callback_request(hash_sister_callback, &query, &result);
if (ret < 0 && ret != -E_RB_KEY_NOT_FOUND)
- goto out_free;
+ goto out_unmap;
if (ret >= 0) {
hs = *(struct osl_row **)result.data;
free(result.data);
}
/* Return success if we already know this file. */
ret = 1;
- if (pb && hs && hs == pb && (!(pad->flags & ADD_FLAG_FORCE))) {
+ if (pb && hs && hs == pb && !(pad->flags & ADD_FLAG_FORCE)) {
if (pad->flags & ADD_FLAG_VERBOSE)
- ret = send_va_buffer(pad->fd,
+ send_ret = send_va_buffer(pad->fd,
"%s exists, not forcing update\n", path);
goto out_unmap;
}
/*
- * we won't recalculate the audio format info and the chunk table if
- * there is a hash sister unless in FORCE mode.
+ * We won't recalculate the audio format info and the chunk table if
+ * there is a hash sister and FORCE was not given.
*/
if (!hs || (pad->flags & ADD_FLAG_FORCE)) {
ret = compute_afhi(path, map.data, map.size, &afhi);
format_num = ret;
afhi_ptr = &afhi;
}
+ munmap(map.data, map.size);
if (pad->flags & ADD_FLAG_VERBOSE) {
- ret = send_va_buffer(pad->fd, "adding %s\n", path);
- if (ret < 0)
- goto out_unmap;
+ send_ret = send_va_buffer(pad->fd, "adding %s\n", path);
+ if (send_ret < 0)
+ goto out_free;
}
- munmap(map.data, map.size);
save_audio_file_info(hash, path, afhi_ptr, pad->flags, format_num, &obj);
/* Ask afs to consider this entry for adding. */
ret = send_callback_request(com_add_callback, &obj, &result);
if (ret > 0) {
- ret2 = send_va_buffer(pad->fd, "%s", (char *)result.data);
+ send_ret = send_va_buffer(pad->fd, "%s", (char *)result.data);
free(result.data);
- if (ret >= 0 && ret2 < 0)
- ret = ret2;
}
goto out_free;
out_unmap:
munmap(map.data, map.size);
out_free:
- if (ret < 0 && ret != -E_SEND)
- send_va_buffer(pad->fd, "failed to add %s (%s)\n", path,
+ if (ret < 0 && send_ret >= 0)
+ send_ret = send_va_buffer(pad->fd, "failed to add %s (%s)\n", path,
PARA_STRERROR(-ret));
free(obj.data);
if (afhi_ptr)
free(afhi_ptr->chunk_table);
- /* it's not an error if not all files could be added */
- return ret == -E_SEND? ret : 1;
+ /* Stop adding files only on send errors. */
+ return send_ret;
}
int com_add(int fd, int argc, char * const * const argv)