Commit Graph

21 Commits

Author SHA1 Message Date
Frediano Ziglio
e0b395fb68 Declare exported functions as C
Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Kevin Pouget
48ab22b728 gstreamer-encoder: fix compiler warning with Fedora 30
Fedora 30 / gcc 9.1.1 20190503 (Red Hat 9.1.1-1) fails to build
because of this error/warning:

> gstreamer-encoder.c: In function 'set_video_bit_rate':
> gstreamer-encoder.c:518:17: error: taking the absolute value of
> unsigned type 'uint64_t' {aka 'long unsigned int'} has no effect
> [-Werror=absolute-value]
>  518 |     } else  if (abs(bit_rate - encoder->video_bit_rate) > encoder->video_bit_rate * SPICE_GST_VIDEO_BITRATE_MARGIN) {
>      |                 ^~~
> gstreamer-encoder.c:518:17: error: absolute value function 'abs'
> given an argument of type 'uint64_t' {aka 'long unsigned int'}

This patches solves these two warnings:

1) cast the substraction to a signed type (int64_t instead of
uint64_t) to preserve the operation meaning;

2) use a custom version of abs() to avoid data truncation and/or
platform-dependent type lengths (abs/labs/llabs)

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-07-03 14:24:25 +01:00
Francois Gouget
2bb96f105d utils: Make all the NSEC_PER_XXX constants 64 bit
Code dealing with nanosecond timestamps normally uses 64 bit integers
and not long long ints. So this makes it easier to print the value of
expressions using these constants.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-07-03 12:08:50 +01:00
Francois Gouget
d4251bac5f utils: Remove the LL suffix from NSEC_PER_MILLISEC
This constant fits in a regular 32 bit signed integer so it does not
need the suffix.
It is also not used in expressions that may overflow.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-06-12 10:16:12 +01:00
Christophe Fergeau
474158dfef ssl: Dump OpenSSL error stack on errors
Bugs such as https://bugzilla.redhat.com/show_bug.cgi?id=1651882 can be
quite tricky to figure out without the detailed OpenSSL error. This
commit adds a detailed dump of the OpenSSL error stack when an OpenSSL
failure happens.

In the bug above, this would have displayed:
(process:13154): Spice-WARNING **: 05:43:10.139: reds.c:2816:reds_init_ssl: Could not load certificates from /etc/pki/libvirt-spice/server-cert.pem

(process:13154): Spice-WARNING **: 05:43:10.140: error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-02-07 09:55:11 +00:00
Frediano Ziglio
3deedc3b6b utils: Get monotonic time in a coherent way
Use a single function to get monotonic time.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-09 15:34:10 +01:00
Christophe Fergeau
f84b26f801 utils: Remove spice_get_monotonic_time_ms
This is a thin wrapper over g_get_monotonic_time_ms, and is called only
once, so we can call directly g_get_monotonic_time_ms instead.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2018-10-08 17:15:55 +02:00
Frediano Ziglio
03125ef950 utils: Use const for rgb32_data_has_alpha data argument
There's no reason to change data passed, the function just check
the alpha channel of the image.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2018-01-29 21:11:38 +00:00
Christophe Fergeau
699a94ca8f utils: Introduce helpers to map channel types to names
spice_server_set_channel_security() is already mostly doing that. We can
make its code more generic, and introduce a red_channel_get_name()
method. This method will then be used to make debug messages more
readable by showing the actual channel name rather than its type as
an int.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-10-23 20:29:28 +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
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
Francois Gouget
8bddb1444e server: Add time constants to go with spice_get_monotonic_time_ms()
They clarify the time unit being used and simplify calculations.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-14 11:24:47 +00:00
Francois Gouget
5c9fb9a0f3 server: Add time constants to go with spice_get_monotonic_time_ns()
They clarify the time unit being used, reduce the need for casts and
simplify calculations.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-14 11:24:34 +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
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
Marc-André Lureau
d793473e5e server: cleanups
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-11-27 11:49:56 +00:00
Marc-André Lureau
029b4beb73 worker: move dcc_add_surface_area_image
Author:    Marc-André Lureau <marcandre.lureau@gmail.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-11-23 13:50:44 +00:00
Francois Gouget
bd2bbe2fdd server: Include stdint.h for int64_t
This fixes a compilation error with gcc 4.4 on RHEL 6.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-11-16 10:21:14 +00:00
Marc-André Lureau
39b7e55ec7 Replace now() with get_mononotonic_time()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-29 18:22:19 +00:00
Marc-André Lureau
93414b23fa utils: add red_get_monotonic_time() 2015-10-29 17:59:02 +00:00