Commit Graph

63 Commits

Author SHA1 Message Date
Frediano Ziglio
44352ca846 Remove dcc_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:27 +01:00
Frediano Ziglio
8dbd52f42a Simplify dcc_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:33 +01:00
Frediano Ziglio
ce9a770dd9 Simplify release_item_after_push
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:28 +01:00
Frediano Ziglio
767818da66 Handle STREAM_CREATE and STREAM_DESTROY pipe items more coherently
The items of these pipe items were allocated staticaly inside the
StreamAgent structure. All others RedPipeItem are allocated dynamically.
This could solve possible future maintenance as the life of these
item is more easier to understand.
It's more easier to understand why reference where incremented.
It also make the StreamAgent structure a bit smaller.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:06 +01:00
Frediano Ziglio
f94ef59de8 Simplify release of STREAM_CREATE and STREAM_DESTROY pipe items
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:03 +01:00
Frediano Ziglio
68c6d52e32 Simplify release of CREATE_SURFACE and DESTROY_SURFACE pipe items
Putting base as first item the default free function is fine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:24 +01:00
Frediano Ziglio
9ecff9e061 Call red_pipe_item_unref instead of free
This is the standard way to release a RedPipeItem

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:16 +01:00
Frediano Ziglio
d26648404a Simplify RED_PIPE_ITEM_TYPE_DRAW item release
Move ring_remove to the function to release this type of item.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:05 +01:00
Francois Gouget
0e10629d70 server: Enable adding alternative MJPEG video encoders
This replaces the original mjpeg_encoder API with a VideoEncoder base
class which can be reimplemented by other encoders.
This also renames the members and enums from mjpeg_* to video_*.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-04 10:51:55 +01:00
Francois Gouget
8a5ba34c01 server: Correctly handle and trace stream report errors
We may get stream reports after the stream has been closed, and even, in
extreme cases, after a new stream has started reusing the same stream
id. Neither case should cause the server to crash.
So restore dcc_handle_stream_report() to how it was before being moved
to dcc.c.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-05-04 10:49:13 +01:00
Jonathon Jongsma
920e117c24 Rename all RedPipeItem subclasses
Use 'Red' prefix to match internal type naming convention

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:26 -05:00
Jonathon Jongsma
b9720d80e0 Rename PipeItem to RedPipeItem
Following internal type naming conventions

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:01 -05:00
Jonathon Jongsma
18d3876b78 UpgradeItem: use base PipeItem for refcounting
No need to re-implement refcounting in this subclass.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:40:57 -05:00
Jonathon Jongsma
50a2c2fce2 Store display in Drawable struct
If the Drawable keeps a pointer to the Display channel that it is
associated with, we can unref it directly and not need to pass the
'display' parameter separately to the unref function

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:40:43 -05:00
Jonathon Jongsma
521dd24ffb dcc: Use refcounting for MonitorsConfigItem 2016-04-15 11:14:34 -05:00
Jonathon Jongsma
e09598ec75 StreamClipItem: use base class refcounting
PipeItem already implements refcounting. Use it.
2016-04-15 09:59:10 -05:00
Jonathon Jongsma
889a0b880f DrawablePipeItem: use base class for refcounting
Since PipeItem already implements refcounting, there's no need to
re-implement it here.
2016-04-15 09:59:08 -05:00
Jonathon Jongsma
3bd6b215d3 dcc: use PipeItem refcounting for ImageItem
Since the base class now implements refcounting, there's no need to
re-invent it here.
2016-04-15 09:53:19 -05:00
Christophe Fergeau
a653044011 Rename red_channel_pipe_item_init to pipe_item_init
The RedChannel argument is not used by pipe_item_init. Removing it
will make code simpler in places where we don't have a RedChannel
directly available.
This is acting on a PipeItem object so correct name is pipe_item_init.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-03-10 11:36:52 +00:00
Marc-André Lureau
acd53b97fb Fix dcc_start() regression
Commit e9ed125d introduced a dead-lock regression by taking twice the
same lock recursively. The previous code checked if a dmabuf was set
without taking the lock, for queuing scanout messages. Since the message
is being processed later on, it make sense to queue and delay until it
is sent to check if there is a scanout.

backtrace:
 #0  red_qxl_get_gl_scanout (qxl_state=0x5555582373c0) at red-qxl.c:828
 #1  0x00007fffec1ae654 in marshall_gl_scanout (rcc=0x7fffda6a7010,
 #m=0x7fff44025e60, item=0x7fff440958a0) at dcc-send.c:2310
 #2  0x00007fffec1aec7b in dcc_send_item (dcc=0x7fffda6a7010,
 #pipe_item=0x7fff440958a0) at dcc-send.c:2441
 #3  0x00007fffec1730f6 in send_item (rcc=0x7fffda6a7010,
 #item=0x7fff440958a0) at display-channel.c:1963
 #4  0x00007fffec1504c3 in
 #red_channel_client_send_item (rcc=0x7fffda6a7010, item=0x7fff440958a0)
 #at red-channel.c:578
 #5  0x00007fffec152d98 in red_channel_client_push (rcc=0x7fffda6a7010)
 #at red-channel.c:1365
 #6  0x00007fffec1a387e in dcc_push_monitors_config (dcc=0x7fffda6a7010)
 #at dcc.c:563
 #7  0x00007fffec1a3489 in dcc_start (dcc=0x7fffda6a7010) at dcc.c:475

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-08 15:24:56 +00:00
Frediano Ziglio
e9ed125dbd use QXLState instead of RedDispatcher
Considering that:
- QXLState is the state of QXLInstance implementation;
- RedDispatcher is the implementation of QXL;
- qif (QXLInterface*) field can be computed really easy from QXLInstance;
- most of its state is private.
Make all structure private and use QXLState instead of RedDispatcher.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-04 15:47:45 +00:00
Jonathon Jongsma
3644783e24 CommonChannel -> CommonGraphicsChannel
Rename this struct to make it clear that it's only the base class for
graphics channels (e.g. display and cursor), not all channels.

Also renamed CommonChannelClient to CommonGraphicsChannelClient.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-17 12:58:40 +00:00
Pavel Grunt
af3aa4b1f4 compress-stat: Add not compressed image to statistics
To see how many images and data could not be compressed.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-17 08:51:16 +00:00
Pavel Grunt
1948566ce8 dcc: Move COMPRESS_DEBUG to compression functions
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-17 08:51:13 +00:00
Pavel Grunt
f401eb07f9 dcc: Rewrite dcc_image_compress
Rules are now:

Compression type:
  off      -> uncompressed
  quic     -> jpeg if possible else quic else off
  lz       -> lz if possible else off
  glz      -> glz if possible else lz else off
  auto_lz  -> lz if possible else jpeg else quic else off
  auto_glz -> glz if possible else lz else jpeg else quic else off
  lz4      -> lz4 if possible else lz else off

jpeg is used only when jpeg-wan-compression allows it

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-17 08:50:43 +00:00
Frediano Ziglio
0ebd3b0d04 dcc: move id from CommonChannelClient to DisplayChannelClient
Was not used by CursorChannelClient but only by DisplayChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-02-16 13:07:08 +00:00
Frediano Ziglio
3108fb37e3 Revert "dcc: remove not necessary volatile specifications"
This reverts commit efe5a0c501.

Due to a problem in the compiler this causes compile to fail.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-15 16:09:49 +00:00
Christophe Fergeau
4049481882 Remove RedGlzDrawable::group_id
It's unused.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:13 +00:00
Christophe Fergeau
9500c32a30 Remove Drawable::group_id
We can now directly get it from RedDrawable.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:29:10 +00:00
Frediano Ziglio
efe5a0c501 dcc: remove not necessary volatile specifications
These automatic variable are used just inside the function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-12 06:17:32 +00:00
Frediano Ziglio
fbdea0fa79 CommonChannel: hold a reference to QXLInstance instead of RedWorker
CommonChannel does not need to know about RedWorker.
This reduce a bit dependencies between objects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:46 +00:00
Frediano Ziglio
d56745df19 dcc: remove group_id from compression functions
The parameter was not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:45 +00:00
Frediano Ziglio
448700bfb4 channel: rename misleading functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-02-11 23:51:42 +00:00
Marc-André Lureau
8777864311 Handle GL_DRAW_DONE
When a client is done with drawing and sends
SPICE_MSGC_DISPLAY_GL_DRAW_DONE, or when it ends, update the number of
async counts.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
[reduce critical message to a warning; do not reset gl_draw_ongoing
 - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 14:01:30 +00:00
Marc-André Lureau
381dc93ec0 Handle GL_DRAW messages
Create an async, and marshall the GL_DRAW message. Count number of
clients, and wait until gl_draw_async_count is 0 to complete the async.
The count is going to be updated in the following patch when the client
is done with the draw.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
[removed unused sent field; move gl_draw_async_count to DisplayChannel
 - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 14:01:25 +00:00
Marc-André Lureau
5881b40ebd Send current GL scanout to new client
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2016-02-09 14:01:20 +00:00
Marc-André Lureau
7a06efde1c Handle GL_SCANOUT messages
Go through dispatcher and marshall scanout message. Since the marshaller
and the QXL state are manipulated from different threads, add a mutex to
protect the current scanout.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2016-02-09 14:01:17 +00:00
Pavel Grunt
0bfad8a37f dcc: make dcc_compress_image_*() private
Reviewed-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 16:05:02 +00:00
Pavel Grunt
faa907e3c6 dcc_compress_image: Handle NULL drawable
It will be used in the following commit.
The GLZ compression cannot be used when the drawable is NULL.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-20 16:04:55 +00:00
Christophe Fergeau
400a5d13cf Remove compress_buf_new
This commit reworks a bit the management of RedCompressBuf so that
compress_buf_new/compress_buf_free become unneeded.
Since d25d6ca0 and the introduction of encoder_data_reset,
compress_buf_free is already unused outside of dcc-encoders.c and could
be static. This in turn makes compress_buf_new a bit odd as the matching
destructor is never used in dcc.c.
This commit introduces an encoder_data_init() method which is hiding
the initialization of the EncoderData structure from the dcc.c code,
allowing to get rid of compress_buf_new() calls from dcc.c code.

It also uses this as an opportunity to stop using GSlice for
RedCompressBuf.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-01-14 16:39:30 +00:00
Frediano Ziglio
1b6af4779a dcc: avoid to report errors triggered by client
Client can always send report even if a stream is not available.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-11 14:45:02 +00:00
Frediano Ziglio
d25d6ca0f2 dcc: write and use a new encoder_data_reset function to clean buffers
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 16:25:37 +00:00
Frediano Ziglio
bd8c74d7a4 dcc: free glz buffer after zlib compression
For zlib+glz compression image if first compressed with glz then the
resulting buffer is compressed again with zlib then the buffer from
zlib is returned to the caller.
However the temporary glz buffer was not freed resulting in a memory
leak.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-01-08 16:25:25 +00:00
Lukas Venhoda
6c4f11191c dcc: Don't disconnect channel, when compression is not supported
Don't disconnect the display channel, when unsupported compression is
requested from the client. Not changing the compression is enough.

https://bugs.freedesktop.org/show_bug.cgi?id=92821
Acked-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-17 12:29:52 +01:00
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
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
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
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
Marc-André Lureau
d9b17bbebb worker: move more stream functions
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-11-26 15:19:03 +00:00
Marc-André Lureau
721c03394b server: move LZ_IMAGE_TYPE_* enum to dcc
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2015-11-26 14:59:51 +00:00