[spice-streaming-server,v2,2/3] Wait to have some client before initialising capture

Submitted by Frediano Ziglio on Nov. 9, 2017, 1:39 p.m.

Details

Message ID 20171109133931.6870-3-fziglio@redhat.com
State New
Headers show
Series "Some updates for" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 9, 2017, 1:39 p.m.
This saves some resources if no client are connected.
Also will allow to get a better capture engine taking into account
client supported codecs.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 src/spice-streaming-agent.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index abe746a..608d2c7 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -345,10 +345,6 @@  static void cursor_changes(Display *display, int event_base)
 static void
 do_capture(const char *streamport, FILE *f_log)
 {
-    std::unique_ptr<FrameCapture> capture(agent.GetBestFrameCapture());
-    if (!capture)
-        throw std::runtime_error("cannot find a suitable capture system");
-
     streamfd = open(streamport, O_RDWR);
     if (streamfd < 0)
         // TODO was syslog(LOG_ERR, "Failed to open %s: %s\n", streamport, strerror(errno));
@@ -370,9 +366,16 @@  do_capture(const char *streamport, FILE *f_log)
             }
         }
 
+        if (quit)
+            return;
+
         syslog(LOG_INFO, "streaming starts now\n");
         uint64_t time_last = 0;
 
+        std::unique_ptr<FrameCapture> capture(agent.GetBestFrameCapture());
+        if (!capture)
+            throw std::runtime_error("cannot find a suitable capture system");
+
         while (!quit && streaming_requested) {
             if (++frame_count % 100 == 0) {
                 syslog(LOG_DEBUG, "SENT %d frames\n", frame_count);
@@ -419,9 +422,6 @@  do_capture(const char *streamport, FILE *f_log)
                 syslog(LOG_ERR, "FAILED to read command\n");
                 return;
             }
-            if (!streaming_requested) {
-                capture->Reset();
-            }
         }
     }
 }