[Muine] [PATCH] position tracking via gstreamer (instead of GTimer)
- From: Peter Johanson <latexer gentoo org>
- To: muine-list gnome org
- Subject: [Muine] [PATCH] position tracking via gstreamer (instead of GTimer)
- Date: Tue, 21 Mar 2006 20:50:21 -0800
hey folks,
gstreamer-0.10 seems to have (at least from testing here) vastly
improved the position querying compared to 0.8. To be safe, I'd love for
some folks to stress test the attached patch, which changes the
gstreamer 0.10 backend to no longer using a seperate GTimer for tracking
the song position.
This should *hopefully* help resolve bugs #332921, and #319522. I'll be
doing more testing here locally sometime this week, especially for bug
#319522, which is more easily reproducable/testable.
Thanks all, please report back your success/failures in responses here
(for successes, i expect testing in the order of a day or two, not just
2 minutes, then a "yes, it works for me". Failures should be more
immediately apparently. (: )
-pete
--
Peter Johanson
<latexer gentoo org>
? po/stamp-it
Index: libmuine/player-gst.c
===================================================================
RCS file: /cvs/gnome/muine/libmuine/player-gst.c,v
retrieving revision 1.16
diff -u -B -r1.16 player-gst.c
--- libmuine/player-gst.c 1 Feb 2006 06:35:03 -0000 1.16
+++ libmuine/player-gst.c 22 Mar 2006 04:45:57 -0000
@@ -55,9 +55,6 @@
guint iterate_idle_id;
guint tick_timeout_id;
-
- GTimer *timer;
- long timer_add;
};
static GObjectClass *parent_class;
@@ -144,10 +141,6 @@
priv = g_new0 (PlayerPriv, 1);
player->priv = priv;
- priv->timer = g_timer_new ();
- g_timer_stop (priv->timer);
- priv->timer_add = 0;
-
priv->tick_timeout_id = g_timeout_add (200, (GSourceFunc) tick_timeout, player);
priv->play = gst_element_factory_make ("playbin", "play");
@@ -178,8 +171,6 @@
player_stop (player);
- g_timer_destroy (player->priv->timer);
-
if (player->priv->iterate_idle_id > 0)
g_source_remove (player->priv->iterate_idle_id);
if (player->priv->tick_timeout_id > 0)
@@ -262,10 +253,6 @@
break;
case GST_MESSAGE_EOS:
- player->priv->timer_add += floor (g_timer_elapsed (player->priv->timer, NULL) + 0.5);
- g_timer_stop (player->priv->timer);
- g_timer_reset (player->priv->timer);
-
g_signal_emit (player, signals[END_OF_STREAM], 0);
break;
@@ -308,10 +295,6 @@
if (!file)
return FALSE;
- g_timer_stop (player->priv->timer);
- g_timer_reset (player->priv->timer);
- player->priv->timer_add = 0;
-
escaped = gnome_vfs_escape_path_string (file);
// FIXME get rid of this one when the switch to gnome-vfs is made
player->priv->current_file = g_strdup_printf ("file://%s", escaped);
@@ -329,8 +312,6 @@
g_return_if_fail (IS_PLAYER (player));
gst_element_set_state (GST_ELEMENT (player->priv->play), GST_STATE_PLAYING);
-
- g_timer_start (player->priv->timer);
}
void
@@ -341,10 +322,6 @@
g_free (player->priv->current_file);
player->priv->current_file = NULL;
- g_timer_stop (player->priv->timer);
- g_timer_reset (player->priv->timer);
- player->priv->timer_add = 0;
-
gst_element_set_state (GST_ELEMENT (player->priv->play), GST_STATE_READY);
}
@@ -354,10 +331,6 @@
g_return_if_fail (IS_PLAYER (player));
gst_element_set_state (GST_ELEMENT (player->priv->play), GST_STATE_PAUSED);
-
- player->priv->timer_add += floor (g_timer_elapsed (player->priv->timer, NULL) + 0.5);
- g_timer_stop (player->priv->timer);
- g_timer_reset (player->priv->timer);
}
static void
@@ -431,15 +404,19 @@
GST_SEEK_TYPE_SET,
t * GST_SECOND,
0, 0);
-
- g_timer_reset (player->priv->timer);
- player->priv->timer_add = t;
}
int
player_tell (Player *player)
{
+ GstFormat format = GST_FORMAT_TIME;
+ gint64 val;
+
g_return_val_if_fail (IS_PLAYER (player), -1);
- return (int) floor (g_timer_elapsed (player->priv->timer, NULL) + 0.5) + player->priv->timer_add;
+ if (gst_element_query_position (player->priv->play, &format, &val)) {
+ return (int) (val / GST_SECOND);
+ }
+
+ return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]