<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 30, 2013 at 8:24 PM, Yonit Halperin <span dir="ltr"><<a href="mailto:yhalperi@redhat.com" target="_blank">yhalperi@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">mm-time can change after migration. This can cause video synchronization<br>
problems after migration if not handled appropriately (see rhbz#951664).<br>
---<br>
 gtk/spice-session.c | 29 +++++++++++++++++++++++++++++<br>
 gtk/spice-session.h |  3 ++-<br>
 2 files changed, 31 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/gtk/spice-session.c b/gtk/spice-session.c<br>
index f46ac01..765fb48 100644<br>
--- a/gtk/spice-session.c<br>
+++ b/gtk/spice-session.c<br>
@@ -115,6 +115,7 @@ enum {<br>
 enum {<br>
     SPICE_SESSION_CHANNEL_NEW,<br>
     SPICE_SESSION_CHANNEL_DESTROY,<br>
+    SPICE_SESSION_MM_TIME_RESET,<br>
     SPICE_SESSION_LAST_SIGNAL,<br>
 };<br>
<br>
@@ -1071,6 +1072,24 @@ static void spice_session_class_init(SpiceSessionClass *klass)<br>
                      SPICE_TYPE_CHANNEL);<br>
<br>
     /**<br>
+     * SpiceSession::mm-time-reset:<br>
+     * @session: the session that emitted the signal<br>
+     *<br>
+     * The #SpiceSession::mm-time-reset is emitted when we identify discontinuity in mm-time<br>
+     *<br>
+     * Since 0.20<br>
+     **/<br>
+    signals[SPICE_SESSION_MM_TIME_RESET] =<br>
+        g_signal_new("mm-time-reset",<br>
+                     G_OBJECT_CLASS_TYPE(gobject_class),<br>
+                     G_SIGNAL_RUN_FIRST,<br>
+                     G_STRUCT_OFFSET(SpiceSessionClass, mm_time_reset),<br>
+                     NULL, NULL,<br>
+                     g_cclosure_marshal_VOID__VOID,<br>
+                     G_TYPE_NONE,<br>
+                     0);<br>
+<br>
+    /**<br>
      * SpiceSession:read-only:<br>
      *<br>
      * Whether this connection is read-only mode.<br>
@@ -1927,16 +1946,26 @@ guint32 spice_session_get_mm_time(SpiceSession *session)<br>
     return s->mm_time + (g_get_monotonic_time() - s->mm_time_at_clock) / 1000;<br>
 }<br>
<br>
+#define MM_TIME_DIFF_RESET_THRESH 5000 // 5 sec<br></blockquote><div><br></div><div>5 seconds seems rather large. Why not something much smaller, like 0.5 sec?<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+<br>
 G_GNUC_INTERNAL<br>
 void spice_session_set_mm_time(SpiceSession *session, guint32 time)<br>
 {<br>
     SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);<br>
+    guint32 old_time;<br>
<br>
     g_return_if_fail(s != NULL);<br>
<br>
+    old_time = spice_session_get_mm_time(session);<br>
+<br>
     s->mm_time = time;<br>
     s->mm_time_at_clock = g_get_monotonic_time();<br>
     SPICE_DEBUG("set mm time: %u", spice_session_get_mm_time(session));<br>
+    if (time > old_time + MM_TIME_DIFF_RESET_THRESH ||<br>
+        old_time > time + MM_TIME_DIFF_RESET_THRESH) {<br></blockquote><div><br></div><div>imho, time < old_time shouldn't need any threshold.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+        SPICE_DEBUG("%s: mm-time-reset, old %u, new %u", __FUNCTION__, old_time, s->mm_time);<br>
+        g_signal_emit(session, signals[SPICE_SESSION_MM_TIME_RESET], 0);<br></blockquote><div><br></div><div>We have to be careful  about coroutine context when emiting signals. Since this function is called from coroutine, we can should check if the current context  is main/leader or if it has a caller / running a coroutine. Perhaps the easier would be to augment emit_main_context() macro to handle this in all cases.<br>
 <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+    }<br>
 }<br>
<br>
 G_GNUC_INTERNAL<br>
diff --git a/gtk/spice-session.h b/gtk/spice-session.h<br>
index b07f525..86056e2 100644<br>
--- a/gtk/spice-session.h<br>
+++ b/gtk/spice-session.h<br>
@@ -74,13 +74,14 @@ struct _SpiceSessionClass<br>
     /* signals */<br>
     void (*channel_new)(SpiceSession *session, SpiceChannel *channel);<br>
     void (*channel_destroy)(SpiceSession *session, SpiceChannel *channel);<br>
+    void (*mm_time_reset)(SpiceSession *session);<br>
<br></blockquote><div><br></div><div>The class handler isn't strictly necessary (it is used for derived class who want to override the default class handler)<br></div><div>I think we shouldn't add it.<br></div><div>
 <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
     /*< private >*/<br>
     /*<br>
      * If adding fields to this struct, remove corresponding<br>
      * amount of padding to avoid changing overall struct size<br>
      */<br>
-    gchar _spice_reserved[SPICE_RESERVED_PADDING];<br>
+    gchar _spice_reserved[SPICE_RESERVED_PADDING - sizeof(void *)];<br>
 };<br>
<br>
 GType spice_session_get_type(void);<br>
<span class=""><font color="#888888">--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Marc-André Lureau
</div></div>