A call to swr_set_compensation() configures the resampler to drop or
duplicate "diff" samples over an interval of "distance" samples.
If the function is not called again, then after "distance" samples, no
more compensation will be applied. So it must always be called, even if
the new computed diff value happens to be the same as the previous one.
In practice, it is unlikely that the diff value is exactly the same
every second, except when it is actively clamped (to 2% of the sample
rate).
Reset video capture/encoding on MOD+Shift+r.
Like on device rotation, this starts a new encoding session which
produces a video stream starting by a key frame.
PR #5432 <https://github.com/Genymobile/scrcpy/pull/5432>
Accept a single boolean "on" rather than a "mode" (which, in practice,
could only take 2 values: NORMAL and OFF).
Also rename "screen power mode" to "display power".
PR #5418 <https://github.com/Genymobile/scrcpy/pull/5418>
If video playback is disabled, then SDK mouse (which uses absolute
positions) could not be used, so the default mouse mode was
automatically switched to UHID.
But UHID does not work on all devices, so it could make the whole scrcpy
session fail.
Instead, disable the mouse by default. It is still possible to pass -M
or --mouse=uhid to enable it explicitly.
Fixes#5410 <https://github.com/Genymobile/scrcpy/issues/5410>
By adding the '?' prefix, the app is searched by its name instead of its
package name (retrieving app names on the device may take some time):
scrcpy --start-app=?firefox
An app matches if its label starts with the given name,
case-insensitive.
If '+' is also passed to force-stop the app before starting, then the
prefixes must be in that order:
scrcpy --start-app=+?firefox
PR #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
The previous commit introduced:
scrcpy --start-app=name
By adding a '+' prefix, the app is stopped beforehand:
scrcpy --start-app=+name
This may be useful to start a fresh app on a new virtual display:
scrcpy --new-display --start-app=+org.mozilla.firefox
PR #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
Add a command line option --start-app=name to start an Android app by
its package name. For example:
scrcpy --start-app=org.mozilla.firefox
The app will be started on the correct target display:
scrcpy --new-display=1920x1080 --start-app=org.videolan.vlc
PR #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Add a feature to create a new (separate) virtual display instead of
mirroring the device screen:
scrcpy --new-display=1920x1080
scrcpy --new-display=1920x1080/420 # force 420 dpi
scrcpy --new-display # use the main display size and density
scrcpy --new-display -m1920 # scaled to fit a max size of 1920
scrcpy --new-display=/240 # use the main display size and 240 dpi
Fixes#1887 <https://github.com/Genymobile/scrcpy/issues/1887>
PR #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Co-authored-by: anirudhb <anirudhb@users.noreply.github.com>
The server params were passed from the main thread to the server thread,
so a deep copy was performed in case the caller instance was destroyed.
But in practice, it only contains memory that lives until the end of the
program (command line arguments), so simply reference it. Several copies
of string fields were missing anyway.
With the old macros definitions, the type of the result depended on the
type of `sec`.
In particular, if sec is a 32-bit type, sec * 1000000 was likely to
overflow (even if the result was assigned to a sc_tick by the caller of
the macro).
This was the case on Windows, where the long type is a 32-bit signed
integer: the --time-limit argument, expressed in seconds, was first
parsed to a long value, then multiplied by 1000000 by the
SC_TICK_FROM_SEC() macro, causing an overflow when the value was greater
than 2147 (2^31 / 1000000).
Fixes#5355 <https://github.com/Genymobile/scrcpy/issues/5355>
The audio player had 2 roles:
- handle the SDL audio output device;
- resample input samples to maintain a target latency.
Extract the latter to a separate component (an "audio regulator"),
independent of SDL.
Capture the gamepads even when the window is not focused.
Note: In theory, with this flag set, we could capture gamepad events
even without a window (--no-window). In practice, scrcpy still requires
a window, because --no-window implies --no-control, and the input
manager is owned by the sc_screen instance, which does not exist if
there is no window. Supporting this use case would require a lot of
refactors.
Refs <https://github.com/Genymobile/scrcpy/pull/5270#issuecomment-2339360460>
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
Suggested-by: Luiz Henrique Laurini <luizhenriquelaurini@gmail.com>
The sc_uhid_devices instance is initialized only when there is a UHID
keyboard.
The device message receiver assumed that it could not receive HID output
reports without a sc_uhid_devices instance (i.e. without a UHID
keyboard), but in practice, a UHID driver implementation on the device
may decide to send UHID output reports for mouse or for gamepads (and we
must just ignore them).
So remove the assert().
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
There was a registration mechanism to listen to HID outputs with a
specific HID id.
However, the UHID gamepad processor handles several ids, so it cannot
work. We could complexify the registration mechanism, but instead,
directly dispatch to the expected processor based on the UHID id.
Concretely, instead of passing a sc_uhid_devices instance to construct a
sc_keyboard_uhid, so that it can register itself, construct the
sc_uhid_devices with all the UHID instances (currently only
sc_keyboard_uhid) so that it can dispatch HID outputs directly.
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
Initialize UHID devices with a custom name:
- "scrcpy: $GAMEPAD_NAME" for gamepads
- "scrcpy" for keyboard and mouse (or if no gamepad name is available)
The name may appear in Android apps.
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
For convenience, short options were added to select UHID input modes:
- -K for --keyboard=uhid
- -M for --mouse=uhid
- -G for --gamepad=uhid
In OTG mode, UHID is not available, so the short options should select
AOA instead.
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
Similar to UHID keyboard and mouse, but for gamepads.
Can be enabled with --gamepad=uhid or -G.
It is not enabled by default because not all devices support UHID
(there is a permission error on old Android versions).
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
This message will be sent on gamepad disconnection.
Contrary to keyboard and mouse devices, which are registered once and
unregistered when scrcpy exists, each physical gamepad is mapped with
its own HID id, and they can be plugged and unplugged dynamically.
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
Trigger SDL_CONTROLLERDEVICEADDED for all gamepads already connected
when scrcpy starts. We want to handle both the gamepads initially
connected and the gamepads connected while scrcpy is running.
This is not racy, because this event may not be trigged automatically
until SDL events are "pumped" (SDL_PumpEvents/SDL_WaitEvent).
PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>