return msg;
}
-/*
- * compute status bar string. Never returns NULL
- */
-static char *get_sb_string(struct misc_meta_data *nmmd)
-{
- char *base, *ret;
- long long unsigned secs = 0, rsecs = 0, percent = 0;
-
- base = para_basename(nmmd->filename);
- if (!base)
- return para_strdup("");
- if (!base[0])
- return base;
- if (nmmd->afi.chunks_total) {
- secs = (long long) nmmd->afi.seconds_total * nmmd->chunks_sent
- / nmmd->afi.chunks_total;
- rsecs = (long long) nmmd->afi.seconds_total *
- (nmmd->afi.chunks_total - nmmd->chunks_sent)
- / nmmd->afi.chunks_total;
- percent = 100 * ((nmmd->chunks_sent + 5) / 10)
- / ((nmmd->afi.chunks_total + 5) / 10);
- }
- ret = make_message("%llu:%02llu [%llu:%02llu] (%llu%%) %s",
- secs / 60, secs % 60,
- rsecs / 60, rsecs % 60,
- percent,
- base
- );
- free(base);
- return ret;
-}
-
static char *get_status(struct misc_meta_data *nmmd)
{
char *bar, *ret, mtime[30] = "";
);
}
-/* sc */
-int com_sc(int fd, int argc, char * const * argv)
-{
- char *name = NULL;
- int ret, old = 0, count = -1; /* print af change forever */
-
- if (argc > 1)
- count = atoi(argv[1]);
-repeat:
- mmd_lock();
- if (old != mmd->num_played) {
- old = mmd->num_played;
- name = para_strdup(mmd->filename);
- }
- mmd_unlock();
- if (name) {
- ret = send_va_buffer(fd, "%s\n", name);
- free(name);
- name = NULL;
- if (ret < 0)
- return ret;
- if (argc > 1 && !--count)
- return 1;
- }
- usleep(500000);
- goto repeat;
-}
-
-/* sb */
-int com_sb(int fd, int argc, char * const * argv)
-{
- char *sb;
- int ret, nr = -1; /* status bar will be printed that many
- * times. Negative value means: print
- * forever
- */
- if (argc > 1)
- nr = atoi(argv[1]);
- while (nr) {
- mmd_lock();
- sb = get_sb_string(mmd);
- mmd_unlock();
- ret = send_va_buffer(fd, "%s\n", sb);
- free(sb);
- if (ret < 0)
- return ret;
- if (nr == 1)
- return 1;
- usleep(500000);
- if (nr > 0)
- nr--;
- }
- return 1;
-}
-
/* stat */
int com_stat(int fd, int argc, char * const * argv)
{
H: Set the 'P' (playing) bit of the vss status flags. This
H: results in starting/continuing to stream.
---
-N: sb
-P: VSS_READ
-D: print status bar for current audio file
-U: sb [n]
-H: Without any arguments, sb continuously prints a status bar of the
-H: form
-H:
-H: 12:34 [56:12] (56%) filename
-H:
-H: indicating playing time, remaining time, percentage and the name of
-H: the file being streamed. Use the optional number n to let stat exit
-H: after having displayed the status bar n times.
----
-N: sc
-P: VSS_READ
-D: print name of audio file whenever it changes
-U: sc [n]
-H: sc prints exactly one line (the filename of the audio file
-H: being played) whenever the audio file changes. Stops after
-H: n iterations, or never if n is not specified.
----
N: sender
P: VSS_READ | VSS_WRITE
D: control paraslash internal senders