Prefix receiver by sc_
Like all other components in scrcpy.
This commit is contained in:
parent
680ddf64be
commit
e91618586c
4 changed files with 21 additions and 21 deletions
|
@ -9,20 +9,20 @@ sc_controller_init(struct sc_controller *controller, sc_socket control_socket,
|
|||
struct sc_acksync *acksync) {
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ok = sc_mutex_init(&controller->mutex);
|
||||
if (!ok) {
|
||||
receiver_destroy(&controller->receiver);
|
||||
sc_receiver_destroy(&controller->receiver);
|
||||
return false;
|
||||
}
|
||||
|
||||
ok = sc_cond_init(&controller->msg_cond);
|
||||
if (!ok) {
|
||||
receiver_destroy(&controller->receiver);
|
||||
sc_receiver_destroy(&controller->receiver);
|
||||
sc_mutex_destroy(&controller->mutex);
|
||||
return false;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ sc_controller_destroy(struct sc_controller *controller) {
|
|||
sc_control_msg_destroy(&msg);
|
||||
}
|
||||
|
||||
receiver_destroy(&controller->receiver);
|
||||
sc_receiver_destroy(&controller->receiver);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -117,7 +117,7 @@ sc_controller_start(struct sc_controller *controller) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!receiver_start(&controller->receiver)) {
|
||||
if (!sc_receiver_start(&controller->receiver)) {
|
||||
sc_controller_stop(controller);
|
||||
sc_thread_join(&controller->thread, NULL);
|
||||
return false;
|
||||
|
@ -137,5 +137,5 @@ sc_controller_stop(struct sc_controller *controller) {
|
|||
void
|
||||
sc_controller_join(struct sc_controller *controller) {
|
||||
sc_thread_join(&controller->thread, NULL);
|
||||
receiver_join(&controller->receiver);
|
||||
sc_receiver_join(&controller->receiver);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ struct sc_controller {
|
|||
sc_cond msg_cond;
|
||||
bool stopped;
|
||||
struct sc_control_msg_queue queue;
|
||||
struct receiver receiver;
|
||||
struct sc_receiver receiver;
|
||||
};
|
||||
|
||||
bool
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "util/log.h"
|
||||
|
||||
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) {
|
||||
bool ok = sc_mutex_init(&receiver->mutex);
|
||||
if (!ok) {
|
||||
|
@ -21,12 +21,12 @@ receiver_init(struct receiver *receiver, sc_socket control_socket,
|
|||
}
|
||||
|
||||
void
|
||||
receiver_destroy(struct receiver *receiver) {
|
||||
sc_receiver_destroy(struct sc_receiver *receiver) {
|
||||
sc_mutex_destroy(&receiver->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
process_msg(struct receiver *receiver, struct device_msg *msg) {
|
||||
process_msg(struct sc_receiver *receiver, struct device_msg *msg) {
|
||||
switch (msg->type) {
|
||||
case DEVICE_MSG_TYPE_CLIPBOARD: {
|
||||
char *current = SDL_GetClipboardText();
|
||||
|
@ -51,7 +51,7 @@ process_msg(struct receiver *receiver, struct device_msg *msg) {
|
|||
}
|
||||
|
||||
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;
|
||||
for (;;) {
|
||||
struct device_msg msg;
|
||||
|
@ -76,7 +76,7 @@ process_msgs(struct receiver *receiver, const unsigned char *buf, size_t len) {
|
|||
|
||||
static int
|
||||
run_receiver(void *data) {
|
||||
struct receiver *receiver = data;
|
||||
struct sc_receiver *receiver = data;
|
||||
|
||||
static unsigned char buf[DEVICE_MSG_MAX_SIZE];
|
||||
size_t head = 0;
|
||||
|
@ -108,7 +108,7 @@ run_receiver(void *data) {
|
|||
}
|
||||
|
||||
bool
|
||||
receiver_start(struct receiver *receiver) {
|
||||
sc_receiver_start(struct sc_receiver *receiver) {
|
||||
LOGD("Starting receiver thread");
|
||||
|
||||
bool ok = sc_thread_create(&receiver->thread, run_receiver,
|
||||
|
@ -122,6 +122,6 @@ receiver_start(struct receiver *receiver) {
|
|||
}
|
||||
|
||||
void
|
||||
receiver_join(struct receiver *receiver) {
|
||||
sc_receiver_join(struct sc_receiver *receiver) {
|
||||
sc_thread_join(&receiver->thread, NULL);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
// receive events from the device
|
||||
// managed by the controller
|
||||
struct receiver {
|
||||
struct sc_receiver {
|
||||
sc_socket control_socket;
|
||||
sc_thread thread;
|
||||
sc_mutex mutex;
|
||||
|
@ -20,18 +20,18 @@ struct receiver {
|
|||
};
|
||||
|
||||
bool
|
||||
receiver_init(struct receiver *receiver, sc_socket control_socket,
|
||||
struct sc_acksync *acksync);
|
||||
sc_receiver_init(struct sc_receiver *receiver, sc_socket control_socket,
|
||||
struct sc_acksync *acksync);
|
||||
|
||||
void
|
||||
receiver_destroy(struct receiver *receiver);
|
||||
sc_receiver_destroy(struct sc_receiver *receiver);
|
||||
|
||||
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
|
||||
receiver_join(struct receiver *receiver);
|
||||
sc_receiver_join(struct sc_receiver *receiver);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue