static gboolean audio_note_stop(audio_note_ui *ui);
+#define GST_TIME_TO_SECS(t) \
+ (gdouble) (((gdouble)(t)) / (gdouble) GST_SECOND) /* GST_SECOND should be 1e9 */
+
+static void
+audio_note_set_length(audio_note_ui *ui, gdouble secs)
+{
+gchar buffer[16];
+guint min=0;
+
+if (secs<0.0) {
+ gtk_label_set_text(GTK_LABEL(ui->lbl_time), "--:--");
+ return;
+}
+
+if (secs>=60.0) {
+ min=secs/60.0;
+ secs-=min*60.0;
+}
+
+g_snprintf(buffer, sizeof(buffer), "%u:%05.2f", min, secs);
+gtk_label_set_text(GTK_LABEL(ui->lbl_time), buffer);
+}
+
static gboolean
audio_note_position_cb(gpointer data)
{
GstFormat fmt=GST_FORMAT_TIME;
GstElement *pipe;
gint64 pos, len;
-gchar buffer[128];
audio_note_ui *ui=(audio_note_ui *)data;
if (ui->note_record->active)
else
return TRUE;
-if (gst_element_query_position (pipe, &fmt, &pos) && gst_element_query_duration (pipe, &fmt, &len)) {
- g_snprintf(buffer, sizeof(buffer), "Time: %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT, GST_TIME_ARGS (pos), GST_TIME_ARGS (len));
- gtk_label_set_text(GTK_LABEL(ui->lbl_time), buffer);
+if (gst_element_query_position(pipe, &fmt, &pos) && gst_element_query_duration(pipe, &fmt, &len)) {
+ audio_note_set_length(ui, GST_TIME_TO_SECS(pos));
}
return TRUE;