Commit graph

1904 commits

Author SHA1 Message Date
Romain Vimont
3761f56c28 Declare callbacks static
It was a typo, "static" was missing.
2021-08-26 12:26:44 +02:00
horizon86
c96f5c70e9 Add Simplified Chinese translation of FAQ
PR #2568 <https://github.com/Genymobile/scrcpy/pull/2568>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-08-24 19:29:02 +02:00
Romain Vimont
d6aaa5bf9a Add a FAQ section for Wayland support
The video driver might need to be explicitly set to wayland.

Refs #2554 <https://github.com/Genymobile/scrcpy/issues/2554>
Refs #2559 <https://github.com/Genymobile/scrcpy/issues/2559>
2021-08-13 12:40:22 +02:00
kosantosbik
4ab3e89c29 Add README file in Turkish
PR #2514 <https://github.com/Genymobile/scrcpy/pull/2514>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-08-11 15:42:31 +02:00
Hyperterminal Byte
4bc78244b9 Fix OBS project ref URL
PR #2545 <https://github.com/Genymobile/scrcpy/pull/2545>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-08-11 15:29:17 +02:00
Stefan Huber
ea233d811d Fix typo in DEVELOP.md
PR #2540 <https://github.com/Genymobile/scrcpy/pull/2540>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-08-11 15:26:32 +02:00
Romain Vimont
f78608ab29 Fix type for assignment
The functions net_send_all() and net_recv_all() return ssize_t, not int.
2021-07-15 18:16:56 +02:00
Romain Vimont
6f03022646 Fix net_send_all()
On partial writes, the final result was the number of bytes written by
the last send() rather than the total.
2021-07-15 18:16:26 +02:00
Romain Vimont
daf90d33d5 Fix code style
Make the code fit into 80 columns.
2021-07-15 18:07:39 +02:00
Romain Vimont
0ae10f2b39 Improve slope estimation on start
The first frames are typically received and decoded with more delay than
the others, causing a wrong slope estimation on start.

To compensate, assume an initial slope of 1, then progressively use the
estimated slope.
2021-07-14 14:54:22 +02:00
Romain Vimont
4c4d02295c Add buffering debugging tools
Output buffering and clock logs by disabling a compilation flag.
2021-07-14 14:54:22 +02:00
Romain Vimont
2f03141e9f Add clock tests
The clock rolling sum is not trivial. Test it.
2021-07-14 14:54:22 +02:00
Romain Vimont
3397720330 Add buffering command line options
Add --display-buffer and --v4l2-buffer options to configure buffering
time.
2021-07-14 14:54:22 +02:00
Romain Vimont
79278961b9 Implement buffering
To minimize latency (at the cost of jitter), scrcpy always displays a
frame as soon as it available, without waiting.

However, when recording (--record), it still writes the captured
timestamps to the output file, so that the recorded file can be played
correctly without jitter.

Some real-time use cases might benefit from adding a small latency to
compensate for jitter too. For example, few tens of seconds of latency
for live-streaming are not important, but jitter is noticeable.

Therefore, implement a buffering mechanism (disabled by default) to add
a configurable latency delay.

PR #2417 <https://github.com/Genymobile/scrcpy/issues/2417>
2021-07-14 14:27:33 +02:00
Romain Vimont
408a301201 Notify new frames via callbacks
Currently, a frame is available to the consumer as soon as it is pushed
by the producer (which can detect if the previous frame is skipped).

Notify the new frames (and frame skipped) via callbacks instead.

This paves the way to add (optional) buffering, which will introduce a
delay between the time when the frame is produced and the time it is
available to be consumed.
2021-07-14 14:22:32 +02:00
Romain Vimont
4d8bcfc68a Extract current video_buffer to frame_buffer
The current video buffer only stores one pending frame.

In order to add a new buffering feature, move this part to a separate
"frame buffer". Keep the video_buffer, which currently delegates all its
calls to the frame_buffer.
2021-07-14 14:22:32 +02:00
Romain Vimont
336248df08 Rename video_buffer to sc_video_buffer
Add a scrcpy-specific prefix.
2021-07-14 14:22:32 +02:00
Romain Vimont
28bce48d47 Relax v4l2_sink lock constraints
To fix a data race, commit 5caeab5f6d
called video_buffer_push() and video_buffer_consume() under the
v4l2_sink lock.

Instead, use the previous_skipped indication (initialized with video
buffer locked) to lock only for protecting the has_frame flag.

This enables the possibility for the video_buffer to notify new frames
via callbacks without lock inversion issues.
2021-07-14 14:22:32 +02:00
Romain Vimont
32e692d5d2 Replace delay by deadline in timedwait()
The function sc_cond_timedwait() accepted a parameter representing the
max duration to wait, because it internally uses SDL_CondWaitTimeout().

Instead, accept a deadline, to be consistent with
pthread_cond_timedwait().
2021-07-14 14:22:32 +02:00
Romain Vimont
ec871dd3f5 Wrap tick API
This avoids to use the SDL timer API directly, and will allow to handle
generic ticks (possibly negative).
2021-07-14 14:22:32 +02:00
Romain Vimont
5524f378c8 Add missing error log
Log video buffer initialization failure in v4l2_sink.
2021-07-14 00:39:35 +02:00
Romain Vimont
4ed3aa3604 Move include fps_counter
The fps_counter is not used from video_buffer.
2021-07-14 00:35:10 +02:00
Romain Vimont
40cea1f677 Remove obsolete comment
Commit 2a94a2b119 removed video_buffer
callbacks, the comment is now meaningless.
2021-07-14 00:35:10 +02:00
Romain Vimont
099cba07f0 Rename queue to sc_queue
Add a scrcpy-specific prefix.
2021-07-14 00:35:10 +02:00
Romain Vimont
af8a21ed7c Fix manpage formatting 2021-07-06 18:33:04 +02:00
Romain Vimont
5938e862a1 Fix --lock-video-orientation syntax in help
Commit f76fe2c0d4 fixed README and tests.

Fix command line help and manpage.
2021-07-06 18:32:40 +02:00
Romain Vimont
e9096e3e34 Remove unnecessary calls to av_packet_unref()
av_packet_free() already calls av_packet_unref().
2021-07-04 12:19:52 +02:00
Romain Vimont
5caeab5f6d Fix v4l2 data race
The v4l2_sink implementation directly read the internal video_buffer
field "pending_frame_consumed", which is protected by the internal
video_buffer mutex. But this mutex was not locked, so reads were racy.

Lock using the v4l2_sink mutex in addition, and use a separate field to
avoid depending on the video_buffer internal data.
2021-06-26 16:03:52 +02:00
Romain Vimont
33fbdc86c7 Initialize fields before starting a thread
To avoid data races.

Reported by TSAN.
2021-06-26 16:03:34 +02:00
Romain Vimont
f33d37976c Fix assertion race condition in debug mode
Commit 21d206f360 added mutex assertions.

However, the "locker" variable to trace the locker thread id was read
and written by several threads without any protection, so it was racy.

Reported by TSAN.
2021-06-26 15:31:50 +02:00
Romain Vimont
7dca5078e7 Initialize controller even if there is no display
The options --no-display and --no-control are independent.

The controller was not initialized when no display was requested,
because it was assumed that no control could occur without display. But
that's not true (anymore): for example, it is possible to pass
--turn-screen-off.

Fixes #2426 <https://github.com/Genymobile/scrcpy/issues/2426>
2021-06-25 21:48:07 +02:00
Romain Vimont
ab12b6c981 Update scrcpy-server in install-release.sh
Make the install script download the new prebuilt server (v1.18).

Fixes #2409 <https://github.com/Genymobile/scrcpy/issues/2409>
2021-06-21 09:47:15 +02:00
Romain Vimont
376201a83c Update links to v1.18 in README and BUILD 2021-06-20 22:11:56 +02:00
Romain Vimont
60c4e886d4 Bump version to 1.18
Make the versionCode a decimal representation of the scrcpy version.

This will for example allow to correctly number the versionCode of
v1.17.1 after a v1.18 is released:
 - v1.18   -> 11800
 - v1.17.1 -> 11701
 - v1.18.1 -> 11801
2021-06-20 22:01:07 +02:00
Romain Vimont
ff7baad709 Upgrade platform-tools (31.0.2) for Windows
Include the latest version of adb in Windows releases.
2021-06-20 21:19:11 +02:00
Romain Vimont
e712f30ceb Merge branch 'master' into dev 2021-06-20 21:18:58 +02:00
Wirtos_new
a9d9cbf8b5 Replace VLA by dynamic allocation
And increase the command buffer size.

Refs #1358 <https://github.com/Genymobile/scrcpy/issues/1358#issuecomment-862989748>
PR #2405 <https://github.com/Genymobile/scrcpy/pull/2405>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-06-20 21:16:42 +02:00
Wirtos_new
fda32928c1 Rename cmd to argv
This is more explicit.

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

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-06-20 21:16:42 +02:00
Romain Vimont
710e80aa0d Return build_cmd() success via a boolean
For consistency with other functions in the codebase.
2021-06-20 21:16:42 +02:00
Romain Vimont
77e96d745b Suggest --record-format instead of -F on error
The short option -F has been deprecated by
ff061b4f30. On error, suggest the long
option --record-format instead.
2021-06-20 21:16:03 +02:00
Romain Vimont
1c95043478 Attempt to log message only in verbose mode
If the log level is not verbose, there is no need to attempt to log
control messages at all.
2021-06-20 16:44:59 +02:00
Romain Vimont
488991116b Expose function to get the current log level
This will allow to avoid unnecessary processing for creating logs which
will be discarded anyway.
2021-06-20 16:04:18 +02:00
Romain Vimont
5c95d18beb Move log level conversion to log API 2021-06-20 16:04:18 +02:00
Romain Vimont
1039f9b531 Workaround PRIu64 on Windows
On Windows, PRIu64 is defined to "llu", which is not supported:

    error: unknown conversion type character 'l' in format
2021-06-20 16:04:18 +02:00
Marti Raudsepp
19ca02cd8f Log control messages in verbose mode
PR #2371 <https://github.com/Genymobile/scrcpy/pull/2371>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-06-20 16:03:52 +02:00
Marti Raudsepp
937fa704a6 Add --verbosity=verbose log level
PR #2371 <https://github.com/Genymobile/scrcpy/pull/2371>

Signed-off-by: Romain Vimont <rom@rom1v.com>
2021-06-20 12:34:19 +02:00
Romain Vimont
7db0189f23 Forward mouse motion only on main clicks
Mouse motion events were forwarded as soon as any mouse button was
pressed.

Instead, only consider left-click (and also middle-click and right-click
if --forward-all-clicks is enabled).
2021-06-20 12:34:19 +02:00
Romain Vimont
8b90e1d3f4 Remove extra ';' in #define 2021-06-20 12:34:19 +02:00
Romain Vimont
df017160ed Replace strcpy() by memcpy()
It was safe to call strcpy() since the input length was checked, but
then it is more straightforward to call memcpy() directly.
2021-06-20 12:34:19 +02:00
Romain Vimont
b846d3a085 Adapt call() on ContentProvider for Android 12
Android 12 changed one of the call() overloads with a new parameter
AttributionSource. Adapt the wrapper.

Fixes #2402 <https://github.com/Genymobile/scrcpy/issues/2402>
2021-06-19 22:59:48 +02:00