Commit Graph

2273 Commits

Author SHA1 Message Date
Jonathon Jongsma
680cab338e RedChannelClient: use Gobject properties
Use g_param_spec_object() instead of g_param_spec_pointer() for the
'client' and 'channel' properties now that these types are GObjects.
This improves refcounting and typesafety slightly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-07 17:22:03 +00:00
Pavel Grunt
2051007e05 spice-options-test: Convert to gtest to catch criticals
Fail on glib warnings instead of ignoring them

Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-07 17:18:45 +00:00
Frediano Ziglio
6a3917f653 spicevmc: Change creation of RedCharDeviceSpiceVmc
Instead of having channel and device object create one the other
create the objects at the beginning and then join them.

This make explicit the code that links the two objects and separate
the objects creation from the linking.

Also remove some boilerplate code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-07 10:37:20 +00:00
Jonathon Jongsma
b6cca46d75 spicevmc: use 'channel' instead of 'state'
After renaming the object to RedVmcChannel, the local variables still
used the old 'state' terminology. Changing these variables to 'channel'
makes things a bit more consistent.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 11:02:25 +00:00
Jonathon Jongsma
7e70be6d16 Remove spicevmc_red_channel_client_get_state()
This helper function does nothing but cast the return from
red_channel_client_get_channel(), and it has a confusing name
(_get_state(), but returns a channel)

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 09:15:17 +00:00
Frediano Ziglio
97e299cc50 spicevmc: Clear RedVmcChannel on red_char_device_spicevmc_dispose
This move object destructions from spicevmc_device_disconnect
to RedCharDeviceSpiceVmc destructor functions assuring any possible
RedCharDeviceSpiceVmc object free will clear its references.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:59:18 +00:00
Frediano Ziglio
d80d7447e7 spicevmc: More RedVmcChannel::recv_from_client_buf cleanup to finalize
No reason why this should be done only on spicevmc_device_disconnect.
red_char_device_write_buffer_release can be called with first pointer
NULL.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:59:16 +00:00
Frediano Ziglio
cd7d3d3486 spicevmc: Free pipe_item in finalize
Assure field is freed at the end and not used or allocate again.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:59:06 +00:00
Jonathon Jongsma
f751eb9fdb spicevmc: store channel in char device
Store the channel in the char device object, and unref it in dispose.
Previously, we were just creating a channel and potentially allowing it
to leak.  There may be better long-term solutions, but this works for
now.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:58:38 +00:00
Jonathon Jongsma
fe1583a6a9 Convert RedClient to GObject
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-02 19:30:58 +00:00
Jonathon Jongsma
bc8d967e67 Move RedClient to a separate file
Also move the RedClient struct out of the header to avoid accessing the
internals from other files.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-02 19:30:58 +00:00
Jonathon Jongsma
1f4705e130 Re-arrange channel client creation to avoid exposing client lock
Instead of requiring the channel client to lock the client's lock,
re-arrange things so that all of the locking can be internal to
RedClient methods. So instead of having a pre-create validate function,
we simply move the check to red_client_add_channel() and return an error
if a channel already exists. This encapsulates the client implementation
better and also reduces code duplication in RedChannelClient and
DummyChannelClient.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-02 19:30:53 +00:00
Jonathon Jongsma
b3b5ab3663 Convert RedsState::clients to GList
Switch from a Ring to a GList so that we can hide the internals of
RedClient in a future commit.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-02 16:10:18 +00:00
Frediano Ziglio
19744b41c2 Avoid to typedef twice RedChannel
It's already defined in the same file some lines above.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-02 16:07:25 +00:00
Frediano Ziglio
654dfa4ca5 red-channel-client: Change initialization order
Make the order of initialization closer to what it was before
conversion to GObject.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-02 15:48:04 +00:00
Frediano Ziglio
bac3a682c8 red-channel-client: Move incoming/ougoing initialization to constructor
These fields need just channel to be set to be initialized.
Move their initialization to constructor to make sure
they are initialized as soon as possible.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-02 15:47:59 +00:00
Frediano Ziglio
f5c0e555d3 red-channel-client: Init pipe field during init
There was a chance that on error GQueue were not
initialized but an attempt to destroy it is made.
This ensures GQueue is initialized as soon as
possible. Note that red_channel_client_initable_init
is called after all init and construction callbacks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-02 15:47:39 +00:00
Jonathon Jongsma
e09f8bab6c Rename SpiceVmcState to RedVmcChannel
Internal types use the 'Red' prefix by convention, rather than the
'Spice' prefix. In addition, this type inherits from RedChannel, so
makes the code a lot clearer to call it a 'channel' rather than a
'state'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 15:02:18 +00:00
Frediano Ziglio
5d88c28786 red-channel-client: Remove only written field
id field of RedChannelClient is not used and marked as debugging.
Also it's value is quite confusing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-01 14:24:39 +00:00
Christophe Fergeau
c7f492b75c syntax-check: Add missing license headers
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:48:26 +00:00
Christophe Fergeau
c979647a77 syntax-check: Remove unused header includes
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:48:20 +00:00
Christophe Fergeau
9c21b474c0 syntax-check: Add missing <config.h> includes
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:47:14 +00:00
Christophe Fergeau
d6c5b5c058 syntax-check: Remove trailing whitespace from EOL and EOF
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:46:16 +00:00
Christophe Fergeau
05b7afb3fb syntax-check: Change tabs to spaces
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:43:05 +00:00
Christophe Fergeau
e91c1844f1 syntax-check: Add missing license
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:42:49 +00:00
Francois Gouget
fff92908b2 streaming: Clarify GStreamer's virtual buffer size documentation
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:36:04 +00:00
Jonathon Jongsma
207cd10dcc Limit maximum "n-surfaces" via param spec
In commit beec1b41, we manually limited this property value in
_set_property(). But there's a simpler way to do it: via the param spec
for the property.

This also means that we can remove the warning log in red_worker_new()
since GObject will automatically warn if a property is assigned a value
outside of its valid range.

Change the minimum and default value for this property from 0 to 1 so
that we always have a primary surface.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 12:28:36 +00:00
Pavel Grunt
5fba8dd1a3 Do not enable statistic by default
It is more a feature for developers, not force them.

Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 11:36:33 +00:00
Pavel Grunt
38b741795f Allow to compile without RED_STATISTICS
Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-01 11:36:27 +00:00
Frediano Ziglio
b4c40ea51f Do not declare image_encoders_compress_lz4 if LZ4 is not available
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-01 10:30:27 +00:00
Frediano Ziglio
c5059edb82 Remove red_pipe_add_verb family function
These functions were implementing the same stuff as empty
messages functions provided by RedChannel so reuse them.

The implementation seems a bit different but the result
is the same. Specifically:
- RedEmptyMsgPipeItem::msg is int while RedVerbItem::verb was
  uint16_t however this data goes into the message type which
  is uint16_t (a 16 bit on the network protocol);
- red_channel_client_send_empty_msg calls
  red_channel_client_begin_send_message while red_marshall_verb
  does not. However red_marshall_verb is called only by
  cursor_channel_send_item and dcc_send_item which always
  calls red_channel_client_begin_send_message.
  Note that in dcc_send_item when an empty message is sent
  red_channel_client_send_message_pending always returns
  true;
- when a PipeItem is created red_channel_client_pipe_add_empty_msg
  calls red_channel_client_push while red_pipe_add_verb does not.
  This actually make very little difference as this kind of item are
  never removed from the queue and a push is forced in every case
  running the event handler for the stream watch (see
  prepare_pipe_add and red_channel_client_event).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-11-01 02:15:28 +00:00
Frediano Ziglio
ed9d759ba4 Constify video_codec_caps
This remove a writable global variable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-10-31 13:28:33 +00:00
Frediano Ziglio
909841b312 worker: Remove dependencies from red-worker.h
red_drawable_unref declaration was moved to red-parse-qxl.h.
Result is that only RedDispatcher know of the existence of RedWorker.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-31 10:26:39 +00:00
Frediano Ziglio
2307bb45b5 Move capability initialisation into channel creation
No reason why RedWorker should know the capabilities of
DisplayChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-31 09:40:40 +00:00
Francois Gouget
96818da95d streaming: Limit the h264 image compression level
When uncapped x264enc can compress the frames beyond recognition in low
bitrate situation. Beyond the set limit the gains are modest and it is
better to drop frames to reduce the bit rate further.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-29 10:33:36 +01:00
Frediano Ziglio
2f18466293 Allows to have more than 1 QXL device
This was introduced with 96e94c6f32
(Convert RedChannel hierarchy to GObject).
The id of CursorChannel/DisplayChannel were always 0 causing
a wrong assertion on the code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-28 15:04:48 +01:00
Frediano Ziglio
6fe8d5d49d Call parent constructor always at the beginning
In this case there is not much change but better
to follow that style as all other constructors
do.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-28 15:04:44 +01:00
Frediano Ziglio
695dd7c58d Fix handle-acks regression
This was introduced with 96e94c6f32
(Convert RedChannel hierarchy to GObject).
The handle-acks settings was TRUE for CursorChannel and DisplayChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-28 15:02:36 +01:00
Frediano Ziglio
f96a78fc4b Fix typo in comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-27 17:05:44 +01:00
Frediano Ziglio
13e9cf0194 Fix core-interface type regression
This was introduced with 96e94c6f32
(Convert RedChannel hierarchy to GObject).
The type for "core-interface" property should be
SpiceCoreInterfaceInternal, not SpiceCoreInterface.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-27 10:36:56 +01:00
Frediano Ziglio
542bc47846 Remove g_smartcard_channel global
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-27 10:28:59 +01:00
Frediano Ziglio
555886c8d7 Remove duplicate include
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-26 09:45:57 +01:00
Pavel Grunt
840040b51e Add missing header to Makefile.am
Fix make distcheck

Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-26 07:47:44 +01:00
Jonathon Jongsma
35b7f4d5ef Implement vfuncs for DummyChannel
96e94c6f inadvertantly introduced a regression where an assert was
triggered in red_channel_constructed for DummyChannel since DummyChannel
didn't implement any of the expected RedChannel vfuncs. This patch
avoids the assert by assigning some empty vfuncs.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-25 16:24:03 -05:00
Jonathon Jongsma
96e94c6f32 Convert RedChannel hierarchy to GObject
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-25 11:32:13 -05:00
Frediano Ziglio
8f43c8348c Remove unused declaration
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-25 15:16:53 +01:00
Frediano Ziglio
afd4d44807 red-worker: Do not include not necessary red-channel-client.h
Definitions are all in red-channel.h

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-20 17:19:39 +01:00
Frediano Ziglio
177c331c53 Avoid to typedef twice MainChannel
MainChannel is already defined in main-channel.h.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-20 17:01:19 +01:00
Frediano Ziglio
beec1b4175 display channel: Don't let client set too many surfaces
Limit the n_surfaces argument to avoid overflowing the surfaces array.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-20 16:43:51 +01:00
Frediano Ziglio
090fbe5eeb Avoid recursive inclusion of headers
red-common.h included utils.h which included red-common.h

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-10-20 16:33:20 +01:00