Romain Vimont
2114f48185
Find device with USB context
...
An explicit context was used everywhere except for listing the devices.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
b779eca8d3
Remove libusb_device field
...
It is possible to retrieve the device instance from the handle via
libusb_get_device(), so we don't need to reference the device one more
time.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
adda47b0f7
Move sc_usb out of sc_aoa
...
This will allow to initialize a USB device separately and pass it to
sc_aoa.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
48e3ff284f
Make serial mandatory for sc_usb
...
In practice, it is already mandatory.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
1d6f9952ee
Extract USB handling from AOA
...
The AOA code handled both USB initialization and AOA commands/events.
Extract USB-related code to a separate file and structure.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
d48d191262
Rename HAVE_AOA_HID to HAVE_USB
...
The condition actually determines whether scrcpy can use libusb or not.
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
2762f5d183
Move AOA/HID code to usb/
...
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974 >
4 years ago
Romain Vimont
c996a6d462
Fix socket close race condition
...
The server needs to interrupt the sockets on stop, but it must not close
them while other threads may attempt to read from or write to them.
In particular, the video_socket is read by the stream thread, and the
control_socket is written by the controller and read by receiver.
Therefore, close the socket only on sc_server_destroy(), which is called
after all other threads are joined.
Reported by TSAN on close:
WARNING: ThreadSanitizer: data race (pid=3287612)
Write of size 8 at 0x7ba000000080 by thread T1:
#0 close ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1690 (libtsan.so.0+0x359d8)
#1 net_close ../app/src/util/net.c:280 (scrcpy+0x23643)
#2 run_server ../app/src/server.c:772 (scrcpy+0x20047)
#3 <null> <null> (libSDL2-2.0.so.0+0x905a0)
Previous read of size 8 at 0x7ba000000080 by thread T16:
#0 recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6603 (libtsan.so.0+0x4f4a6)
#1 net_recv_all ../app/src/util/net.c:228 (scrcpy+0x234a9)
#2 stream_recv_packet ../app/src/stream.c:33 (scrcpy+0x2045c)
#3 run_stream ../app/src/stream.c:228 (scrcpy+0x21169)
#4 <null> <null> (libSDL2-2.0.so.0+0x905a0)
Refs ddb9396743
4 years ago
Romain Vimont
8ea6fb1f0f
Print version on stdout
...
Refs b25404ee4b
4 years ago
Romain Vimont
b546c33eff
Do not print scrcpy version twice on --version
...
Refs 6da6d905c2
4 years ago
Romain Vimont
4817cadd09
Fix code style
...
Align function parameters.
4 years ago
Romain Vimont
02b5e87802
Slightly reduce lock usage
...
Locking the frame_buffer mutex to reference the input frame into the
tmp_frame is unnecessary.
This also fixes the missing unlock on error.
4 years ago
Romain Vimont
8e4d3beb01
Fix return value on adb commands error
4 years ago
Romain Vimont
9d2e00697e
Use sc_ prefix for control_msg enums
...
Refs afa4a1b728
4 years ago
Romain Vimont
f289d206ea
Disable more actions if --no-control
...
If control is disabled, then do not enable "show touches" or
automatically power off the device on close.
4 years ago
Romain Vimont
ca516f4318
Refactor if-block in cli
...
Several tests must be performed if opts->control is false.
4 years ago
Romain Vimont
5d6076bffd
Move misplaced break statements
...
With ifdefs, the resulting code could contain both a return statement
and a break.
4 years ago
Romain Vimont
e0bce1725b
Fix header guard prefix
4 years ago
Romain Vimont
063d103dd6
Capture mouse on start for --hid-mouse
...
If relative mode is enabled, capture the mouse immediately.
4 years ago
Romain Vimont
4bf9c057fe
Extract relative mode check to an inline function
...
This will allow to reuse the condition in another function.
4 years ago
Romain Vimont
17c97820b2
Never forward capture keys
...
In relative mode, Alt and Super are "capture keys". Never forward them
to the input manager, to avoid inconsistencies between UP and DOWN
events.
4 years ago
Romain Vimont
8c7f0ed5ea
Fix warning message
...
Make the message consistent for HID keyboard and HID mouse.
4 years ago
Romain Vimont
ac038f276e
Add missing break statement
...
This was harmless because this is the last "case" of the switch, but for
consistency, add the missing break.
4 years ago
Romain Vimont
1f65b1bf87
Remove inline hint
...
There is no reason to request inlining here.
4 years ago
Romain Vimont
d41a46dc95
Handle libusb_get_device_descriptor() error
...
The function libusb_get_device_descriptor() might return an error.
Handle it.
4 years ago
Romain Vimont
308a1f8192
Simplify error handling in sc_aoa_init()
...
Use goto to avoid many repetitions.
4 years ago
Romain Vimont
241a587e61
Fix missing HID mouse destructor call
...
The destructor unregisters the HID mouse, so it was not reported as a
leak, but it must still be called.
4 years ago
Romain Vimont
7e35bfe382
Refactor if-blocks
...
Group all conditions requiring a controller in a single if-block.
4 years ago
Romain Vimont
855819bbd8
Remove redundant control boolean
...
The controller is NULL if and only if control is disabled, so an
additional control boolean is redundant.
4 years ago
Romain Vimont
557daf280e
Pass NULL controller if control is disabled
...
If --no-control is requested, then the controller instance is not
initialized. However, its reference was still passed to screen and
input_manager.
Instead, pass NULL if no controller is available.
4 years ago
Romain Vimont
0b8e926330
Do not process finger events if no control
...
If --no-control is passed, then im->mp is NULL, so processing touches
would crash.
4 years ago
Romain Vimont
0ec3361bc9
Fix crash on --no-control
...
Relative mouse mode assumed that a mouse processor was always available,
but this is not the case if --no-control is passed.
4 years ago
Romain Vimont
81ff7ebd06
Simplify event loop
...
Merge single event handling with the event loop function.
4 years ago
Romain Vimont
1ffe312369
Handle file drop from input_manager
...
A file is pushed (or an apk is installed) to the device on file drop.
This behavior is specific to the screen and its input_manager.
4 years ago
Romain Vimont
ebef027c4f
Do not return status for event handling
...
It is never read. Simplify.
4 years ago
Romain Vimont
8e4e7d42f1
Fix leak on file pusher error
...
If a file_push request fails, the allocated filename must be freed.
4 years ago
Romain Vimont
b066dc0bbf
Rename file_handler to sc_file_pusher
...
Rename handler to pusher ("handler" is too generic), and add sc_ prefix.
4 years ago
Romain Vimont
3a0ba7d0a4
Disable downsizing on error if V4L2 is enabled
...
V4L2 device is created with the initial device size, it does not support
resizing.
PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947 >
4 years ago
Romain Vimont
75c5dc6859
Position and size the window on first frame
...
The optimal initial size was computed from the expected dimensions, sent
immediately by the server before encoding any video frame.
However, the actual frame size may be different, for example when the
device encoder does not support the requested size.
To always handle this case properly, position and size the window only
once the first frame size is known.
PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947 >
4 years ago
Romain Vimont
fa30f9806a
Move "show window" call on first frame
...
Show the window only after the actual frame size is known (and if no
error has occurred).
This will allow to properly position and size the window when the size
of the first frame is different from the size initially announced by the
server.
PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947 >
4 years ago
Romain Vimont
4fb61ac83d
Fix screen comments
...
The position fields accept SC_WINDOW_POSITION_UNDEFINED, not the size
fields.
PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947 >
4 years ago
Romain Vimont
15bf27afdd
Make auto-downsize on error optional
...
Add --no-downsize-on-error option to disable attempts to use a lower
definition on MediaCodec error.
PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947 >
4 years ago
Romain Vimont
b3ff1f6b3b
Upgrade FFmpeg (5.0) for Windows 64-bit
...
Use FFmpeg win64 binaries from gyan.dev (referenced from ffmpeg.org):
- https://www.gyan.dev/ffmpeg/builds/
- https://ffmpeg.org/download.html#build-windows
Keep the old FFmpeg prebuilt binaries (4.3.1) for win32 builds.
Fixes #1753 <https://github.com/Genymobile/scrcpy/issues/1753 >
Refs #1838 <https://github.com/Genymobile/scrcpy/pull/1838 >
Refs #2583 <https://github.com/Genymobile/scrcpy/pull/2583 >
PR #2952 <https://github.com/Genymobile/scrcpy/pull/2952 >
Co-authored-by: Yu-Chen Lin <npes87184@gmail.com>
Co-authored-by: nkh0472 <nkh0472@hotmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont
a2495c5ef1
Use symlink to simplify Windows ffmpeg dependency
...
The FFmpeg dependency is downloaded from two separate zipfiles.
Symlink include/ to expose everything from a single directory, to
simplify the meson script.
PR #2952 <https://github.com/Genymobile/scrcpy/pull/2952 >
4 years ago
Bernhard Rosenkränzer
5e8fa56e7a
Fix build with ffmpeg 5.0
...
PR #2948 <https://github.com/Genymobile/scrcpy/pull/2948 >
Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont
1c71bd16be
Use constant string for known booleans
...
Boolean options explicitly passed to the server are statically known.
4 years ago
Romain Vimont
afa4a1b728
Use sc_ prefix for control_msg
4 years ago
Romain Vimont
3a4d5c7f18
Use sc_ prefix for controller
4 years ago
Romain Vimont
5f7ddff8ae
Use sc_ prefix for input_manager
4 years ago
Romain Vimont
2a0c2e5e99
Use sc_ prefix for screen
4 years ago