The input manager assumed that if a controller was present, then both a
key processor and a mouse processor were present.
Remove this assumption, to support disabling keyboard and mouse
separately. This prepares the introduction of new command line options
--keyboard and --mouse.
Some functions in input_manager.c only have access to a sub-object (for
example the controller). For consistency, always pass the whole
input manager instance.
This will allow to add assertions when keyboard and mouse could be
disabled separately.
The assumption that underflow and overbuffering are caused by jitter
(and that the delay between the producer and consumer will be caught up)
does not always hold.
For example, if the consumer does not consume at the expected rate (the
SDL callback is not called often enough, which is an audio output
issue), many samples will be dropped due to overbuffering, decreasing
the average buffering indefinitely.
Prevent the average buffering to become negative to limit the
consequences of an unexpected behavior.
PR #4572 <https://github.com/Genymobile/scrcpy/pull/4572>
The buffering level does not change continuously: it increases abruptly
when a packet is received, and decreases abruptly when an audio block is
consumed.
To estimate the buffering level, a rolling average is used.
To make the buffering more stable, increase the smoothness of this
rolling average. This decreases the risk of enabling audio compensation
due to an estimation error.
PR #4572 <https://github.com/Genymobile/scrcpy/pull/4572>
Use different thresholds for enabling and disabling compensation.
Concretely, enable compensation if the difference between the average
and the target buffering levels exceeds 4 ms (instead of 1 ms). This
avoids unnecessary compensation due to small noise in buffering level
estimation.
But keep a smaller threshold (1 ms) for disabling compensation, so that
the buffering level is restored closer to the target value. This avoids
to keep the actual level close to the compensation threshold.
PR #4572 <https://github.com/Genymobile/scrcpy/pull/4572>
The audio output thread only reads samples from the buffer, and most of
the time, the audio receiver thread only writes samples to the buffer.
In these cases, using atomics avoids lock contention.
There are still corner cases where the audio receiver thread needs to
"read" samples (and drop them), so lock only in these cases.
PR #4572 <https://github.com/Genymobile/scrcpy/pull/4572>
Power on the device on start only if video capture is enabled.
Note that it only impacts display mirroring, since control is completely
disabled if video source is camera.
Refs 110b3a16f6
For AV1, the config packet must not be merged with the next non-config
packet.
This fixes the following error when passing --video-codec=av1:
> INFO: [FFmpeg] libdav1d 1.3.0
> ERROR: [FFmpeg] Unknown OBU type 0 of size 29393
> ERROR: [FFmpeg] Error parsing OBU data
> ERROR: Decoder 'video': could not send video packet: -1094995529
PR #4487 <https://github.com/Genymobile/scrcpy/pull/4487>
The SDL video subsystem may be initialized so that clipboard
synchronization works even without video playback.
But if the video subsystem initialization fails (e.g. because no video
device is available), consider it as an error only if video playback is
enabled.
Refs 5e59ed3135Fixes#4477 <https://github.com/Genymobile/scrcpy/issues/4477>
Fix the following warning/error:
../app/src/cli.c:2158:17: warning: a label can only be part of a
statement and a declaration is not a statement [-Wpedantic]
With some compilers, this is an error rather than a pedantic warning.
Refs <https://github.com/Genymobile/scrcpy/issues/2256#issuecomment-1467008307>
Install all the prebuilt dependencies for Windows to a specific folder,
and use meson command line options to specify their location.
This removes crossbuild-specific code from the meson scripts and will
simplify dependency upgrades.
PR #4460 <https://github.com/Genymobile/scrcpy/pull/4460>
Audio PTS are retrieved by AudioRecord.getTimestamp(), so they do not
necessarily exactly match the number of samples (this allows to take
drift and lag into account).
As a consequence, two consecutive timestamps in microseconds may
sometimes end up within the same millisecond, causing the warning. This
is particularly true for the Matroska muxer which uses a timebase of
1/1000 (1 ms precision).
Since this is "expected", lower the log level from warning to debug.
FLAC is not low latency: the default encoder produces blocks of 4096
samples, which represent ~85.333ms.
Increase the audio buffer by default so that audio playback works.