[longomatch] Stop timeout if we are playing



commit 1159207fad5080b061f1ccb78ca7470a1d179ccc
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Jul 17 11:16:35 2014 +0200

    Stop timeout if we are playing

 LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs |   23 ++++++++++++++---------
 libcesarplayer/lgm-video-player.c          |    3 +++
 2 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index a90ca07..d7b1eaf 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -103,10 +103,7 @@ namespace LongoMatch.Gui
                #endregion
                protected override void OnDestroyed ()
                {
-                       if (timeout != 0) {
-                               GLib.Source.Remove (timeout);
-                               timeout = 0;
-                       }
+                       ReconfigureTimeout (0);
                        player.Dispose ();
                        blackboard.Dispose ();
                        base.OnDestroyed ();
@@ -176,7 +173,6 @@ namespace LongoMatch.Gui
                #region Public methods
 
                public void Open (string filename) {
-                       timeout = GLib.Timeout.Add (20, OnTick);
                        Open (filename, true);
                }
 
@@ -226,10 +222,7 @@ namespace LongoMatch.Gui
                }
                
                public void Close() {
-                       if (timeout != 0) {
-                               GLib.Source.Remove (timeout);
-                               timeout = 0;
-                       }
+                       ReconfigureTimeout (0);
                        player.Close();
                        filename = null;
                        timescale.Value = 0;
@@ -450,6 +443,16 @@ namespace LongoMatch.Gui
                        videodrawingarea.ExposeEvent += HandleExposeEvent;
                        videodrawingarea.CanFocus = false;
                }
+               
+               void ReconfigureTimeout (uint mseconds) {
+                       if (timeout != 0) {
+                               GLib.Source.Remove (timeout);
+                               timeout = 0;
+                       }
+                       if (mseconds != 0) {
+                               timeout = GLib.Timeout.Add (mseconds, OnTick);
+                       }
+               }
 
                #endregion
 
@@ -461,10 +464,12 @@ namespace LongoMatch.Gui
                
                void OnStateChanged(bool playing) {
                        if(playing) {
+                               ReconfigureTimeout (20);
                                playbutton.Hide();
                                pausebutton.Show();
                        }
                        else {
+                               ReconfigureTimeout (0);
                                playbutton.Show();
                                pausebutton.Hide();
                        }
diff --git a/libcesarplayer/lgm-video-player.c b/libcesarplayer/lgm-video-player.c
index 8179798..bd80f41 100644
--- a/libcesarplayer/lgm-video-player.c
+++ b/libcesarplayer/lgm-video-player.c
@@ -144,6 +144,9 @@ lgm_error_msg (LgmVideoPlayer * lvp, GstMessage * msg)
 static void
 lgm_reconfigure_tick_timeout (LgmVideoPlayer * lvp, guint msecs)
 {
+  /* Tick timeouts are not used anymore */
+  return;
+
   if (lvp->priv->update_id != 0) {
     g_source_remove (lvp->priv->update_id);
     lvp->priv->update_id = 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]