Commit Graph

494 Commits (9e78b765da01843b4986f93179b0c92701269062)

Author SHA1 Message Date
Romain Vimont 54ccccd883 Replace SDL_Atomic by stdatomic from C11
There is no reason to use SDL atomics.
4 years ago
Romain Vimont 94e1696869 Do not warn on terminating the server
If the server is already dead, terminating it fails. This is expected.
4 years ago
Romain Vimont a346bb80f4 Do not block on accept() if server died
The server may die before connecting to the client. In that case, the
client was blocked indefinitely (until Ctrl+C) on accept().

To avoid the problem, close the server socket once the server process is
dead.
4 years ago
Romain Vimont d421741a83 Wait server from a separate thread
Create a thread just to wait for the server process exit.

This paves the way to simply wake up a blocking accept() in a portable
way.
4 years ago
Romain Vimont 64d5edce92 Refactor server_start() error handling
This avoids cleanup duplication.
4 years ago
e_vigurskiy 4150eedcdf Add display id parameter
Add --display command line parameter to specify a display id.

PR #1238 <https://github.com/Genymobile/scrcpy/pull/1238>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont e050cfdcd6 Fix static_assert() parameters
In C11, static_assert() expects a message.
4 years ago
Romain Vimont dc7c677728 Accept negative window position
It seems to work on some window managers.

Fixes #1242 <https://github.com/Genymobile/scrcpy/issues/1242>
4 years ago
Romain Vimont 902b99174d Fix server debugger for Android >= 9
Add a compilation flag to select the debugger method to use:
 - old: Android < 9
 - new: Android >= 9

See <https://github.com/Genymobile/scrcpy/issues/1187#issuecomment-599075661>
4 years ago
Jaafar Biyadi cd69eb4a4f Handle NumPad events when NumLock is disabled
PR #1188 <https://github.com/Genymobile/scrcpy/pull/1188>
Fixes #1048 <https://github.com/Genymobile/scrcpy/issues/1048>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
yangfl d3281f4b67 Show a friendly hint for adb installation
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
George Stamoulis 1982bc439b Add option to lock video orientation
PR #1151 <https://github.com/Genymobile/scrcpy/pull/1151>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont c0f428eb05 Merge branch 'master' into dev 4 years ago
Romain Vimont 4794ca8ae7 Use linear filtering
Anisotropic filtering makes no sense for scrcpy use case.

This (semantically) reverts 9e328ef98b.
4 years ago
Romain Vimont 0fb22c3e98 Happy new year 2020! 4 years ago
Romain Vimont dc7fcf3c7a Accept port range
Accept a range of ports to listen to, so that it does not fail if
another instance of scrcpy is currently starting.

The range can be passed via the command line:

    scrcpy -p 27183:27186
    scrcpy -p 27183  # implicitly 27183:27183, as before

The default is 27183:27199.

Closes #951 <https://github.com/Genymobile/scrcpy/issues/951>
4 years ago
Romain Vimont 2a3a9d4ea9 Add util function to parse a list of integers
This will help parsing arguments like '1234:5678' into a list of
integers.
4 years ago
Romain Vimont ca0031cbde Refactor server tunnel initialization
Start the server socket in enable_tunnel() directly.

For the caller point of view, enabling the tunnel opens a port (either
the server socket locally or the "adb forward" process).
4 years ago
Romain Vimont d1a9a76cc6 Reorder functions
Move functions so that they can be called from enable_tunnel() (in the
following commit).
4 years ago
Romain Vimont a8ceaf5284 Fix include order 4 years ago
Romain Vimont 83d48267a7 Accept --max-fps before Android 10
KEY_MAX_FPS_TO_ENCODER existed privately before Android 10:
<https://github.com/Genymobile/scrcpy/issues/488#issuecomment-567321437>
5 years ago
Romain Vimont db6252e52b Simplify net.c
The platform-specific code for net.c was implemented in sys/*/net.c.

But the differences are quite limited, so use ifdef-blocks in the single
net.c instead.
5 years ago
Yu-Chen Lin f9786e5034 Get env in windows correctly
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Yu-Chen Lin 78a320a763 Fix utf-8 char path in windows
The file 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server'
exists, however, it will show msg as follow:

    INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
    stat: No such file or directory
    ERROR: 'E:\安安\scrcpy-win64-v1.12.1-1-g31bd950\scrcpy-server' does
    not exist or is not a regular file
    Press any key to continue...

This patch fixes it.

Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont 7d5845196e Fix memory leak on portable builds
The function get_server_path() sometimes returned an owned string,
sometimes a non-owned string.

Always return an allocated (owned) string, and free it after usage.
5 years ago
Romain Vimont 6965d051ae Limit bitrate range to 31 bits integer
A proper solution could be to use "long long" instead (guaranteed to be
at least 64 bits), but it adds its own problems (e.g. "%lld" is not
supported as a printf format on all platforms).

In practice, we don't need such high values, so keep it simple.

Fixes #995 <https://github.com/Genymobile/scrcpy/issues/995>
5 years ago
Romain Vimont e4cebc8d4c Do not build tests in release mode
Assertions would not be executed.

And as a side effect, it causes "unused variable" warnings.
5 years ago
Romain Vimont ba1b36758e Define SDL_MAIN_HANDLED in all tests
Each test defines its own main() function. If this flag is not set, then
SDL redefines it to SDL_main(), causing compilation failures.
5 years ago
Romain Vimont ad92a192b5 Fix meson.build codestyle 5 years ago
Romain Vimont 242e57d69b Merge branch 'master' into dev 5 years ago
Romain Vimont 024c2f7e6b Configure log priority early
The log priority must be configured before parsing command-line
arguments, in order to get logs as expected.
5 years ago
Romain Vimont 1eae139b6e Add missing consts
String parsing functions should not be able to modify their input.
5 years ago
Romain Vimont 419c869c9c Use ARRAY_LEN() macro in tests 5 years ago
Romain Vimont 929bf48c7e Add tests for command-line parsing 5 years ago
Romain Vimont d950383b72 Move command-line parsing to a separate file 5 years ago
Romain Vimont 61274a7cdb Factorize integer argument parsing
Add util functions for integer parsing (with tests), and factorize
integer argument parsing to avoid code duplication.
5 years ago
Romain Vimont 64bcac9157 Refuse to push a non-regular file server
If SCRCPY_SERVER_PATH points to a directory, then a directory will be
pushed to /data/local/tmp/scrcpy-server.jar.

When executing it, app_process will just abort and leave the directory
on the device, causing scrcpy to always fail.

To avoid the problem, check that the server is a regular file before
pushing it.

Closes #956 <https://github.com/Genymobile/scrcpy/issues/956>
5 years ago
Romain Vimont 3259c60b22 Fix test compilation on mingw
Including SDL2/SDL.h redefines main to SDL_main by default.
5 years ago
Romain Vimont eb0f339271 Add shortcut to rotate screen
On Ctrl+r, disable auto-rotation (if enabled), set the screen rotation
and re-enable auto-rotation (if it was enabled).

Closes #11 <https://github.com/Genymobile/scrcpy/issues/11>
5 years ago
Yu-Chen Lin fbc86a616c Correct coding style
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
5 years ago
Yu-Chen Lin b2bf25c52c Add test_buffer_util
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
5 years ago
Yu-Chen Lin 5eeaed09ae Add test_strquote
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
5 years ago
Romain Vimont 3100533e56 Fix "natural scrolling"
> Movements down (scroll backward) generate negative y values and up
> (scroll forward) generate positive y values.

> If direction is SDL_MOUSEWHEEL_FLIPPED the values in x and y will be
> opposite. Multiply by -1 to change them back.

<https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks>

The x and y values already take the scrolling configuration into
account. Reversing the values when the direction is flipped cancels the
scrolling configuration.

Therefore, just ignore the direction field.

Fixes <https://github.com/Genymobile/scrcpy/issues/966>
5 years ago
Romain Vimont 86fcd89d80 Fix max size default value
Suggested-by: jurkov

Closes <https://github.com/Genymobile/scrcpy/issues/978>
5 years ago
Romain Vimont 15a206b7fc Assert return value of mutex functions
Mutex functions may only fail due to a programming error.

Use assertions in debug builds, and ignore the value in release builds.
5 years ago
Romain Vimont d0f5a7fd9f Remove unused includes
No mutex is used in decoder.c and stream.c.
5 years ago
Romain Vimont 510caff0cd Replace SDL_assert() by assert()
SDL_assert() open a dialog on assertion failure.

There is no reason not to use assert() directly.
5 years ago
Romain Vimont b5ebb234dd Replace BUILD_DEBUG by NDEBUG
Use the "standard" NDEBUG definition, which is used by assert().
5 years ago
Romain Vimont 73e8ec1b35 Remove path argument from cmd_execute()
It is always equal to argv[0] (or not used on Windows).
5 years ago
Romain Vimont 8dc11a0286 Fix warnings on Windows
fix warnings reported with -Dwarning_level=2 on Windows.
5 years ago