Commit Graph

2314 Commits

Author SHA1 Message Date
Francois Gouget
cbc4e07682 server: Rename DISPLAY_CLIENT_TIMEOUT and de-duplicate it
Given that it is used for both cursor and display, COMMON_CLIENT_TIMEOUT
seems more appropriate. Also define it only in red-worker.h.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-14 10:53:40 +00:00
Pavel Grunt
67f619d551 worker: Rename function name in the comment as well
It was renamed in 47b023866f

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-11 16:04:16 +00:00
Frediano Ziglio
9c56c884ad dcc: do not cause problem with multiple threads.
With multiple cards configured you can have multiple workers running in
different thread.
With such configuration static variables not syncronized could lead
to undefined behavior.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-11 14:57:05 +00:00
Frediano Ziglio
765b5209ef reds: do not use g_malloc0 in server code
The rest of code is using spice_malloc* functions, use them for
consistency.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-11 14:55:32 +00:00
Francois Gouget
c9282b3bc7 server: Use spice_get_monotonic_time_ms() in spice_timer_queue.c
This reduces code duplication.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-11 12:43:26 +00:00
Francois Gouget
f7613250c5 server: Add spice_get_monotonic_time_ms()
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-11 12:43:26 +00:00
Francois Gouget
65b60250d0 server: Rename red_get_monotonic_time() to spice_get_monotonic_time_ns()
This is a generic function not tied to the red_xxx functionality and the
new name clarifies that it returns the time in nanoseconds (unlike
g_get_monotonic_time()).

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-11 12:43:26 +00:00
Francois Gouget
0ad7f71e24 server: Provide a framerate estimate based on the initial frames
This way the video encoder can actually count on a real estimate when
it is initializing.
Note that the server only creates a video stream if at least 20 bitmap
'blits' of the same size and type arrive, each within a maximum time
interval from the previous one. So it was only keeping track of the
frame to frame interval. Thus to get an average frame rate over all the
20 frames it's necessary to also keep track of the first_frame_time.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-12-11 12:43:44 +01:00
Marc-André Lureau
e9bf0a69af snd: remove duplicated snd_attach_*() code
red_channel_set_data() already sets channel->data.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-11 11:26:09 +00:00
Marc-André Lureau
5d8350f7d7 build-sys: disable static lib by default
It's not used in general, so no need to build it by default.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-11 11:22:00 +00:00
Marc-Andre Lureau
17029eff1d red-dispatcher: group cases
A small cleanup.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-10 19:12:10 +00:00
Marc-André Lureau
00357bb2f3 snd: simplify reds_register_channel() call
Give channel argument directly

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-10 19:12:10 +00:00
Frediano Ziglio
e7c79b71a4 channel: make sure we retain RedChannelClient while processing it
During display_channel_handle_migrate_data the pointer is passed
to different functions which could release it making the pointer
invalid. Make sure pointer is not freed while processing.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-10 17:36:25 +00:00
Frediano Ziglio
b12187b332 channel: rename red_channel_(client_)waits_* functions
Make clear that these funcion are just checking a condition.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-10 17:22:59 +00:00
Francois Gouget
c8010f0201 server: Remove an unneeded time.h include directive
main-channel.c now uses g_get_monotonic_time() instead of
clock_gettime().

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-12-10 16:07:08 +01:00
Frediano Ziglio
febaed3529 server: misc header cleanups
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 22:17:51 +00:00
Frediano Ziglio
24da6bcd37 server: merge spice-bitmap-utils and spice_bitmap_utils
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 22:16:10 +00:00
Frediano Ziglio
c4c716ab18 stat: add test for statistic functions
Make sure code compile with and without statistics enabled (beside
printing functions).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 17:02:54 +00:00
Frediano Ziglio
253d2cef40 stat: use a better design for statistic functions
make sure code compile with statistics enabled or disabled.
Dummy (empty) structures and functions are used instead of preprocessor.
Also fix a problem as stat_compress_init did not initialize clock
field.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 17:02:48 +00:00
Frediano Ziglio
4173663ea1 stat: fix portability problem in stat_time_t declaration
Assure stat_time_t is 64 bit on all architectures.
long is not 64 bit on 32 bit systems so use uint64_t intead.
Also avoid 32 bit overflows for such architectures.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 17:02:41 +00:00
Marc-André Lureau
c0f4de5c86 display: replace some dubious asserts
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2015-12-09 11:42:00 +00:00
Francois Gouget
9956270358 server: Use g_get_monotonic_time() to get the time in microseconds
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-08 15:08:44 -06:00
Francois Gouget
c8d5120ff0 server: Define the MJPEG encoder warmup time in nanoseconds
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-08 15:08:44 -06:00
Francois Gouget
4ce4c4a525 server: Simplify the MJPEG encoder's maximum framerate estimation
Note that if frame_size == bytes_per_sec == 0 this now returns
MJPEG_MAX_FPS but this should not happen anyway.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-12-08 16:22:41 +01:00
Francois Gouget
9b42aafe31 server: Rename SUPPORT_AUTOMATED_TESTS to HAVE_AUTOMATED_TESTS
This improves consistency with spice-deps.m4 which names its
AM_CONDITIONAL() variables HAVE_XXX.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-12-08 15:39:11 +01:00
Alon Levy
6e6126e024 server: multiple clients works ok if we limit the pipe to the slowest client
Signed-off-by: Alon Levy <alon@pobox.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-04 15:43:56 +00:00
Frediano Ziglio
ed1ef89ca8 pass proper type to SPICE_CONTAINEROF
In some case the member specified to SPICE_CONTAINEROF was not
exactly the same type of the pointer passed.
This can cause issues if structure changes so use proper member.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-04 13:33:54 +00:00
Frediano Ziglio
89fda203bc worker: improve validation for update command
If surface_id is not valid we should still release resource allocated
by red_get_update_cmd and from the guest.
This to reduce leaks in case of a race or another error in the guest
driver.
Also not issue a warning on invalid surface number to avoid filling
log space unconditionally.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2015-12-04 12:02:36 +00:00
Jonathon Jongsma
0410c6f165 remove glz_encoder_config.h
Move all code from glz_encoder_config.h into other files.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-04 11:57:18 +00:00
Alon Levy
aef334e6e8 tests: test_display_base: use a faster wakeup time to easily test multiple client blocking
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-04 11:46:27 +00:00
Frediano Ziglio
525cd67be7 server: rename files
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:54:32 +00:00
Frediano Ziglio
1ea55284d9 memslot: change some spice_assert to spice_return_if_fail
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:51:18 +00:00
Frediano Ziglio
1873c7d497 display: misc style and rename changes
- remove some red_ prefix;
- move red_drawable->self_bitmap check outside handle_self_bitmap;
- move update check outside red_get_area (renamed surface_read_bits);
- rename depend_on_surface_id argument to surface_id;
- rename success variable to add_to_pipe.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:51:18 +00:00
Frediano Ziglio
1940972ca9 worker: move red_process_draw to display-channel.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:51:18 +00:00
Frediano Ziglio
dfaf83235f display: make get_drawable symmetric to display_channel_drawable_unref
Make possible to safely call display_channel_drawable_unref straight
after calling get_drawable.

Problem was function definitions and dependency.

display_channel_drawable_try_new is supposed to return an uninitialized
pointer (or NULL on failure) to a Drawable structure.

(display_channel_)get_drawable is supposed to return an initialized
pointer (or NULL) to a Drawable structure.

(display_channel_)add_drawable is supposed to add the Drawable to the
list/tree of drawing to draw.

Now, with these definitions after get_drawable the Drawable state (if
pointer is not NULL) should be consistent and we should be able to call
display_channel_drawable_unref.

In the current code this was not true as for instance surface_id was
copied to Drawable but the reference counter of the surface was not
incremented leading possible unref call to decrement the counter and
free the surface. This can happen if any call between get_drawable and
unref does not increment the reference in a consistent way. This
basically means that every present or future code in the path between
get_drawable and unref have to know this unconsistency and handle it.
This is a maintaining problem as people need to know these details when
editing existing code (actually this is display_channel_add_drawable
code).
This basically create a dependency between get_drawable and
add_drawable.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:51:18 +00:00
Francois Gouget
43d6c5b9ee server: Reuse red_get_monotonic_time() in the MJPEG video encoder
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-03 15:35:06 +00:00
Frediano Ziglio
89707f3b4d stat: fix stat_info_t initialization
For compression statistics clock field was not initialized but used
computing statistics.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 10:56:03 +00:00
Marc-André Lureau
ef8c431d9b worker: rename process_commands process_display
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:48:42 +00:00
Frediano Ziglio
bf1e139875 dcc: reduce statement wrapping
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:41:46 +00:00
Frediano Ziglio
f31536802a worker: change red_worker_new_channel result to CommonChannel*
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:41:46 +00:00
Frediano Ziglio
7280460b78 memslot: prefix memslot functions with memslot_
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:41:46 +00:00
Frediano Ziglio
768dfa2139 worker: do not use dynamic memory for RedSurfaceCmd
Allocation on stack is sufficient and code is more similar to
QXL_CMD_MESSAGE and QXL_CMD_UPDATE cases.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:41:46 +00:00
Frediano Ziglio
c1ecbaf7b1 display: move more logic in display_channel_get_drawable()
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:41:46 +00:00
Frediano Ziglio
c26e6de0ee worker: move get_drawable to display-channel.c
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-03 10:41:46 +00:00
Marc-André Lureau
13a3560b88 smartcard: include libcacard.h if possible
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-12-02 17:48:49 +01:00
Yonit Halperin
1ea34e6d43 red_worker: make dcc_clear_surface_drawables_from_pipe declaration consistent with definition
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-02 12:52:10 +00:00
Marc-André Lureau
1c9aea02c6 worker: merge handle_new_display_channel
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-02 12:47:25 +00:00
Marc-André Lureau
5161132ec7 display: rename detach_streams_behind
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-02 12:44:46 +00:00
Marc-André Lureau
4980850dd2 display: add update_compression() method
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2015-12-02 12:34:47 +00:00
Marc-André Lureau
47b023866f worker: move red_process_surface
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-02 12:29:34 +00:00