Prefix UI events constants by SC_

This commit is contained in:
Romain Vimont 2023-02-10 18:46:12 +01:00
parent 953edfd1df
commit 4f9e9c6619
4 changed files with 16 additions and 16 deletions

View file

@ -1,5 +1,5 @@
#define EVENT_NEW_FRAME SDL_USEREVENT #define SC_EVENT_NEW_FRAME SDL_USEREVENT
#define EVENT_STREAM_STOPPED (SDL_USEREVENT + 1) #define SC_EVENT_STREAM_STOPPED (SDL_USEREVENT + 1)
#define EVENT_SERVER_CONNECTION_FAILED (SDL_USEREVENT + 2) #define SC_EVENT_SERVER_CONNECTION_FAILED (SDL_USEREVENT + 2)
#define EVENT_SERVER_CONNECTED (SDL_USEREVENT + 3) #define SC_EVENT_SERVER_CONNECTED (SDL_USEREVENT + 3)
#define EVENT_USB_DEVICE_DISCONNECTED (SDL_USEREVENT + 4) #define SC_EVENT_USB_DEVICE_DISCONNECTED (SDL_USEREVENT + 4)

View file

@ -155,7 +155,7 @@ event_loop(struct scrcpy *s) {
SDL_Event event; SDL_Event event;
while (SDL_WaitEvent(&event)) { while (SDL_WaitEvent(&event)) {
switch (event.type) { switch (event.type) {
case EVENT_STREAM_STOPPED: case SC_EVENT_STREAM_STOPPED:
LOGW("Device disconnected"); LOGW("Device disconnected");
return SCRCPY_EXIT_DISCONNECTED; return SCRCPY_EXIT_DISCONNECTED;
case SDL_QUIT: case SDL_QUIT:
@ -179,10 +179,10 @@ await_for_server(bool *connected) {
LOGD("User requested to quit"); LOGD("User requested to quit");
*connected = false; *connected = false;
return true; return true;
case EVENT_SERVER_CONNECTION_FAILED: case SC_EVENT_SERVER_CONNECTION_FAILED:
LOGE("Server connection failed"); LOGE("Server connection failed");
return false; return false;
case EVENT_SERVER_CONNECTED: case SC_EVENT_SERVER_CONNECTED:
LOGD("Server connected"); LOGD("Server connected");
*connected = true; *connected = true;
return true; return true;
@ -237,7 +237,7 @@ sc_demuxer_on_eos(struct sc_demuxer *demuxer, void *userdata) {
(void) demuxer; (void) demuxer;
(void) userdata; (void) userdata;
PUSH_EVENT(EVENT_STREAM_STOPPED); PUSH_EVENT(SC_EVENT_STREAM_STOPPED);
} }
static void static void
@ -245,7 +245,7 @@ sc_server_on_connection_failed(struct sc_server *server, void *userdata) {
(void) server; (void) server;
(void) userdata; (void) userdata;
PUSH_EVENT(EVENT_SERVER_CONNECTION_FAILED); PUSH_EVENT(SC_EVENT_SERVER_CONNECTION_FAILED);
} }
static void static void
@ -253,7 +253,7 @@ sc_server_on_connected(struct sc_server *server, void *userdata) {
(void) server; (void) server;
(void) userdata; (void) userdata;
PUSH_EVENT(EVENT_SERVER_CONNECTED); PUSH_EVENT(SC_EVENT_SERVER_CONNECTED);
} }
static void static void

View file

@ -371,7 +371,7 @@ sc_video_buffer_on_new_frame(struct sc_video_buffer *vb, bool previous_skipped,
bool need_new_event; bool need_new_event;
if (previous_skipped) { if (previous_skipped) {
sc_fps_counter_add_skipped_frame(&screen->fps_counter); sc_fps_counter_add_skipped_frame(&screen->fps_counter);
// The EVENT_NEW_FRAME triggered for the previous frame will consume // The SC_EVENT_NEW_FRAME triggered for the previous frame will consume
// this new frame instead, unless the previous event failed // this new frame instead, unless the previous event failed
need_new_event = screen->event_failed; need_new_event = screen->event_failed;
} else { } else {
@ -380,7 +380,7 @@ sc_video_buffer_on_new_frame(struct sc_video_buffer *vb, bool previous_skipped,
if (need_new_event) { if (need_new_event) {
static SDL_Event new_frame_event = { static SDL_Event new_frame_event = {
.type = EVENT_NEW_FRAME, .type = SC_EVENT_NEW_FRAME,
}; };
// Post the event on the UI thread // Post the event on the UI thread
@ -820,7 +820,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
bool relative_mode = sc_screen_is_relative_mode(screen); bool relative_mode = sc_screen_is_relative_mode(screen);
switch (event->type) { switch (event->type) {
case EVENT_NEW_FRAME: { case SC_EVENT_NEW_FRAME: {
bool ok = sc_screen_update_frame(screen); bool ok = sc_screen_update_frame(screen);
if (!ok) { if (!ok) {
LOGW("Frame update failed\n"); LOGW("Frame update failed\n");

View file

@ -22,7 +22,7 @@ sc_usb_on_disconnected(struct sc_usb *usb, void *userdata) {
(void) userdata; (void) userdata;
SDL_Event event; SDL_Event event;
event.type = EVENT_USB_DEVICE_DISCONNECTED; event.type = SC_EVENT_USB_DEVICE_DISCONNECTED;
int ret = SDL_PushEvent(&event); int ret = SDL_PushEvent(&event);
if (ret < 0) { if (ret < 0) {
LOGE("Could not post USB disconnection event: %s", SDL_GetError()); LOGE("Could not post USB disconnection event: %s", SDL_GetError());
@ -34,7 +34,7 @@ event_loop(struct scrcpy_otg *s) {
SDL_Event event; SDL_Event event;
while (SDL_WaitEvent(&event)) { while (SDL_WaitEvent(&event)) {
switch (event.type) { switch (event.type) {
case EVENT_USB_DEVICE_DISCONNECTED: case SC_EVENT_USB_DEVICE_DISCONNECTED:
LOGW("Device disconnected"); LOGW("Device disconnected");
return SCRCPY_EXIT_DISCONNECTED; return SCRCPY_EXIT_DISCONNECTED;
case SDL_QUIT: case SDL_QUIT: