+ bn? bn : "?");
+ if (ret < 0)
+ goto out;
+ }
+ ret = para_printf(b,
+ "%s" /* filename stuff */
+ "%s%s%s%s" /* score */
+ "%s\n" /* attributes */
+ "%s: %s\n" /* hash */
+ "%s" /* image id, image name */
+ "%s" /* lyrics */
+ "%s: %dkbit/s\n" /* bitrate */
+ "%s: %s\n" /* format */
+ "%s: %dHz\n" /* frequency */
+ "%s: %d\n" /* channels */
+ "%s: %s\n" /* duration */
+ "%s: %lu\n" /* seconds total */
+ "%s: %s\n" /* last played time */
+ "%s: %d\n" /* num_played */
+ "%s: %u\n" /* ampplification */
+ "%s" /* tag info */
+ "%s: %lu\n" /* chunk time */
+ "%s: %lu\n", /* num chunks */
+ filename_lines,
+ have_score? status_item_list[SI_SCORE] : "",
+ have_score? ": " : "",
+ score_buf,
+ have_score? "\n" : "",
+ att_lines,
+ status_item_list[SI_HASH], asc_hash,
+ image_lines,
+ lyrics_lines,
+ status_item_list[SI_BITRATE], afhi->bitrate,
+ status_item_list[SI_FORMAT], audio_format_name(afsi->audio_format_id),
+ status_item_list[SI_FREQUENCY], afhi->frequency,
+ status_item_list[SI_CHANNELS], afhi->channels,
+ status_item_list[SI_DURATION], duration_buf,
+ 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,
+ status_item_list[SI_AMPLIFICATION], afsi->amp,
+ afhi->info_string,
+ status_item_list[SI_CHUNK_TIME], tv2ms(&afhi->chunk_tv),
+ status_item_list[SI_NUM_CHUNKS], afhi->chunks_total
+ );
+ if (ret < 0)
+ goto out;
+ if (opts->mode == LS_MODE_MBOX) {
+ struct osl_object lyrics_def;
+ lyr_get_def_by_id(afsi->lyrics_id, &lyrics_def);
+ if (lyrics_def.data) {
+ ret = para_printf(b, "Lyrics:\n~~~~~~~\n%s",
+ (char *)lyrics_def.data);
+ osl_close_disk_object(&lyrics_def);
+ }
+ }
+ free(att_lines);
+ free(lyrics_lines);
+ free(image_lines);
+ free(filename_lines);
+out:
+ free(afhi->info_string);
+ 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,
+ "%s: \n" /* path */
+ "%s: \n" /* dirname */
+ "%s: \n" /* basename */
+ "%s: \n" /* score */
+ "%s: \n" /* attributes bitmap */
+ "%s: \n" /* attributes txt */
+ "%s: \n" /* hash */
+ "%s: \n" /* image id */
+ "%s: \n" /* image name */
+ "%s: \n" /* lyrics id */
+ "%s: \n" /* lyrics name */
+ "%s: \n" /* bitrate */
+ "%s: \n" /* format */
+ "%s: \n" /* frequency */
+ "%s: \n" /* channels */
+ "%s: \n" /* duration */
+ "%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],
+ status_item_list[SI_BASENAME],
+ status_item_list[SI_SCORE],
+ status_item_list[SI_ATTRIBUTES_BITMAP],
+ status_item_list[SI_ATTRIBUTES_TXT],
+ status_item_list[SI_HASH],
+ status_item_list[SI_IMAGE_ID],
+ status_item_list[SI_IMAGE_NAME],
+ status_item_list[SI_LYRICS_ID],
+ status_item_list[SI_LYRICS_NAME],
+ status_item_list[SI_BITRATE],
+ status_item_list[SI_FORMAT],
+ status_item_list[SI_FREQUENCY],
+ status_item_list[SI_CHANNELS],
+ 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_AUDIO_FILE_INFO],
+ status_item_list[SI_TAGINFO1],
+ status_item_list[SI_TAGINFO2],
+ status_item_list[SI_AMPLIFICATION]
+ );
+}
+
+static void fixup_taginfo(char *begin, char *end)
+{
+ char *p = begin;
+
+ for (;;) {
+ p = strchr(p, '\n');
+ if (!p)
+ break;
+ if (p >= end - 1)
+ break;
+ *p = ' ';
+ p++;
+ }
+}
+
+/* crap, remove this ASAP. */
+static int fixup_info_string(char *info_string)
+{
+ char *t1, *t2, *end;
+
+ if (strncmp(info_string, "audio_file_info:", 16))
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ t1 = strstr(info_string, "\ntaginfo1:");
+ if (!t1)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ t2 = strstr(info_string, "\ntaginfo2: ");
+ if (!t2)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+
+ end = t2 + strlen(t2);
+ fixup_taginfo(info_string + 16, t1);
+ fixup_taginfo(t1 + 10, t2);
+ fixup_taginfo(t2 + 10, end);
+
+ if (t1 - info_string < 80 && t2 - t1 < 80 && end - t2 < 80)
+ return 0;
+ if (t1 - info_string >= 80) {
+ memmove(info_string + 80, t1, end - t1);
+ t1 = info_string + 80;
+ t2 -= t1 - info_string - 80;
+ end -= t1 - info_string - 80;
+ }
+ if (t2 - t1 >= 80) {
+ memmove(t1 + 80, t2, end - t2);
+ end -= t2 - t1 - 80;
+ t2 = t1 + 80;
+ }
+ if (end - t2 >= 80) {
+ t2[78] = '\n';
+ t2[79] = '\0';