mirror of
https://github.com/Genymobile/scrcpy
synced 2024-11-09 07:10:29 +00:00
Rename (un)lock_mutex to mutex_(un)lock
For consistency, rename lock_mutex and unlock_mutex to mutex_lock and mutex_unlock.
This commit is contained in:
parent
ad667bfa20
commit
c4266e487b
@ -21,7 +21,7 @@ static int read_packet(void *opaque, uint8_t *buf, int buf_size) {
|
|||||||
// set the decoded frame as ready for rendering, and notify
|
// set the decoded frame as ready for rendering, and notify
|
||||||
static void push_frame(struct decoder *decoder) {
|
static void push_frame(struct decoder *decoder) {
|
||||||
struct frames *frames = decoder->frames;
|
struct frames *frames = decoder->frames;
|
||||||
lock_mutex(frames->mutex);
|
mutex_lock(frames->mutex);
|
||||||
if (!decoder->skip_frames) {
|
if (!decoder->skip_frames) {
|
||||||
while (!frames->rendering_frame_consumed) {
|
while (!frames->rendering_frame_consumed) {
|
||||||
SDL_CondWait(frames->rendering_frame_consumed_cond, frames->mutex);
|
SDL_CondWait(frames->rendering_frame_consumed_cond, frames->mutex);
|
||||||
@ -32,7 +32,7 @@ static void push_frame(struct decoder *decoder) {
|
|||||||
|
|
||||||
frames_swap(frames);
|
frames_swap(frames);
|
||||||
frames->rendering_frame_consumed = SDL_FALSE;
|
frames->rendering_frame_consumed = SDL_FALSE;
|
||||||
unlock_mutex(frames->mutex);
|
mutex_unlock(frames->mutex);
|
||||||
|
|
||||||
static SDL_Event new_frame_event = {
|
static SDL_Event new_frame_event = {
|
||||||
.type = EVENT_NEW_FRAME,
|
.type = EVENT_NEW_FRAME,
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
#ifndef LOCKUTIL_H
|
#ifndef LOCKUTIL_H
|
||||||
#define LOCKUTIL_H
|
#define LOCKUTIL_H
|
||||||
|
|
||||||
static inline void lock_mutex(SDL_mutex *mutex) {
|
#include <stdlib.h>
|
||||||
|
#include <SDL2/SDL_log.h>
|
||||||
|
#include <SDL2/SDL_mutex.h>
|
||||||
|
|
||||||
|
static inline void mutex_lock(SDL_mutex *mutex) {
|
||||||
if (SDL_LockMutex(mutex)) {
|
if (SDL_LockMutex(mutex)) {
|
||||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex");
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void unlock_mutex(SDL_mutex *mutex) {
|
static inline void mutex_unlock(SDL_mutex *mutex) {
|
||||||
if (SDL_UnlockMutex(mutex)) {
|
if (SDL_UnlockMutex(mutex)) {
|
||||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex");
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -349,7 +349,7 @@ SDL_bool show_screen(const char *serial, Uint16 local_port) {
|
|||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
goto screen_quit;
|
goto screen_quit;
|
||||||
case EVENT_NEW_FRAME:
|
case EVENT_NEW_FRAME:
|
||||||
lock_mutex(frames.mutex);
|
mutex_lock(frames.mutex);
|
||||||
AVFrame *frame = frames.rendering_frame;
|
AVFrame *frame = frames.rendering_frame;
|
||||||
frames.rendering_frame_consumed = SDL_TRUE;
|
frames.rendering_frame_consumed = SDL_TRUE;
|
||||||
if (!decoder.skip_frames) {
|
if (!decoder.skip_frames) {
|
||||||
@ -364,7 +364,7 @@ SDL_bool show_screen(const char *serial, Uint16 local_port) {
|
|||||||
frame_size = current_frame_size;
|
frame_size = current_frame_size;
|
||||||
|
|
||||||
update_texture(frame, texture);
|
update_texture(frame, texture);
|
||||||
unlock_mutex(frames.mutex);
|
mutex_unlock(frames.mutex);
|
||||||
|
|
||||||
texture_empty = SDL_FALSE;
|
texture_empty = SDL_FALSE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user