Commit Graph

2396 Commits

Author SHA1 Message Date
Frediano Ziglio
333ef51ece Refactor cursor marshalling for SET, INIT
Use spice_marshaller_add_by_ref_full() instead of
spice_marshaller_add_by_ref() to allow the marshaller to manage the
lifetime of the referenced data buffer rather than having to manage it
by passing a PipeItem to red_channel_client_init_send_data(). Since the
data is owned by CursorItem (which is not in fact a RedPipeItem, but is
owned by a pipe item and is itself refcounted), we take a reference on
the CursorItem when adding the data buf to the marshaller, and then
unreference it in the marshaller free func.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-20 16:10:56 +00:00
Jonathon Jongsma
5c0f2e341c Avoid passing pipe item to red_channel_client_init_send_data()
The only time that the pipe item needs to be passed as the third
argument to red_channel_client_init_send_data() is when the pipe item
holds a data buffer that has been added to the marshaller by reference
(spice_marshaller_add_by_ref()) and needs to be kept alive until the
data has been sent. In all other cases, the item does not need to be
kept alive, so we can safely pass NULL for this third parameter.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-20 10:14:02 +00:00
Jonathon Jongsma
0239dfa908 Reset marshaller as soon as a message is sent
Any data that is added to the marshaller by reference (using e.g.
spice_marshaller_add_by_ref_full()) is freed during
spice_marshaller_reset(). But the marshaller is not currently reset
until we begin to send the next message (in
red_channel_client_send_item()). This means that the sent message data
lives longer than expected and can violate some assumptions in other
parts of the code.

To make sure that the data is cleaned up right after being sent, I've
added a reset call to clear_sent_item() and called that function from
_on_out_msg_done().  This means that _restore_main_sender() no longer
needs to reset the marshaller, and we no longer need to call
_reset_sent_item() within _on_out_msg_done() (since this function is
called from _clear_sent_item()).

This prepares the way for refactoring
red_channel_client_init_send_data() to change how we keep the
RedPipeItem alive while sending a message.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-20 10:13:55 +00:00
Jonathon Jongsma
f184aed83e CursorChannel: minor improvement to cursor_fill()
Move all 'out' parameters to the end of the function.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-16 09:46:46 +00:00
Frediano Ziglio
91668cdaab Sort include order in source files
Sort based on coding style.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-16 08:16:21 +00:00
Frediano Ziglio
48e732e08b red-worker: Optimise check
Use compile time check instead of runtime one.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-16 08:13:18 +00:00
Victor Toso
aebc51f91a reds: don't replace video_codecs on failure
We should replace the video_codecs GArray only after the parsing of
input is done, otherwise we might lose previous configuration.

Tests were updated to match this situation. Input that fails to
replace video_codecs are considered bad.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-15 11:13:36 +00:00
Jonathon Jongsma
481e1528ae Rename cursor_set_item() to cursor_channel_set_item()
Follow C method naming convention.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-14 20:16:02 +00:00
Frediano Ziglio
67df9f760f gitignore: Reuse top-level gitignore
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-14 19:09:21 +00:00
Frediano Ziglio
54ee6bbb8b gitignore: Limit scope of some files
This make more obvious which directory they refer
and potentially avoid ignoring unwanted files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-14 19:09:21 +00:00
Frediano Ziglio
893f3fef87 gitignore: Remove obsolete files
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-14 19:09:21 +00:00
Frediano Ziglio
554b20bbdb gstreamer: Prevent integer overflow in delay computation
The partial expression "MSEC_PER_SEC * size * 8" can overflow if
size is 536870 or more. This as the operation is done using
32 bit unsigned integers. Being the size potentially double of
a compressed frame size the limit can be easily reached.
As get_average_frame_size already return a 64 bit use 64 bit
even for the size to avoid the integer overflow.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francois Gouget <fgouget@codeweavers.com>
2016-12-12 19:37:34 +00:00
Frediano Ziglio
6940f7ff53 Removed unused red_channel_pipes_new_add_tail function
This function is supposed to add an item to the queue to
be sent before all other queued items.
Was never used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-12 13:37:00 +00:00
Frediano Ziglio
dc9177689e Remove unused refs field
refs was used before GObject for reference counting.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-12 13:36:54 +00:00
Frediano Ziglio
ed500d1a4c red-worker: Introduce RedWorkerMessageGlDraw structure
All RedWorker messages starts with RedWorker except
SpiceMsgDisplayGlDraw.
For coherence introduce a RedWorkerMessageGlDraw structure
holding just SpiceMsgDisplayGlDraw. This also allows possible
extensions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-12 11:45:07 +00:00
Victor Toso
8faf7a6f45 Fix gitignore
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-08 15:18:25 +01:00
Frediano Ziglio
3613ead4d8 marshaller: rename _add_ref() to _add_by_ref()
The spice_marshaller_add_ref() family of functions is confusing since it
sounds like you're incrementing a reference on the marshaller. What it
is actually doing is adding a data buffer to the marshaller by reference
rather than by value. Changing the function names to _add_by_ref() makes
this clearer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-08 14:05:04 +00:00
Uri Lublin
51d0ed6abb dispatcher: write_safe: move EINTR debug message
spice_debug was called for not-EINTR case, move
it to the right place.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-06 16:45:11 +00:00
Uri Lublin
c3d5689f4a red-record-qxl: child_output_setup: remove fcntl call
man 2 dup2 specifies:
  The close-on-exec flag (FD_CLOEXEC; see  fcntl(2))  for
  the duplicate descriptor is off.

Since the purpose of the fcntl call is to turn off FD_CLOEXEC
flag, and it's already done, just remove this call.

Suggested-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-06 16:45:08 +00:00
Uri Lublin
4be1a6ec8c red-record-qxl: add curly braces to empty while loop
Spice coding style suggests to use curly braces
for while blocks.

Some prefer the block to not be empty so continue
is untouched.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-06 16:45:07 +00:00
Uri Lublin
547f9f4387 red_get_image_data_flat: allocate mem after sanity check
This patch prevents possible memory leak.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-06 16:45:03 +00:00
Uri Lublin
dad108edb1 image_encoders: check shared_dict before accessing it
In both image_encoders_restore_glz_dictionary() and
image_encoders_get_glz_dictionary() shared-dict may
be NULL if size is too large, and the server gets
size from the network.

Both functions end up calling glz_enc_dictionary_create()
that calls glz_dictionary_window_create() where size is
checked.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-06 16:45:00 +00:00
Uri Lublin
a286da42d2 display-channel: current_remove: rename inner variable 'container'
It shadows the outer one.

Renamed also the outer 'container' variable.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-06 16:44:53 +00:00
Frediano Ziglio
030ae7bbdc tests: Apply same warning level as main server code
Allow to catch minor issue with test code.
Although test usually are coded with less care than production
code the current changes required are not so extensive and
can catch different issues.
Most of the patch is making functions static to avoid warnings for
undeclared functions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-06 16:16:19 +00:00
Frediano Ziglio
97f631471b build: Remove not existing include directory
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-06 13:07:27 +00:00
Victor Toso
f007c0a991 display-channel: Make video-codecs property read-write
This patch creates display_channel_get_video_codecs() helper to let
stream.c get the video-codecs without accessing the internal structure
of DisplayChannel.

As video-codecs is a property of DisplayChannel, this change means
making this property readable as well.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-06 13:47:00 +01:00
Frediano Ziglio
6c33b69e15 Support QXL remove on spice_server_remove_interface
Allow to dynamically remove QXL interfaces. This could be used to
support hot swapping of QXL cards.
This code is actually not used in any way.
QXL interfaces are destroyed by spice_server_destroy automatically.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
b9e8105d16 Free properly primary surface during replay
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
4f301ea0e4 Free replay queues
There could be still some data pending.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
0c8b059fac replay: Free spice server to detect leaks
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
74fa5e3fe4 Free main_dispatcher in spice_server_destroy
Avoid leaking it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
492e59842a Free QXL instances in spice_server_destroy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
8dbfd4971a Free inputs_channel in spice_server_destroy
Avoid leaking this channel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:35 +00:00
Frediano Ziglio
e4a17a4875 Call parent finalize at the and of display_channel_finalize
Make finalization of DisplayChannel consistent with other code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 23:27:34 +00:00
Pavel Grunt
b53c0d368b test: Ignore too new warnings
There is an explicit check for the version

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-05 12:32:28 +00:00
Frediano Ziglio
f870f0f030 sound: Load marshaller into a variable
Reduce GObject changes coming in the next commit since we'll need to
change how we access the marshaller anyway. This will make the
following commits easier to review.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-05 12:02:59 +00:00
Frediano Ziglio
b8f06e2437 smartcard: Optimise sending data
As data is packae in a single piece of memory send it
altogether.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-05 11:54:12 +00:00
Victor Toso
82165c10eb display-channel: reuse function to set video codecs
Including g_clear_pointer() in glib-compat.h and using it to avoid
warnings in odd situations.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-05 11:47:37 +00:00
Frediano Ziglio
c6e8163093 dcc: Avoid to include RedChannelClient private header
Make sure we don't tamper with RedChannelClient internals.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 22:15:02 +00:00
Frediano Ziglio
f191fb4717 sound: Reuse client variable if available
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
815da98f45 sound: Introduce a macro to cast to SndChannelClient
This make easier the transition to GObject.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
852202a049 sound: Change AudioFrame allocation
When qemu (for example) delivers audio samples to the spice server, it
does so by requesting a buffer from the spice server
(spice_server_playback_get_buffer()), filling them with audio data, and
then calling spice_server_playback_put_samples() to send them to the
client. Between the call to _get_buffer() and the call to
_put_samples(), we need to ensure that the buffer remains valid. Since
this buffer is allocated within PlaybackChannelClient, we did this by
incrementing a ref on the PlaybackChannelClient in _get_buffer(), and
decrementing the ref in _put_samples(). This has the effect of
potentially keeping the PlaybackChannelClient alive after the spice
client has disconnected.

This was not a problem when PlaybackChannelClient was a simple helper
class. But we intend to change PlaybackChannelClient so that it
inherits from RedChannelClient. In that case, the reference taken in
_get_buffer() would result in the RedChannelClient (and associated
RedChannel, etc) being kept alive longer than expected. To avoid this,
we add an additional ref-counted adapter class (AudioFrameContainer)
that owns the allocated audio frames and can outlive the
RedChannelClient if necessary. When the client is freed, the
AudioFrameContainer is just unreferenced.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
f301d3efc1 sound: Reuse record_client variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:54:49 +00:00
Frediano Ziglio
00a701e787 sound: Convert SndChannel to GObject
Stops using the dummy channel.
Data handling still goes through DummyChannelClient which is why
empty implementation of some required vfuncs is working.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 21:03:48 +00:00
Frediano Ziglio
98f6767483 Rearrange object destruction
Try to arrange destruction in the opposite order of the creation

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 17:38:55 +00:00
Frediano Ziglio
87f562d843 Add red_qxl_destroy function
Allows to destroy a QXL object

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-02 15:53:39 +00:00
Frediano Ziglio
41d52961db gstreamer: Correctly don't allow too limited bit rates
The check to limit too low bit rates was setting encoder->bit_rate
instead of bit_rate. However after some lines bit_rate was used
to set encoder->bit_rate basically removing the lower threshold.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Francois Gouget <fgouget@codeweavers.com>
2016-12-02 08:39:51 +00:00
Francois Gouget
f861d2922d streaming: Stop streaming if the client reports a streaming error
By removing the stream's video encoder we force the stream to send
future frames using the fallback code, that is as regular screen
updates.
However note that we keep the stream object: we have to. Otherwise
future frames would trigger the creation of a new stream object with a
new video encoder which would again try to stream the video and fail
again and again.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Victor Toso <victortoso@redhat.com>
2016-12-02 09:02:47 +01:00
Frediano Ziglio
a605a8d4a1 sound: Rename SndWorker to SndChannel
SndWorker has been historically based on RedChannel, initial git commit
has:
struct SndWorker {
     Channel base;
     ...
};

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-01 16:59:08 +00:00
Frediano Ziglio
4867b9e76a sound: Rename {Record,Playback}Channel to *ChannelClient
Make easier to understand that they refer to client and not
all channel.

Specifically:
- RecordChannel -> RecordChannelClient
- PlaybackChannel -> PlaybackChannelClient
- playback_channel -> playback_client
- record_channel -> record_client

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-01 16:26:22 +00:00