[Xfce4-commits] <parole:master> Use gint64 in seconds as a duration for the stream everywhere.
Ali Abdallah
noreply at xfce.org
Thu Nov 26 10:16:06 CET 2009
Updating branch refs/heads/master
to 0f258ea927d82eff8c2e1a02a882bb3baaf13f01 (commit)
from fec37f5d94c21912a8df40d019e37b19712cf0bd (commit)
commit 0f258ea927d82eff8c2e1a02a882bb3baaf13f01
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Thu Nov 26 08:59:30 2009 +0100
Use gint64 in seconds as a duration for the stream everywhere.
TODO | 1 -
browser-plugin/media-plugin/parole-plugin-player.c | 4 +-
gst/gstmarshal.list | 2 +-
gst/parole-gst.c | 43 ++++++++++----------
gst/parole-gst.h | 6 +-
parole/parole-stream.c | 10 ++--
plugins/properties/stream-properties-provider.c | 2 +-
src/main.c | 1 -
src/parole-statusbar.c | 37 +++++++++++++++--
9 files changed, 66 insertions(+), 40 deletions(-)
diff --git a/TODO b/TODO
index e1f6af4..b220056 100644
--- a/TODO
+++ b/TODO
@@ -9,6 +9,5 @@
* Write a youtube plugin.
* Subtitle downloader.
* Always on top.
-* Power manager inhibit while playing.
* thumbnail.
* ...?
diff --git a/browser-plugin/media-plugin/parole-plugin-player.c b/browser-plugin/media-plugin/parole-plugin-player.c
index a75edd4..a3ced75 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.c
+++ b/browser-plugin/media-plugin/parole-plugin-player.c
@@ -253,7 +253,7 @@ parole_plugin_player_media_state_cb (ParoleGst *gst, const ParoleStream *stream,
if ( state == PAROLE_MEDIA_STATE_PLAYING )
{
- gdouble duration;
+ gint64 duration;
gboolean seekable;
gboolean live;
@@ -347,7 +347,7 @@ parole_plugin_player_volume_changed_cb (GtkWidget *volume, gdouble value, Parole
static void
parole_plugin_player_media_progressed_cb (ParoleGst *gst, const ParoleStream *stream,
- gdouble value, ParolePluginPlayer *player)
+ gint64 value, ParolePluginPlayer *player)
{
if ( !player->priv->user_seeking && player->priv->state == PAROLE_MEDIA_STATE_PLAYING )
diff --git a/gst/gstmarshal.list b/gst/gstmarshal.list
index 61cba6f..4447534 100644
--- a/gst/gstmarshal.list
+++ b/gst/gstmarshal.list
@@ -1,4 +1,4 @@
VOID:OBJECT,ENUM
-VOID:OBJECT,DOUBLE
+VOID:OBJECT,INT64
VOID:OBJECT,INT
diff --git a/gst/parole-gst.c b/gst/parole-gst.c
index f9c65e3..2099f38 100644
--- a/gst/parole-gst.c
+++ b/gst/parole-gst.c
@@ -533,8 +533,8 @@ parole_gst_tick_timeout (gpointer data)
gint64 pos;
GstFormat format = GST_FORMAT_TIME;
- gdouble value;
- gboolean video;
+ gint64 value;
+ gint64 video;
gst = PAROLE_GST (data);
@@ -549,8 +549,10 @@ parole_gst_tick_timeout (gpointer data)
if ( gst->priv->state == GST_STATE_PLAYING )
{
- value = ( pos / ((gdouble) 60 * 1000 * 1000 * 1000 ));
- g_signal_emit (G_OBJECT (gst), signals [MEDIA_PROGRESSED], 0, gst->priv->stream, value);
+ value = pos / GST_SECOND;
+
+ if ( G_LIKELY (value > 0) )
+ g_signal_emit (G_OBJECT (gst), signals [MEDIA_PROGRESSED], 0, gst->priv->stream, value);
}
out:
@@ -604,7 +606,7 @@ static void
parole_gst_query_duration (ParoleGst *gst)
{
gint64 absolute_duration = 0;
- gdouble duration = 0;
+ gint64 duration = 0;
gboolean live;
GstFormat gst_time;
@@ -616,10 +618,10 @@ parole_gst_query_duration (ParoleGst *gst)
if (gst_time == GST_FORMAT_TIME)
{
- duration = absolute_duration / ((gdouble) 60 * 1000 * 1000 * 1000);
+ duration = absolute_duration / GST_SECOND;
live = ( absolute_duration == 0 );
- TRACE ("Duration %e is_live=%d", duration, live);
+ TRACE ("Duration %lld is_live=%d", duration, live);
g_object_set (G_OBJECT (gst->priv->stream),
"absolute-duration", absolute_duration,
@@ -912,9 +914,6 @@ parole_gst_evaluate_state (ParoleGst *gst, GstState old, GstState new, GstState
break;
case GST_STATE_READY:
gst->priv->buffering = FALSE;
- if ( gst->priv->update_vis)
- parole_gst_update_vis (gst);
-
gst->priv->media_state = PAROLE_MEDIA_STATE_STOPPED;
g_signal_emit (G_OBJECT (gst), signals [MEDIA_STATE], 0,
gst->priv->stream, PAROLE_MEDIA_STATE_STOPPED);
@@ -1289,6 +1288,11 @@ parole_gst_play_file_internal (ParoleGst *gst)
TRACE ("*** Error *** This is a bug, playbin element is already playing");
}
+ if ( gst->priv->update_vis)
+ parole_gst_update_vis (gst);
+
+ gtk_widget_queue_draw (GTK_WIDGET (gst));
+
g_object_get (G_OBJECT (gst->priv->stream),
"uri", &uri,
NULL);
@@ -1708,9 +1712,9 @@ parole_gst_class_init (ParoleGstClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (ParoleGstClass, media_progressed),
NULL, NULL,
- _gmarshal_VOID__OBJECT_DOUBLE,
+ _gmarshal_VOID__OBJECT_INT64,
G_TYPE_NONE, 2,
- G_TYPE_OBJECT, G_TYPE_DOUBLE);
+ G_TYPE_OBJECT, G_TYPE_INT64);
signals [MEDIA_TAG] =
g_signal_new ("media-tag",
@@ -1960,7 +1964,7 @@ void parole_gst_seek (ParoleGst *gst, gdouble pos)
{
gint64 seek;
gint64 absolute_duration;
- gdouble duration;
+ gint64 duration;
gboolean seekable;
TRACE ("Seeking");
@@ -1977,7 +1981,7 @@ void parole_gst_seek (ParoleGst *gst, gdouble pos)
g_return_if_fail (seekable == TRUE);
#endif
- seek = (gint64) (pos * absolute_duration) / duration;
+ seek = (pos * absolute_duration) / duration;
g_warn_if_fail ( gst_element_seek (gst->priv->playbin,
1.0,
@@ -2065,9 +2069,9 @@ gint parole_gst_get_current_cdda_track (ParoleGst *gst)
return ret_val;
}
-gdouble parole_gst_get_stream_duration (ParoleGst *gst)
+gint64 parole_gst_get_stream_duration (ParoleGst *gst)
{
- gdouble dur;
+ gint64 dur;
g_object_get (G_OBJECT (gst->priv->stream),
"duration", &dur,
@@ -2075,17 +2079,14 @@ gdouble parole_gst_get_stream_duration (ParoleGst *gst)
return dur;
}
-gdouble parole_gst_get_stream_position (ParoleGst *gst)
+gint64 parole_gst_get_stream_position (ParoleGst *gst)
{
GstFormat format = GST_FORMAT_TIME;
- gdouble value;
gint64 pos;
gst_element_query_position (gst->priv->playbin, &format, &pos);
- value = ( pos / ((gdouble) 60 * 1000 * 1000 * 1000 ));
-
- return value;
+ return pos / GST_SECOND;
}
gboolean parole_gst_get_is_xvimage_sink (ParoleGst *gst)
diff --git a/gst/parole-gst.h b/gst/parole-gst.h
index b07b70a..52c4eb9 100644
--- a/gst/parole-gst.h
+++ b/gst/parole-gst.h
@@ -76,7 +76,7 @@ typedef struct
void (*media_progressed) (ParoleGst *gst,
const ParoleStream *stream,
- gdouble value);
+ gint64 value);
void (*buffering) (ParoleGst *gst,
const ParoleStream *stream,
@@ -144,9 +144,9 @@ gint parole_gst_get_current_cdda_track (ParoleGst *gst);
ParoleMediaType parole_gst_get_current_stream_type (ParoleGst *gst);
-gdouble parole_gst_get_stream_duration (ParoleGst *gst);
+gint64 parole_gst_get_stream_duration (ParoleGst *gst);
-gdouble parole_gst_get_stream_position (ParoleGst *gst);
+gint64 parole_gst_get_stream_position (ParoleGst *gst);
gboolean parole_gst_get_is_xvimage_sink (ParoleGst *gst);
diff --git a/parole/parole-stream.c b/parole/parole-stream.c
index d563b76..580e57a 100644
--- a/parole/parole-stream.c
+++ b/parole/parole-stream.c
@@ -55,10 +55,10 @@ struct _ParoleStreamPrivate
gboolean live;
gboolean seekable;
gboolean tag_available;
- gdouble duration;
gint video_w;
gint video_h;
gint64 absolute_duration;
+ gint duration;
guint tracks;
guint track;
guint disp_par_n;
@@ -180,7 +180,7 @@ static void parole_stream_set_property (GObject *object,
PAROLE_STREAM_GET_PRIVATE (stream)->tag_available = g_value_get_boolean (value);
break;
case PROP_DURATION:
- PAROLE_STREAM_GET_PRIVATE (stream)->duration = g_value_get_double (value);
+ PAROLE_STREAM_GET_PRIVATE (stream)->duration = g_value_get_int64 (value);
break;
case PROP_ABSOLUTE_DURATION:
PAROLE_STREAM_GET_PRIVATE (stream)->absolute_duration = g_value_get_int64 (value);
@@ -250,7 +250,7 @@ static void parole_stream_get_property (GObject *object,
g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_n);
break;
case PROP_DURATION:
- g_value_set_double (value, PAROLE_STREAM_GET_PRIVATE (stream)->duration);
+ g_value_set_int64 (value, PAROLE_STREAM_GET_PRIVATE (stream)->duration);
break;
case PROP_TRACKS:
g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->tracks);
@@ -429,10 +429,10 @@ parole_stream_class_init (ParoleStreamClass *klass)
**/
g_object_class_install_property (object_class,
PROP_DURATION,
- g_param_spec_double("duration",
+ g_param_spec_int64 ("duration",
"Duration",
"Duration",
- 0, G_MAXDOUBLE,
+ 0, G_MAXINT64,
0,
G_PARAM_READWRITE));
diff --git a/plugins/properties/stream-properties-provider.c b/plugins/properties/stream-properties-provider.c
index c7e1e6a..d8f8d95 100644
--- a/plugins/properties/stream-properties-provider.c
+++ b/plugins/properties/stream-properties-provider.c
@@ -453,7 +453,7 @@ tag_message_cb (ParoleProviderPlayer *player, const ParoleStream *stream, Stream
}
}
- sensitive = media_type = PAROLE_MEDIA_TYPE_LOCAL_FILE
+ sensitive = media_type = PAROLE_MEDIA_TYPE_LOCAL_FILE;
gtk_widget_set_sensitive (prop->title, sensitive);
gtk_widget_set_sensitive (prop->artist, sensitive);
gtk_widget_set_sensitive (prop->album, sensitive);
diff --git a/src/main.c b/src/main.c
index 803c06e..5f65b1e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -287,7 +287,6 @@ int main (int argc, char **argv)
{
if ( g_strv_length (filenames) == 1 && parole_is_uri_disc (filenames[0]))
{
- g_debug ("Yalla");
parole_player_play_uri_disc (player, filenames[0], device);
}
else
diff --git a/src/parole-statusbar.c b/src/parole-statusbar.c
index 6929d8d..11e7137 100644
--- a/src/parole-statusbar.c
+++ b/src/parole-statusbar.c
@@ -47,8 +47,8 @@ struct ParoleStatusbarPrivate
GtkWidget *label_duration;
GtkWidget *sep;
- gdouble duration;
- gdouble pos;
+ gint64 duration;
+ gint64 pos;
};
G_DEFINE_TYPE (ParoleStatusbar, parole_statusbar, G_TYPE_OBJECT)
@@ -68,8 +68,30 @@ parole_statusbar_set_buffering (ParoleStatusbar *bar, gint percentage)
g_free (buff);
}
+static void
+get_time_string (gchar *timestring, gint total_seconds)
+{
+ gint hours;
+ gint minutes;
+ gint seconds;
+
+ minutes = total_seconds / 60;
+ seconds = total_seconds % 60;
+ hours = minutes / 60;
+ minutes = minutes % 60;
+
+ if ( hours == 0 )
+ {
+ g_snprintf (timestring, 128, "%02i:%02i", minutes, seconds);
+ }
+ else
+ {
+ g_snprintf (timestring, 128, "%i:%02i:%02i", hours, minutes, seconds);
+ }
+}
+
static void
-parole_statusbar_set_duration (ParoleStatusbar *bar, ParoleMediaState state, gdouble position)
+parole_statusbar_set_duration (ParoleStatusbar *bar, ParoleMediaState state, gint64 position)
{
gchar *text = NULL;
@@ -85,8 +107,13 @@ parole_statusbar_set_duration (ParoleStatusbar *bar, ParoleMediaState state, gdo
{
if ( bar->priv->duration != 0)
{
- text = g_strdup_printf ("%s %4.2f/%4.2f",
- state == PAROLE_MEDIA_STATE_PAUSED ? _("Paused") : _("Playing"), position, bar->priv->duration);
+ gchar pos_text[128], dur_text[128];
+ get_time_string (pos_text, position);
+ get_time_string (dur_text, bar->priv->duration);
+ text = g_strdup_printf ("%s %s/%s",
+ state == PAROLE_MEDIA_STATE_PAUSED ? _("Paused") : _("Playing"),
+ pos_text,
+ dur_text);
}
if ( text )
{
More information about the Xfce4-commits
mailing list