Commit Graph

19 Commits (master)

Author SHA1 Message Date
chengjian.scj d93582724d Initialize interrupted field explicitly
The field sc_fps_counter.interrupted was never initialized explicitly.

Signed-off-by: Romain Vimont <rom@rom1v.com>
1 year ago
Romain Vimont fa93c8a91b Move FPS counter start/stop logs
This will allow to print the same logs for every start/stop call.

PR #3030 <https://github.com/Genymobile/scrcpy/pull/3030>
2 years ago
Romain Vimont 03705b828b Use sc_prefix for fps counter 2 years ago
Romain Vimont 2a872c3865 Fix fps_counter tick type
The type uint32_t is not sufficient to store the result of
sc_tick_now().

As a consequence, the FPS counter entered a live loop and caused a lock
starvation (deadlock in practice).

Refs ec871dd3f5
Refs 682a691173
2 years ago
Romain Vimont 3ada5c51bc Rename scrcpy threads
Prefix the name of threads by "scrcpy-". This improves readability in
the output of `top -H` for example.

Limit the thread names to 16 bytes, because it is limited on some
platforms.
3 years ago
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().
3 years ago
Romain Vimont ec871dd3f5 Wrap tick API
This avoids to use the SDL timer API directly, and will allow to handle
generic ticks (possibly negative).
3 years ago
Romain Vimont e604e8a752 Move fps_counter to screen
The FPS counter specifically count frames from the screen video buffer,
so it is specific to the screen.
3 years ago
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 59feb2a15c Group common includes into common.h
Include config.h and compat.h in common.h, and include common.h from all
source files.
3 years ago
Romain Vimont 54ccccd883 Replace SDL_Atomic by stdatomic from C11
There is no reason to use SDL atomics.
4 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 dfd0707a29 Move utilities to util/ 5 years ago
Romain Vimont 1f8ba1ca79 Include config.h everywhere
Ref: <https://github.com/Genymobile/scrcpy/issues/829>

Suggested-by: Louis Kruger <louisk@gmail.com>
5 years ago
Romain Vimont e2a272bf99 Improve framerate counting
The FPS counter was called only on new frames, so it could not print
values regularly, especially when there are very few FPS (when the
device surface does not change).

To the extreme, it was never able to display 0 fps.

Add a separate thread to print framerate every second.
5 years ago
Romain Vimont ebccb9f6cc Add runtime option to render expired frames
Replace the compilation flag SKIP_FRAMES by a runtime flag to force
rendering of expired frames. By default, the expired frames are skipped.
5 years ago
Romain Vimont dfed1b250e Replace SDL types by C99 standard types
Scrcpy is a C11 project. Use the C99 standard types instead of the
SDL-specific types:

    SDL_bool -> bool
    SintXX   -> intXX_t
    UintXX   -> uintXX_t
5 years ago
Romain Vimont aeda583a2c Update code style
Limit source code to 80 chars, and declare functions return type and
modifiers on a separate line.

This allows to avoid very long lines, and all function names are
aligned.

(We do this on VLC, and I like it.)
5 years ago
Romain Vimont 536b31829a Separate multi-words filenames by '_'
Rename foobar.ext to foo_bar.ext.

<https://github.com/Genymobile/scrcpy/pull/226#discussion_r209454865>
6 years ago