Prefix receiver by sc_

Like all other components in scrcpy.
This commit is contained in:
Romain Vimont 2023-02-18 09:37:13 +01:00
parent 680ddf64be
commit e91618586c
4 changed files with 21 additions and 21 deletions

View file

@ -9,20 +9,20 @@ sc_controller_init(struct sc_controller *controller, sc_socket control_socket,
struct sc_acksync *acksync) { struct sc_acksync *acksync) {
cbuf_init(&controller->queue); cbuf_init(&controller->queue);
bool ok = receiver_init(&controller->receiver, control_socket, acksync); bool ok = sc_receiver_init(&controller->receiver, control_socket, acksync);
if (!ok) { if (!ok) {
return false; return false;
} }
ok = sc_mutex_init(&controller->mutex); ok = sc_mutex_init(&controller->mutex);
if (!ok) { if (!ok) {
receiver_destroy(&controller->receiver); sc_receiver_destroy(&controller->receiver);
return false; return false;
} }
ok = sc_cond_init(&controller->msg_cond); ok = sc_cond_init(&controller->msg_cond);
if (!ok) { if (!ok) {
receiver_destroy(&controller->receiver); sc_receiver_destroy(&controller->receiver);
sc_mutex_destroy(&controller->mutex); sc_mutex_destroy(&controller->mutex);
return false; return false;
} }
@ -43,7 +43,7 @@ sc_controller_destroy(struct sc_controller *controller) {
sc_control_msg_destroy(&msg); sc_control_msg_destroy(&msg);
} }
receiver_destroy(&controller->receiver); sc_receiver_destroy(&controller->receiver);
} }
bool bool
@ -117,7 +117,7 @@ sc_controller_start(struct sc_controller *controller) {
return false; return false;
} }
if (!receiver_start(&controller->receiver)) { if (!sc_receiver_start(&controller->receiver)) {
sc_controller_stop(controller); sc_controller_stop(controller);
sc_thread_join(&controller->thread, NULL); sc_thread_join(&controller->thread, NULL);
return false; return false;
@ -137,5 +137,5 @@ sc_controller_stop(struct sc_controller *controller) {
void void
sc_controller_join(struct sc_controller *controller) { sc_controller_join(struct sc_controller *controller) {
sc_thread_join(&controller->thread, NULL); sc_thread_join(&controller->thread, NULL);
receiver_join(&controller->receiver); sc_receiver_join(&controller->receiver);
} }

View file

@ -21,7 +21,7 @@ struct sc_controller {
sc_cond msg_cond; sc_cond msg_cond;
bool stopped; bool stopped;
struct sc_control_msg_queue queue; struct sc_control_msg_queue queue;
struct receiver receiver; struct sc_receiver receiver;
}; };
bool bool

View file

@ -7,7 +7,7 @@
#include "util/log.h" #include "util/log.h"
bool bool
receiver_init(struct receiver *receiver, sc_socket control_socket, sc_receiver_init(struct sc_receiver *receiver, sc_socket control_socket,
struct sc_acksync *acksync) { struct sc_acksync *acksync) {
bool ok = sc_mutex_init(&receiver->mutex); bool ok = sc_mutex_init(&receiver->mutex);
if (!ok) { if (!ok) {
@ -21,12 +21,12 @@ receiver_init(struct receiver *receiver, sc_socket control_socket,
} }
void void
receiver_destroy(struct receiver *receiver) { sc_receiver_destroy(struct sc_receiver *receiver) {
sc_mutex_destroy(&receiver->mutex); sc_mutex_destroy(&receiver->mutex);
} }
static void static void
process_msg(struct receiver *receiver, struct device_msg *msg) { process_msg(struct sc_receiver *receiver, struct device_msg *msg) {
switch (msg->type) { switch (msg->type) {
case DEVICE_MSG_TYPE_CLIPBOARD: { case DEVICE_MSG_TYPE_CLIPBOARD: {
char *current = SDL_GetClipboardText(); char *current = SDL_GetClipboardText();
@ -51,7 +51,7 @@ process_msg(struct receiver *receiver, struct device_msg *msg) {
} }
static ssize_t static ssize_t
process_msgs(struct receiver *receiver, const unsigned char *buf, size_t len) { process_msgs(struct sc_receiver *receiver, const unsigned char *buf, size_t len) {
size_t head = 0; size_t head = 0;
for (;;) { for (;;) {
struct device_msg msg; struct device_msg msg;
@ -76,7 +76,7 @@ process_msgs(struct receiver *receiver, const unsigned char *buf, size_t len) {
static int static int
run_receiver(void *data) { run_receiver(void *data) {
struct receiver *receiver = data; struct sc_receiver *receiver = data;
static unsigned char buf[DEVICE_MSG_MAX_SIZE]; static unsigned char buf[DEVICE_MSG_MAX_SIZE];
size_t head = 0; size_t head = 0;
@ -108,7 +108,7 @@ run_receiver(void *data) {
} }
bool bool
receiver_start(struct receiver *receiver) { sc_receiver_start(struct sc_receiver *receiver) {
LOGD("Starting receiver thread"); LOGD("Starting receiver thread");
bool ok = sc_thread_create(&receiver->thread, run_receiver, bool ok = sc_thread_create(&receiver->thread, run_receiver,
@ -122,6 +122,6 @@ receiver_start(struct receiver *receiver) {
} }
void void
receiver_join(struct receiver *receiver) { sc_receiver_join(struct sc_receiver *receiver) {
sc_thread_join(&receiver->thread, NULL); sc_thread_join(&receiver->thread, NULL);
} }

View file

@ -11,7 +11,7 @@
// receive events from the device // receive events from the device
// managed by the controller // managed by the controller
struct receiver { struct sc_receiver {
sc_socket control_socket; sc_socket control_socket;
sc_thread thread; sc_thread thread;
sc_mutex mutex; sc_mutex mutex;
@ -20,18 +20,18 @@ struct receiver {
}; };
bool bool
receiver_init(struct receiver *receiver, sc_socket control_socket, sc_receiver_init(struct sc_receiver *receiver, sc_socket control_socket,
struct sc_acksync *acksync); struct sc_acksync *acksync);
void void
receiver_destroy(struct receiver *receiver); sc_receiver_destroy(struct sc_receiver *receiver);
bool bool
receiver_start(struct receiver *receiver); sc_receiver_start(struct sc_receiver *receiver);
// no receiver_stop(), it will automatically stop on control_socket shutdown // no sc_receiver_stop(), it will automatically stop on control_socket shutdown
void void
receiver_join(struct receiver *receiver); sc_receiver_join(struct sc_receiver *receiver);
#endif #endif