Commit Graph

1101 Commits (964b6d2243fa1921543e48810f3064b9bd2d50d1)
 

Author SHA1 Message Date
Romain Vimont f6320c7e31 Wrap SDL thread functions into scrcpy-specific API
The goal is to expose a consistent API for system tools, and paves the
way to make the "core" independant of SDL in the future.
3 years ago
Romain Vimont 30e619d37f Replace SDL_strdup() by strdup()
The functions SDL_malloc(), SDL_free() and SDL_strdup() were used only
because strdup() was not available everywhere.

Now that it is available, use the native version of these functions.
3 years ago
Romain Vimont c0dde0fade Provide strdup() compat
Make strdup() available on all platforms.
3 years ago
Romain Vimont ace438e52a Remove unused port_range field
The port_range is used from "struct server_params", the copy in
"struct server" was unused.
3 years ago
Romain Vimont 8e83f3e8af Remove unused custom event 3 years ago
Romain Vimont 97b001e7c0 Fix undefined left shift
Small unsigned integers promote to signed int. As a consequence, if v is
a uint8_t, then (v << 24) yields an int, so the left shift is undefined
if the MSB is 1.

Cast to uint32_t to yield an unsigned value.

Reported by USAN (meson x -Db_sanitize=undefined):

    runtime error: left shift of 255 by 24 places cannot be represented
    in type 'int'
3 years ago
Romain Vimont d8e9ad20b0 Improve file handler error message
Terminating the file handler current process may be either a "push" or
"install" command.
3 years ago
Romain Vimont b566700bfd Kill process with SIGKILL signal
An "adb push" command is not terminated by SIGTERM.
3 years ago
Romain Vimont 7afd149f4b Fix file_handler process race condition
The current process could be waited both by run_file_handler() and
file_handler_stop().

To avoid the race condition, wait the process without closing, then
close with mutex locked.
3 years ago
Romain Vimont 6a50231698 Expose a single process_wait()
There were two versions: process_wait() and process_wait_noclose().

Expose a single version with a flag (it was already implemented that way
internally).
3 years ago
Romain Vimont b8edcf52b0 Simplify process_wait()
The function process_wait() returned a bool (true if the process
terminated successfully) and provided the exit code via an output
parameter exit_code.

But the returned value was always equivalent to exit_code == 0, so just
return the exit code instead.
3 years ago
Romain Vimont 94eff0a4bb Fix size_t incorrectly assigned to int
The function control_msg_serialize() returns a size_t.
4 years ago
Romain Vimont 8dbb1676b7 Factorize meson compiler variable initialization 4 years ago
Romain Vimont ab912c23e7 Define feature test macros in common.h
This enables necessary functions once for all.

As a consequence, define common.h before any other header.
4 years ago
Romain Vimont 59feb2a15c Group common includes into common.h
Include config.h and compat.h in common.h, and include common.h from all
source files.
4 years ago
Romain Vimont 6385b8c162 Move common structs to coords.h
The size, point and position structs were defined in common.h. Move them
to coords.h so that common.h could be used for generic code to be
included in all source files.
4 years ago
Romain Vimont 037be4af21 Fix compat missing include
The header libavformat/version.h was included, but not
libavcodec/version.h.

As a consequence, the LIBAVCODEC_VERSION_INT definition depended on the
caller includes.
4 years ago
Romain Vimont 1e215199dc Remove unused struct port_range
It had been replaced by struct sc_port_range in scrcpy.h.
4 years ago
Romain Vimont d580ee30f1 Separate process wait and close
On Linux, waitpid() both waits for the process to terminate and reaps it
(closes its handle). On Windows, these actions are separated into
WaitForSingleObject() and CloseHandle().

Expose these actions separately, so that it is possible to send a signal
to a process while waiting for its termination without race condition.

This allows to wait for server termination normally, but kill the
process without race condition if it is not terminated after some delay.
4 years ago
Romain Vimont 821c175730 Rename process_simple_wait to process_wait
Adding "simple" in the function name brings no benefit.
4 years ago
Romain Vimont cc6f5020d8 Move conditional src files in meson.build
Declare all the source files (including the platform-specific ones) at
the beginning.
4 years ago
Romain Vimont 4bd9da4c93 Split command into process and adb
The process API provides the system-specific implementation, the adb API
uses it to expose adb commands.
4 years ago
Romain Vimont aa8b571389 Increase display id range
Some devices use big display id values.

Refs #2009 <https://github.com/Genymobile/scrcpy/issues/2009>
4 years ago
Romain Vimont ed130e05d5 Fix possibly uninitialized value
Due to gotos, "ret" may be returned uninitialized.
4 years ago
clesiemo3 192fbd8450 Use --cask for latest versions of brew
PR #2004 <https://github.com/Genymobile/scrcpy/pull/2004>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont c5c5fc18ae Update links to v1.17 in README and BUILD 4 years ago
Romain Vimont f682b87ba5 Bump version to 1.17 4 years ago
Romain Vimont 10b749e27d Kill the server only after a small delay
Let the server terminate properly once all the sockets are closed.

If it does not terminate (this can happen if the device is asleep), then
kill it.

Note: since the server process termination is detected by a flag set
after waitpid() returns, there is a small chance that the process
terminates (and the PID assigned to a new process) before the flag is
set but before the kill() call. This race condition already existed
before this commit.

Fixes #1992 <https://github.com/Genymobile/scrcpy/issues/1992>
4 years ago
Romain Vimont 05e8c1a3c5 Call CloseHandle() after wait on Windows
TerminateProcess() is "equivalent" to kill(), while
WaitForSingleObject() is "equivalent" to waitpid(), so the handle must
be closed after WaitForSingleObject().
4 years ago
Romain Vimont 83910d3b9c Initialize server struct dynamically
This will allow to add mutex/cond fields.
4 years ago
Romain Vimont 90f8356630 Interrupt device threads on stop
The (non-daemon) threads were not interrupted on video stream stopped,
leaving the server process alive.

Interrupt them to wake up their blocking call so that they terminate
properly.

Refs #1992 <https://github.com/Genymobile/scrcpy/issues/1992>
4 years ago
Romain Vimont 3ba51211d6 Mention how to add default arguments on Windows
Mention that it is possible to add default arguments by editing the
wrapper scripts.
4 years ago
Romain Vimont ea3582d2c3 Merge branch 'master' into dev 4 years ago
Romain Vimont 112adbba87 Happy new year 2021! 4 years ago
Romain Vimont d039a7a39a Upgrade SDL (2.0.14) for Windows
Include the latest version of SDL in Windows releases.
4 years ago
Romain Vimont 6ab80e4ce8 Rename release.make to release.mk
It's more standard, and benefits from syntax coloration in vi.
4 years ago
Romain Vimont 230afd8966 Unify release makefile
Before this change, release.sh built some native stuff, and
Makefile.CrossWindows built the Windows releases.

Instead, use a single release.make to build the whole release. It also
avoids to build the server one more time.
4 years ago
Romain Vimont a46733906a Replace noconsole binary by a wrapper script
This simplifies the build system.

Refs <https://github.com/Genymobile/scrcpy/issues/1975#issuecomment-745314161>
4 years ago
Romain Vimont 431c9ee33b Improve rotation documentation 4 years ago
Romain Vimont 43d3dcbd97 Document Windows command line usage
PR #1973 <https://github.com/Genymobile/scrcpy/pull/1973>

Reviewed-by: Yu-Chen Lin <npes87184@gmail.com>
4 years ago
Romain Vimont a5f4f58295 Remove duplicate include 4 years ago
Romain Vimont ea12783bbc Upgrade JUnit to 4.13 4 years ago
Romain Vimont 904d470579 Pause on error from a wrapper script
On Windows, scrcpy paused on error before exiting to give the user a
chance to see the user message.

This was a hack and causes issues when using scrcpy from batch scripts.

Disable this pause from the scrcpy binary, and provide a batch wrapper
(scrcpy-console.bat) to pause on error.

Fixes #1875 <https://github.com/Genymobile/scrcpy/issues/1875>
4 years ago
Romain Vimont 6d151eaef9 Reference encoder section from FAQ 4 years ago
Romain Vimont 5dc3285dbf Reference FFmpeg Windows builds from GitHub
Refs #1753 <https://github.com/Genymobile/scrcpy/issues/1753>
4 years ago
Romain Vimont c9a4bdb890 Upgrade platform-tools (30.0.5) for Windows
Include the latest version of adb in Windows releases.
4 years ago
Romain Vimont d60ac65b32 Merge branch 'master' into dev 4 years ago
jianzhang4 d6078cf202 Fix build errors for macOS
PR #1960 <https://github.com/Genymobile/scrcpy/pull/1960>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
SamBe.ng 47c8971267 Document shell command to get the device IP
PR #1944 <https://github.com/Genymobile/scrcpy/pull/1944>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont 30434afc0a Upgrade gradle build tools to 4.0.1 4 years ago