+ ret = para_regcomp(&preg, re, REG_EXTENDED | REG_NOSUB);
+ if (ret < 0)
+ return ret;
+ ret = 0;
+ FOR_EACH_AUDIO_FORMAT(i)
+ if (regexec(&preg, audio_formats[i], 0, NULL, 0) != REG_NOMATCH)
+ ret |= (1 << i);
+ regfree(&preg);
+ return ret;
+}
+
+/**
+ * Compute the play time based on information of the given slot.
+ *
+ * \param slot_num The slot number (negative means: no slot).
+ *
+ * This computes a string of the form "0:07 [3:33] (3%/3:40)" using information
+ * from the status items received from para_server and the start time of the
+ * (first) writer of the given slot.
+ *
+ * It has to to take into account that probably the stream was not started at
+ * the beginning of the file, that the clock between the server and the client
+ * host may differ and that playback of the stream was delayed, e.g. because
+ * the prebuffer filter is used in the filter configuration of the given slot.
+ *
+ * If no writer is active in the given slot, or \a slot_num is negative
+ * (indicating that para_audiod runs in standby mode), an approximation based
+ * only on the status items is computed and the returned string is prefixed
+ * with "~".
+ *
+ * \return A string that must be freed by the caller.
+ */
+char *get_time_string(int slot_num)
+{
+ int ret, seconds = 0, length;
+ struct timeval *tmp, sum, sss, /* server stream start */
+ rstime, /* receiver start time */
+ wstime, /* writer start time */
+ wtime, /* now - writer start */
+ rskip; /* receiver start - sss */
+ struct slot_info *s = slot_num < 0? NULL : &slot[slot_num];
+ char *msg;
+
+ if (audiod_status == AUDIOD_OFF)
+ goto empty;