[Spice-devel] [spice-list] [RFC spice-streaming-agent 2/2] spice-streaming-agent: fully reset the capture loop on start/stop requests

Christophe de Dinechin dinechin at redhat.com
Wed Jul 31 09:26:31 UTC 2019


Kevin Pouget writes:

> With this patch, spice-streaming-agent exits the frame-sending loop
> when START/STOP requests are received. This allows the recomputation
> of the most suitable capture/encoding plugin, that may have been
> updated with START/STOP message.
> ---
>  src/spice-streaming-agent.cpp | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 49f5dc4..3626ecc 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -126,6 +126,7 @@ private:
>  };
>
>  static bool streaming_requested = false;
> +static bool reset_requested = false;
>  static bool quit_requested = false;
>  static std::set<SpiceVideoCodecType> client_codecs;
>
> @@ -169,6 +170,7 @@ static void read_command_from_device(StreamPort &stream_port)
>          StartStopMessage msg = in_message.get_payload<StartStopMessage>();
>          streaming_requested = msg.start_streaming;
>          client_codecs = msg.client_codecs;
> +        reset_requested = true;
>
>          syslog(LOG_INFO, "GOT START_STOP message -- request to %s streaming",
>                 streaming_requested ? "START" : "STOP");
> @@ -240,13 +242,16 @@ do_capture(StreamPort &stream_port, FrameLog &frame_log, ConcreteAgent &agent)
>          if (quit_requested) {
>              return;
>          }
> +        reset_requested = false;
>
>          syslog(LOG_INFO, "streaming starts now");
>          uint64_t time_last = 0;
>
>          std::unique_ptr<FrameCapture> capture(agent.GetBestFrameCapture(client_codecs));
>          if (!capture) {
> -            throw std::runtime_error("cannot find a suitable capture system");
> +            syslog(LOG_ERR, "Error cannot find a suitable capture system");
> +            streaming_requested = false;
> +            continue;

Please add a comment explaining the effect of clearing
"streaming_requested". Maybe it would be worth renaming the variable
with your change, maybe something like "capture_in_progress"?

>          }
>
>          std::vector<DeviceDisplayInfo> display_info;
> @@ -275,7 +280,7 @@ do_capture(StreamPort &stream_port, FrameLog &frame_log, ConcreteAgent &agent)
>              syslog(LOG_ERR, "Empty device display info from the plugin");
>          }
>
> -        while (!quit_requested && streaming_requested) {
> +        while (!quit_requested && streaming_requested && !reset_requested) {
>              if (++frame_count % 100 == 0) {
>                  syslog(LOG_DEBUG, "SENT %d frames", frame_count);
>              }


--
Cheers,
Christophe de Dinechin (IRC c3d)


More information about the Spice-devel mailing list