Commit Graph

2594 Commits

Author SHA1 Message Date
Christophe Fergeau
968f3ab3e8 Add RedCharDeviceWriteBufferPrivate
This is intended to hold the fields that only char-device.c has a use
for, but for now this only adds the boilerplate for it, the next commit
will move the relevant field there.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-28 16:59:25 +02:00
Christophe Fergeau
ecdef4930b Remove redundant code from red_channel_client_msg_sent()
red_channel_client_clear_sent_item() will clear send_data.blocked, so no
need to do it in red_channel_client_msg_sent() as well.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-28 16:59:25 +02:00
Christophe Fergeau
2a3b6c2c00 Use red_channel_client_set_blocked() helper
Now that red_channel_client_set_blocked() is no longer changing the
events we are watching for, we can call it from
red_channel_client_push().

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-28 16:59:25 +02:00
Christophe Fergeau
2eb491cb6b Don't modify watch when network queue is full
Since 5c460d, we need to watch for WATCH_EVENT_WRITE as long as there are
items queued waiting to be sent, this does not need to be done only when
the network queue is full.

When red_channel_client_set_blocked() is called, as a message is being
sent, WATCH_EVENT_WRITE will already be set, so it does not need to set
it again.
red_channel_client_msg_sent() removes WATCH_EVENT_WRITE, but this will
be done later anyway by red_channel_client_push() if needed.

Since it's redundant, we can remove this.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-28 16:59:25 +02:00
Christophe Fergeau
68a4eaedf1 Remove unneeded red_channel_client_is_blocked() call
red_channel_client_msg_sent() calls red_channel_client_clear_sent_item()
which will clear the rcc->priv->send_data.blocked flag. Later on, it
contains a check for !red_channel_client_is_blocked(), which will always
be true as nothing in between could have set it again. This commit
removes this unneeded check.

This check was already redundant when it was introduced in
9a62a9a809

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-28 16:59:25 +02:00
Christophe Fergeau
bf7bb4e886 Remove unneeded rcc->priv->latency_monitor.timer checks
Before this commit, red_channel_client_start_ping_timer() and
red_channel_client_cancel_ping_timer() had checks to be no-ops when
rcc->priv->latency_monitor.timer is NULL.

This commit adds a similar check to
red_channel_client_restart_ping_timer(), and removes explicit NULL
checks before calls to red_channel_client_{cancel,restart,start}_ping_timer()

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-28 16:59:25 +02:00
Frediano Ziglio
79c6ed0a9f Remove useless check
rcc is just used on the next line so cannot be NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-28 15:33:29 +01:00
Christophe Fergeau
f9e7454509 Use enum rather than int in MainChannelClientPrivate::net_test_stage
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-26 17:44:22 +02:00
Pavel Grunt
5d836f3b70 display-channel: Remove extra 'the' in comment
Fixes `make syntax-check`

https://gitlab.com/spice/spice/builds/14346626

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-21 10:35:13 +01:00
Frediano Ziglio
ffff35c689 sound: Use bool type coherently
Many function already used bool as boolean type.
Change last gboolean occurrencies and values.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-04-20 09:11:11 +01:00
Christophe Fergeau
258c2234ba playback: Don't lose client connection after migration
Commit 590acf3c55 introduced a regression after migration:
PlaybackChannel::connection is never set even if a client is connected,
which means the playback channel is non-functional until a client
reconnects as all the snd_channel_set_xxx() method checks for a non-NULL
PlaybackChannel::connection before sending data to the client.

This commit slightly changes the code flow in
on_new_playback_channel_client()/playback_channel_client_constructed()
so that PlaybackChannel::connection is set regardless of what
red_client_during_migrate_at_target() returns. This is what was done
prior to 590acf3c55.

This resolves https://bugs.freedesktop.org/show_bug.cgi?id=100136

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-19 09:53:16 +01:00
Jonathon Jongsma
f23834ccb4 DisplayChannel: document exclude_region() functions
This is a particularly opaque part of the code for managing pending
Drawable operations. This patch adds documentation atempting to explain
these functions.
2017-04-13 11:18:13 -05:00
Jonathon Jongsma
ac6e7a4ebd Add debug output identifying audio codec
It can be useful for debug to know what the codec of the playback and
record channels are, so add a debug-level print statement indicating
this.

Resolves: rhbz#1436251

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-11 10:24:42 -05:00
Christophe Fergeau
c765e9f283 main-channel-client: Remove unused statistics code
Main-channel-client.c has code to send pings when the statistics code is
enabled. This is done through a timer calling a ping_timer_cb callback.
However, this timer is created but never started, so this code is
actually dead-code.

Since this code does not seem to be doing much apart from sending the
pings (which can be achieved by simply setting monitor-latency to TRUE
in main_channel_client_create()), this commit removes it.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-11 10:21:30 +02:00
Christophe Fergeau
cf3657d2e4 Use red_channel_client_is_blocked
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-11 10:21:30 +02:00
Christophe Fergeau
24020ab931 Use bool in RedChannelClientLatencyMonitor
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-11 10:21:30 +02:00
Christophe Fergeau
6ccd8721a4 Use enum rather than int in RedChannelClient{Latency,Connectivity}Monitor
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-11 10:21:30 +02:00
Christophe Fergeau
54146811b2 Use bool in ConnectivityMonitor
Their uint32_t value is never used, all that matters is whether we
received data or not.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-11 10:21:30 +02:00
Christophe Fergeau
9770428c0d Remove one more unused "monitor_latency" arguments
This was missed in commit db9dcd9.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-11 10:21:30 +02:00
Jonathon Jongsma
72d5a6bd8f Test client caps separately
in main_channel_push_agent_connected(), it used the convenience function
red_channel_test_remote_cap() to determine whether to send the
AGENT_CONNECTED_TOKENS message, or the AGENT_CONNECTED message. However,
this function returns false if *any* one client doesn't support the
capability. We should instead check each individual client separately to
see if they support the capability.
2017-04-07 15:08:43 -05:00
Jonathon Jongsma
1b18fd76d1 Remove unused red_channel_test_remote_common_cap()
This was a convenience function around
red_channel_client_test_remote_common_cap() that simply iterated over
each client (currently we only really support a single client anyway)
and returned TRUE only if all clients supported the capability. But
nobody ever called this wrapper function.
2017-04-07 15:08:43 -05:00
Jonathon Jongsma
a5c15dfadf Remove extra space between "!" and variable name 2017-04-07 15:08:43 -05:00
Jonathon Jongsma
9d49c6bb03 snd_desired_audio_mode: change arguments to bool
client_can_celt and client_can_opus are true/false values, so use
'bool' type instead of 'int.
2017-04-07 15:08:43 -05:00
Jonathon Jongsma
9b0824bae4 red_channel_client_test_remote_cap() returns bool
Both _test_remote_cap() and _test_remote_common_cap() are used as
boolean values, so change the return type from int to bool to follow our
coding standard.
2017-04-07 15:08:43 -05:00
Jonathon Jongsma
332ad52143 Change playback_compression to bool type
This is a setting for determining whether to compress the audio playback
channel or not. It is variously typed as int or uint32_t. Convert it to
a 'bool' to make it more clear that it is a true/false value rather than
an enumeration or something like that.
2017-04-07 15:08:43 -05:00
Frediano Ziglio
dfe9fe9ebe test: Add vp9 support to GStreamer test
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-07 16:45:54 +01:00
Frediano Ziglio
e9035e5239 Attempt to create bitmap debug directory
The DUMP_BITMAP compile option enable some debugging code to
output image bitmaps in a subdirectory of /tmp.
However if this directory does not exists the server will crash
as not able to create a file in it.
Try to create directory before creating the file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-04-07 16:45:54 +01:00
Frediano Ziglio
4725ec03b1 gstreamer: Remove some leaks if pipeline cannot be created
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-04-07 16:45:49 +01:00
Christophe Fergeau
78c3dd4c18 Make various functions static
- glz_enc_dictionary_reset
- monitors_config_new
- red_channel_any_blocked
- red_channel_no_item_being_sent
- red_client_get_channel

are only used in the file where they are defined, so they can as well be
static.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-05 12:39:20 +02:00
Christophe Fergeau
27a9450d07 build-sys: Add configure check for TCP_KEEPIDLE
This is only available in newer FreeBSD releases (9.1 and later), and
will cause build errors or older versions

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=99213

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 12:22:52 +02:00
Christophe Fergeau
eb9f69ed9a reds-stream: Introduce reds_stream_get_no_delay() helper
This new function removes one place outside of RedsStream which needs to
access RedsStream::socket

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 12:22:52 +02:00
Christophe Fergeau
5ca3d6ca50 net: Introduce red_socket_set_keepalive() helper
This allows to move some low-level code out of reds.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 12:22:52 +02:00
Christophe Fergeau
b85ca4b8a9 net: Introduce red_socket_set_non_blocking() helper
This allows to move some low-level code out of reds.c

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 12:22:52 +02:00
Christophe Fergeau
ecf05ed6be reds-stream: Introduce reds_stream_set_no_delay() helper
The code to enable/disable on a TCP socket is duplicated in multiple
places in the code base, this commit replaces this duplicated code with
a helper in RedsStream.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 12:22:36 +02:00
Frediano Ziglio
5d046d9b2d red-channel: Initialize statistic node correctly
Doing a memset(0) on a SpiceStatNode does not create an empty/unattached
node, but instead creates a node '0'. This node could be non-existing,
or totally unrelated.
This patch creates a default '0' node as soon as the file is created.
This will make the behaviour of 0-filled nodes more in line with what
one would expect.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-31 11:02:02 +01:00
Christophe Fergeau
bc5326b1ce Unify header guards
This changes the header guards in all .h files to follow this format:

/*
 * Licensing block
 */

/* ... */

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-30 18:17:20 +01:00
Christophe Fergeau
6a6d0fa339 Remove unused red_channel_client_new()
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-30 18:17:17 +01:00
Christophe Fergeau
b8bc1fe715 Don't set RedChannelClient::monitor-latency to FALSE
This is the default value, and the property is marked as
_CONSTRUCT_ONLY, so we don't need to explicitly force the default when
instantiating a RedChannelClient.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-30 18:17:13 +01:00
Christophe Fergeau
db9dcd944a Remove unused "monitor_latency" arguments
InputsChannelClient::new and SmartcardChannelClient::new both accept a
"monitor_latency" argument, which is always FALSE. It can be removed.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-30 18:17:05 +01:00
Frediano Ziglio
3377feef5a Initialize earlier GLib type system if necessary
Before GLib 2.36 you should call g_type_init before attempting
any GLib type usage.
As constructor function are called before even main we need
to call g_type_init much before do_spice_init.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-30 18:05:30 +01:00
Frediano Ziglio
7d86223e21 Fix minor incompatibilities with RHEL6
Include missing pthread header.
Avoid undeclared functions in test-glib-compat.c including
proper/correct header.
Define missing g_assert_true and g_assert_false.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-30 10:50:09 +01:00
Christophe Fergeau
0457d00f75 build-sys: Alphabetically order source file list
The list of source files to build was in a random order, this commit
orders them alphabetically.
2017-03-27 10:37:31 +02:00
Frediano Ziglio
3c78882884 test-leaks: Document test program
This test needs some additional setup to do its job.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-24 11:58:16 +00:00
Frediano Ziglio
76b7f943e4 Some automatic check on video encoders
Stress a bit video encoders.
This check different combination of
- encoder type;
- image formats;
- image clipping (encoding partial frames);
- handling frames split into chunks.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-23 12:52:58 +00:00
Frediano Ziglio
186b8439ae reds-stream: Small syscall optimisation
Handle single chunk writev as normal write.
From some test more than 60% of the times writev is called with 1 as
counter. We can easily and very cheaply turn this call to a simpler
write avoiding the need to pass the array to the kernel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-23 12:04:35 +00:00
Christophe Fergeau
7b5e294a36 tests/pki: Use CA/certificate valid until 2048
As pointed out by danpb, tests/pki/server-cert.pem is only valid until
Fri Nov 29 15:51:44 UTC 2019

This changes tests/pki/server-cert.pem and tests/pki/ca-cert.pem to be
valid until 2048. These certificates were generated using the
instructions on https://www.spice-space.org/page/SSLConnection
The -subj args were omitted, and the defaults suggested by openssl used.
The -days parameter was changed to -days 10950.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-23 12:02:47 +01:00
Christophe Fergeau
759fdfc6d1 build-sys: Add tests/pki to EXTRA_DIST
This fixes make distcheck

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-23 12:02:47 +01:00
Frediano Ziglio
9bad8c306c Fix GStreamer encoding if stride is not 4 bytes aligned
This is required by GStreamer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-03-22 15:52:15 +00:00
Christophe Fergeau
68bc284b52 build-sys: Update to latest ax_valgrind_check.m4
This allows to remove a small hack in server/Makefile.am where we were
using make check-valgrind-memcheck rather than make check-valgrind to
make sure we get a non-0 exit code on failures.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-22 09:34:40 +00:00
Christophe Fergeau
844544f8be build-sys: Add make check-valgrind target
This allows to run automatically our test-suite with valgrind to test
for memory leaks.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-21 16:34:56 +01:00