[client v2 01/12] gstreamer: Avoid a couple of forward function declarations

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

 



Signed-off-by: Francois Gouget <fgouget@xxxxxxxxxxxxxxx>
---

v2: No change.

 src/channel-display-gst.c | 81 ++++++++++++++++++++-------------------
 1 file changed, 42 insertions(+), 39 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 91ece0fa..ec8a7d39 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -120,8 +120,6 @@ static void free_gst_frame(SpiceGstFrame *gstframe)
 /* ---------- GStreamer pipeline ---------- */
 
 static void schedule_frame(SpiceGstDecoder *decoder);
-static void fetch_pending_sample(SpiceGstDecoder *decoder);
-static SpiceGstFrame *get_decoded_frame(SpiceGstDecoder *decoder, GstBuffer *buffer);
 
 RECORDER(frames_stats, 64, "Frames statistics");
 
@@ -184,46 +182,10 @@ static gboolean display_frame(gpointer video_decoder)
     return G_SOURCE_REMOVE;
 }
 
-/* main loop or GStreamer streaming thread */
-static void schedule_frame(SpiceGstDecoder *decoder)
-{
-    guint32 now = stream_get_time(decoder->base.stream);
-    g_mutex_lock(&decoder->queues_mutex);
-
-    while (!decoder->timer_id) {
-        while (decoder->display_frame == NULL && decoder->pending_samples) {
-            fetch_pending_sample(decoder);
-        }
-
-        SpiceGstFrame *gstframe = decoder->display_frame;
-        if (!gstframe) {
-            break;
-        }
-
-        if (spice_mmtime_diff(gstframe->encoded_frame->mm_time, now) >= 0) {
-            decoder->timer_id = g_timeout_add(gstframe->encoded_frame->mm_time - now,
-                                              display_frame, decoder);
-        } else if (decoder->display_frame && !decoder->pending_samples) {
-            /* Still attempt to display the least out of date frame so the
-             * video is not completely frozen for an extended period of time.
-             */
-            decoder->timer_id = g_timeout_add(0, display_frame, decoder);
-        } else {
-            SPICE_DEBUG("%s: rendering too late by %u ms (ts: %u, mmtime: %u), dropping",
-                        __FUNCTION__, now - gstframe->encoded_frame->mm_time,
-                        gstframe->encoded_frame->mm_time, now);
-            stream_dropped_frame_on_playback(decoder->base.stream);
-            decoder->display_frame = NULL;
-            free_gst_frame(gstframe);
-        }
-    }
-
-    g_mutex_unlock(&decoder->queues_mutex);
-}
-
 /* Get the decoded frame relative to buffer or NULL if not found.
  * Dequeue the frame from decoding_queue and return it, caller
  * is responsible to free the pointer.
+ *
  * queues_mutex must be held.
  */
 static SpiceGstFrame *get_decoded_frame(SpiceGstDecoder *decoder, GstBuffer *buffer)
@@ -283,6 +245,10 @@ static SpiceGstFrame *get_decoded_frame(SpiceGstDecoder *decoder, GstBuffer *buf
     return gstframe;
 }
 
+/* Helper for schedule_frame().
+ *
+ * queues_mutex must be held.
+ */
 static void fetch_pending_sample(SpiceGstDecoder *decoder)
 {
     GstSample *sample = gst_app_sink_pull_sample(decoder->appsink);
@@ -315,6 +281,43 @@ static void fetch_pending_sample(SpiceGstDecoder *decoder)
     }
 }
 
+/* main loop or GStreamer streaming thread */
+static void schedule_frame(SpiceGstDecoder *decoder)
+{
+    guint32 now = stream_get_time(decoder->base.stream);
+    g_mutex_lock(&decoder->queues_mutex);
+
+    while (!decoder->timer_id) {
+        while (decoder->display_frame == NULL && decoder->pending_samples) {
+            fetch_pending_sample(decoder);
+        }
+
+        SpiceGstFrame *gstframe = decoder->display_frame;
+        if (!gstframe) {
+            break;
+        }
+
+        if (spice_mmtime_diff(gstframe->encoded_frame->mm_time, now) >= 0) {
+            decoder->timer_id = g_timeout_add(gstframe->encoded_frame->mm_time - now,
+                                              display_frame, decoder);
+        } else if (decoder->display_frame && !decoder->pending_samples) {
+            /* Still attempt to display the least out of date frame so the
+             * video is not completely frozen for an extended period of time.
+             */
+            decoder->timer_id = g_timeout_add(0, display_frame, decoder);
+        } else {
+            SPICE_DEBUG("%s: rendering too late by %u ms (ts: %u, mmtime: %u), dropping",
+                        __FUNCTION__, now - gstframe->encoded_frame->mm_time,
+                        gstframe->encoded_frame->mm_time, now);
+            stream_dropped_frame_on_playback(decoder->base.stream);
+            decoder->display_frame = NULL;
+            free_gst_frame(gstframe);
+        }
+    }
+
+    g_mutex_unlock(&decoder->queues_mutex);
+}
+
 /* GStreamer thread
  *
  * We cannot use GStreamer's signals because they are not always run in
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]