summaryrefslogtreecommitdiff
path: root/usbredirhost
AgeCommit message (Collapse)AuthorFilesLines
2021-11-04Prepare for 0.12.0 releaseusbredir-0.12.0Victor Toso1-1/+1
Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-11-04usbredirhost: drop isoc packagesVictor Toso1-3/+10
This is similar to the application side callback introduced by a88e197 "usbredirhost: new callback to drop isoc packets", only that packages are now dropped when usbredirparser owns and queues the outgoing data. Resolves: https://gitlab.freedesktop.org/spice/usbredir/-/issues/19 Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-10-28usbredirhost: restrain setting buffered_output_size_cbVictor Toso1-0/+9
Application should not be able to set this callback if data queue is on the library's side. Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-08-12Use "#pragma once" as include guardMichael Hanselmann1-4/+1
While "#pragma once" is not part of the C or C++ standards, it is a construct supported "by the vast majority of modern compilers"[1]. The previously used include guards starting with two underscores were also in violation of the relevant standards: identifiers starting with a double underscore ("__") are reserved for the implementation[2]. [1] https://en.cppreference.com/w/cpp/preprocessor/impl#.23pragma_once [2] https://eel.is/c++draft/lex.name#3.1 Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-06-04Use visibility to limit symbols exportedFrediano Ziglio2-3/+16
This mainly address MacOS issues using visibility. The .map files we use serve both at limiting symbols and provide symbol versioning. However to limit symbols using MacOS linker some different files need to be prepared and arguments to linker must be different. Using visibility is more supported by both Meson and multiple systems (Linux due to gcc or clang, MacOS due to clang, Windows). Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-29Fix typos in header commentsMichael Hanselmann1-1/+1
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-05-03build-sys: drop autotoolsVictor Toso2-29/+0
Meson build was added for 0.9.0 release where we deprecated autotools. Now that release is done, let's maintain only meson. Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-04-14Add local directory to include search path for mesonMichael Hanselmann1-2/+7
All includes of usbredir-related headers use the form `#include "usbredirparser.h"`, i.e. not relative to the root directory. As a consequence builds would fail to find files if they weren't installed in a global include directory: ``` ../usbredirhost/usbredirhost.h:25:10: fatal error: usbredirparser.h: No such file or directory ``` Adding "." to the include paths avoids this issue. Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-04-14Fix generated by meson libusbredirhost.pcTomasz Kłoczko1-1/+1
Fix incorrect usbredir parser library dependency in generated by meson libusbredirhost.pc file. Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
2021-04-02Prepare for 0.9.0 releaseusbredir-0.9.0Victor Toso1-1/+1
Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-03-29build-sys: Fix mingw build with __MINGW_PRINTF_FORMATFrediano Ziglio1-1/+3
Address the following error: > usbredirhost.c: In function 'usbredirhost_can_write_iso_package': > usbredirhost.c:1043:19: error: unknown conversion type character 'l' in format [-Werror=format=] > 1043 | DEBUG("START dropping isoc packets %" PRIu64 " buffer > %" PRIu64 " hi threshold", > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > usbredirhost.c:186:57: note: in definition of macro 'DEBUG' I've cherry-picked Frediano's patch in the #11 issue bellow. Fixes: https://gitlab.freedesktop.org/spice/usbredir/-/issues/11 Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-03-24meson: Add missing usbredir{host parser} pc filesVictor Toso1-1/+12
Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-03-24build-sys: Ship meson on a tarball from autotoolsVictor Toso1-0/+3
The opposite is already true. You can build with autotools on a tarball made with meson dist. Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-03-24build-sys: Add meson supportVictor Toso2-0/+61
As an alternative to autotools. Simple time comparison between configure+build time: 11.569s ./autogen.sh && make 1.642s meson . _build && ninja -C _build Note that from cflags defined in autotools, only -fstack-protector was removed for the windows build, otherwise we get few of the following: > /usbredir/winbuild/../usbredirparser/usbredirfilter.c:274: undefined reference to `__stack_chk_fail' Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-02-17docs: Format Multithreading doc in MarkdownVictor Toso1-2/+2
Renamed removing the README as it is already in the docs folder. Signed-off-by: Victor Toso <victortoso@redhat.com>
2021-02-16usbredirhost: clamp the boundaries of log levelVictor Toso1-1/+5
Prior to this, usbredir user could provide usbredirparser_debug_data as log level but that has no direct mapping to libusb log levels. libusb_set_option() would return LIBUSB_ERROR_INVALID_PARAM. That was unnoticed till previous commit. Signed-off-by: Victor Toso <victortoso@redhat.com> Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-02-16usbredirhost: handle return value from libusb_set_option()Victor Toso1-1/+6
Otherwise, we don't get the logs in case of bad input or any other underlying issue. Signed-off-by: Victor Toso <victortoso@redhat.com> Acked-by: Frediano Ziglio <freddy77@gmail.com>
2020-09-18usbredirhost: close device on errorVictor Toso1-0/+1
In case calloc() in usbredirparser_create() fails, we should be closing libusb_device_handle* as we own it (similar is done after earlier in same function after calloc for usbredirhost*). Note that usbredirhost_close() will not work as host->handle is not set yet. Signed-off-by: Victor Toso <victortoso@redhat.com>
2018-08-03Fix libusb-1.0.22 deprecated libusb_set_debugHan Han1-0/+4
Since libusb-1.0.22, libusb_set_debug is deprecated and replaced with libusb_set_option. Details: https://github.com/libusb/libusb/commit/539f22e2fd916558d11ab9a66f10f461c5593168 Compiling error: usbredirhost.c: In function ‘usbredirhost_open_full’: usbredirhost.c:753:5: error: ‘libusb_set_debug’ is deprecated: Use libusb_set_option instead [-Werror=deprecated-declarations] libusb_set_debug(host->ctx, host->verbose); ^~~~~~~~~~~~~~~~ Signed-off-by: Han Han <hhan@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-10Don't print warning when resetting a missing deviceJonathon Jongsma1-1/+5
When usbredirhost clears the current device, it resets the device and attempts to re-attach the kernel driver for the device. The current device is cleared when the API user explicitly sets a new device with usbredirhost_set_device(). However, some API users call usbredirhost_set_device(..., NULL) to clear the current device when the redirected device has been unplugged. In this scenario, resetting the device will fail and print a warning to the terminal. Since this is an expected scenario, we should simply handle it rather than printing an warning. Resolves: rhbz#1442963 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-06usbredirhost: avoid access to null pointerVictor Toso1-1/+1
ERROR() is a wrapper for va_log() which takes usbredirhost* as first argument. We can't use it if host == NULL. Changing to fprintf to not fail the function silently. This was catched by coverity: 3. usbredir-0.7.1/usbredirhost/usbredirhost.c:1412: var_deref_model: Passing null pointer "host" to "va_log", which dereferences it. 4. usbredir-0.7.1/usbredirhost/usbredirhost.c:163:5: deref_parm: Directly dereferencing parameter "host". # 161| int n; # 162| # 163|-> if (level > host->verbose) { # 164| return; # 165| } Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-08-04usbredirhost: fix leak on errorVictor Toso1-0/+1
Pointed by coverity: 17. usbredir-0.7.1/usbredirhost/usbredirhost.c:2306: leaked_storage: Returning without freeing "data" leaks the storage that it points to. # 2304| # usbredirhost_bulk_packet_complete(transfer->transfer); # 2305| } # 2306|-> } # 2307| # 2308| static void usbredirhost_iso_packet(void *priv, uint64_t # id, Acked-by: Pavel Grunt <pgrunt@redhat.com>
2015-12-18Remove trailing whitespaceLukas Venhoda1-2/+2
2015-11-03usbredirhost: Fix -Wformat warningFabiano Fidêncio1-3/+3
Use "PRIu64" macro for printf-ing uint64_t variables, avoiding warnings like: usbredirhost.c: In function 'usbredirhost_can_write_iso_package': usbredirhost.c:1023:19: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] DEBUG("START dropping isoc packets %lu buffer > %lu hi threshold", ^ usbredirhost.c:181:57: note: in definition of macro 'DEBUG' #define DEBUG(...) va_log(host, usbredirparser_debug, __VA_ARGS__) ^ usbredirhost.c:1023:19: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] DEBUG("START dropping isoc packets %lu buffer > %lu hi threshold", ^ usbredirhost.c:181:57: note: in definition of macro 'DEBUG' #define DEBUG(...) va_log(host, usbredirparser_debug, __VA_ARGS__) ^ usbredirhost.c:1028:19: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] DEBUG("STOP dropping isoc packets %lu buffer < %lu low threshold", ^ usbredirhost.c:181:57: note: in definition of macro 'DEBUG' #define DEBUG(...) va_log(host, usbredirparser_debug, __VA_ARGS__) ^ usbredirhost.c:1028:19: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] DEBUG("STOP dropping isoc packets %lu buffer < %lu low threshold", ^ usbredirhost.c:181:57: note: in definition of macro 'DEBUG' #define DEBUG(...) va_log(host, usbredirparser_debug, __VA_ARGS__) ^ usbredirhost.c: In function 'usbredirhost_set_iso_threshold': usbredirhost.c:1162:11: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] DEBUG("higher threshold is %lu bytes | lower threshold is %lu bytes", ^ usbredirhost.c:181:57: note: in definition of macro 'DEBUG' #define DEBUG(...) va_log(host, usbredirparser_debug, __VA_ARGS__) ^ usbredirhost.c:1162:11: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] DEBUG("higher threshold is %lu bytes | lower threshold is %lu bytes", ^ usbredirhost.c:181:57: note: in definition of macro 'DEBUG' #define DEBUG(...) va_log(host, usbredirparser_debug, __VA_ARGS__) Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-10-29usbredirhost: new callback to drop isoc packetsVictor Toso2-2/+74
For streaming devices it might be necessary from application to drop data for different reasons. This patch provides a new callback that it is called before queueing the most recent isoc packet. usbredirhost uses the device information to set two levels of threshold. In case application's buffer size is higher then the higher threshold we will drop enough isoc packets to be able to provide a complete video frame again. The calculation aims at 10fps as worst case. The higher threshold is set to 180ms and the lower threshold to 30ms which would give us at least 150ms of continuous data. Related: https://bugzilla.redhat.com/show_bug.cgi?id=1264156 Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-12-04build-sys: add git.mk to generate .gitignoreMarc-André Lureau1-0/+2
2014-10-02usbredirhost: Add 2798:0001 to the do-not-reset blacklistHans de Goede1-0/+1
https://bugzilla.redhat.com/show_bug.cgi?id=1115917 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: reset device on releaseHans de Goede1-0/+10
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: lock host earlier in async packet completion callbacksHans de Goede1-5/+6
The transfer->foo_packet union members are also used on cancellation, and completion and cancellation may race, so they should not be accessed without holding the lock. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: Improve debug loggingHans de Goede1-9/+22
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: Fix a cancellation corner caseHans de Goede1-1/+3
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: Add missing flush on cancelHans de Goede1-0/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: Ensure all in flight urbs are cancelled before a resetHans de Goede1-0/+11
The guest should have cancelled any pending urbs already, but the cancellations have not necessary completed when we receive a reset. If we then continue with the reset pending urbs may complete with an error code of LIBUSB_TRANSFER_NO_DEVICE, causing us to see a device disconnect. We also need to cleanly shutdown any streams and let the guest know they should be restarted after the reset. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost_cancel_pending_urbs: Add a notify_guest parameterHans de Goede1-4/+11
If this is 1 then the guest will be send stream_status packets with a status of usb_redir_stall for any stopped streams. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: Add usbredirhost_wait_for_cancel_completion helperHans de Goede1-12/+19
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-11-19usbredirhost: Implement support for bulk streamsHans de Goede1-5/+85
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-10-19usbredirhost: Fill in max_streams in ep_infoHans de Goede1-0/+24
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-07-12usbredirhost: Use libusb_set_auto_detach_kernel_driver when availableHans de Goede1-0/+15
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-13usbredirhost: Fix coverity sign_extension warningHans de Goede1-1/+2
Coverity does not like uint8_t * int being casted to an uint64_t, change the int to an unsigned int to make it happy. Note that the int in question can never be > 255, so this is not a real issue. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-01-25Properly declare C symbolsMarc-André Lureau1-0/+8
2012-12-05usbredirhost: Add a do-not-reset device blacklistHans de Goede1-11/+47
And populate it with 1210:001c Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Only apply mult to max-packet-size for isoc high speed endpointsHans de Goede1-16/+17
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Add support for buffered bulk inputHans de Goede1-10/+67
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Add usbredirhost_stop_stream() helper functionHans de Goede1-28/+14
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Add usbredirhost_send_stream_data() helper functionHans de Goede1-34/+49
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Push sending of stream error status lower down the stackHans de Goede1-59/+43
Send the error status in the places where the error actually happens, rather then passing an error return code all the way up, and then check + send the error status at the higher level. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Add usbredirhost_send_stream_status() helper functionHans de Goede1-32/+36
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Add usbredirhost_clear_stream_stall_unlocked() helper funcHans de Goede1-29/+22
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost_interrupt_packet_complete: Split into in / out versionsHans de Goede1-26/+37
And name the input version usbredirhost_buffered_packet_complete in preparation for also using it for handling of buffered bulk-in endpoints. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-12-05usbredirhost: Use multiple transfers for interrupt receivingHans de Goede1-136/+33
To ensure we don't loose any date when we suffer some latency in completion processing. Signed-off-by: Hans de Goede <hdegoede@redhat.com>