Log with category APPLICATION
All our logs should use APPLICATION category. The logs for other categories are not printed by default under the "critical" level.
This commit is contained in:
parent
598ddcbfbc
commit
6fe65d9f5c
9 changed files with 34 additions and 34 deletions
|
@ -67,7 +67,7 @@ process_t adb_push(const char *serial, const char *local, const char *remote) {
|
|||
|
||||
SDL_bool process_check_success(process_t proc, const char *name) {
|
||||
if (proc == PROCESS_NONE) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not execute \"%s\"", name);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not execute \"%s\"", name);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
exit_code_t exit_code;
|
||||
|
|
|
@ -80,7 +80,7 @@ SDL_bool controller_start(struct controller *controller) {
|
|||
|
||||
controller->thread = SDL_CreateThread(run_controller, "controller", controller);
|
||||
if (!controller->thread) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not start controller thread");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not start controller thread");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,39 +38,39 @@ static int run_decoder(void *data) {
|
|||
|
||||
AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_H264);
|
||||
if (!codec) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "H.264 decoder not found");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "H.264 decoder not found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AVCodecContext *codec_ctx = avcodec_alloc_context3(codec);
|
||||
if (!codec_ctx) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_VIDEO, "Could not allocate decoder context");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate decoder context");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avcodec_open2(codec_ctx, codec, NULL) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not open H.264 codec");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not open H.264 codec");
|
||||
ret = -1;
|
||||
goto run_finally_free_codec_ctx;
|
||||
}
|
||||
|
||||
AVFormatContext *format_ctx = avformat_alloc_context();
|
||||
if (!format_ctx) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_VIDEO, "Could not allocate format context");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate format context");
|
||||
ret = -1;
|
||||
goto run_finally_close_codec;
|
||||
}
|
||||
|
||||
unsigned char *buffer = av_malloc(BUFSIZE);
|
||||
if (!buffer) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_VIDEO, "Could not allocate buffer");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate buffer");
|
||||
ret = -1;
|
||||
goto run_finally_free_format_ctx;
|
||||
}
|
||||
|
||||
AVIOContext *avio_ctx = avio_alloc_context(buffer, BUFSIZE, 0, decoder, read_packet, NULL, NULL);
|
||||
if (!avio_ctx) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_VIDEO, "Could not allocate avio context");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate avio context");
|
||||
// avformat_open_input takes ownership of 'buffer'
|
||||
// so only free the buffer before avformat_open_input()
|
||||
av_free(buffer);
|
||||
|
@ -82,7 +82,7 @@ static int run_decoder(void *data) {
|
|||
|
||||
//const char *url = "tcp://127.0.0.1:1234";
|
||||
if (avformat_open_input(&format_ctx, NULL, NULL, NULL) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not open video stream");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not open video stream");
|
||||
ret = -1;
|
||||
goto run_finally_free_avio_ctx;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ static int run_decoder(void *data) {
|
|||
int got_picture;
|
||||
int len = avcodec_decode_video2(codec_ctx, decoder->frames->decoding_frame, &got_picture, &packet);
|
||||
if (len < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not decode video packet: %d", len);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not decode video packet: %d", len);
|
||||
goto run_quit;
|
||||
}
|
||||
if (got_picture) {
|
||||
|
@ -112,11 +112,11 @@ static int run_decoder(void *data) {
|
|||
#else
|
||||
int ret;
|
||||
if ((ret = avcodec_send_packet(codec_ctx, &packet)) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not send video packet: %d", ret);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not send video packet: %d", ret);
|
||||
goto run_quit;
|
||||
}
|
||||
if ((ret = avcodec_receive_frame(codec_ctx, decoder->frames->decoding_frame)) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not receive video frame: %d", ret);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not receive video frame: %d", ret);
|
||||
goto run_quit;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ static int run_decoder(void *data) {
|
|||
#endif
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "End of frames");
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "End of frames");
|
||||
|
||||
run_quit:
|
||||
avformat_close_input(&format_ctx);
|
||||
|
@ -150,7 +150,7 @@ SDL_bool decoder_start(struct decoder *decoder) {
|
|||
|
||||
decoder->thread = SDL_CreateThread(run_decoder, "video_decoder", decoder);
|
||||
if (!decoder->thread) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not start decoder thread");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not start decoder thread");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ SDL_bool frames_offer_decoded_frame(struct frames *frames) {
|
|||
}
|
||||
#else
|
||||
if (!frames->rendering_frame_consumed) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_RENDER, "Skip frame");
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Skip frame");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4,28 +4,28 @@
|
|||
|
||||
void mutex_lock(SDL_mutex *mutex) {
|
||||
if (SDL_LockMutex(mutex)) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not lock mutex");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void mutex_unlock(SDL_mutex *mutex) {
|
||||
if (SDL_UnlockMutex(mutex)) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not unlock mutex");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void cond_wait(SDL_cond *cond, SDL_mutex *mutex) {
|
||||
if (SDL_CondWait(cond, mutex)) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not wait on condition");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not wait on condition");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void cond_signal(SDL_cond *cond) {
|
||||
if (SDL_CondSignal(cond)) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not signal a condition");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not signal a condition");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,18 +7,18 @@
|
|||
TCPsocket server_socket_accept(TCPsocket server_socket, Uint32 timeout_ms) {
|
||||
SDLNet_SocketSet set = SDLNet_AllocSocketSet(1);
|
||||
if (!set) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not allocate socket set");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate socket set");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDLNet_TCP_AddSocket(set, server_socket) == -1) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not add socket to set");
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not add socket to set");
|
||||
SDLNet_FreeSocketSet(set);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDLNet_CheckSockets(set, timeout_ms) != 1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "No connection to accept");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No connection to accept");
|
||||
SDLNet_FreeSocketSet(set);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ SDL_bool sdl_init_and_configure(void) {
|
|||
|
||||
// Bilinear resizing
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not enable bilinear filtering");
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not enable bilinear filtering");
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
// Handle a click to gain focus as any other click
|
||||
if (!SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1")) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not enable mouse focus clickthrough");
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not enable mouse focus clickthrough");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -73,7 +73,7 @@ static SDL_bool get_preferred_display_bounds(struct size *bounds) {
|
|||
# define GET_DISPLAY_BOUNDS(i, r) SDL_GetDisplayBounds((i), (r))
|
||||
#endif
|
||||
if (GET_DISPLAY_BOUNDS(0, &rect)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Could not get display usable bounds: %s", SDL_GetError());
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not get display usable bounds: %s", SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -137,26 +137,26 @@ SDL_bool screen_init_rendering(struct screen *screen, const char *device_name, s
|
|||
screen->window = SDL_CreateWindow(device_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
window_size.width, window_size.height, SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE);
|
||||
if (!screen->window) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not create window: %s", SDL_GetError());
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create window: %s", SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
screen->renderer = SDL_CreateRenderer(screen->window, -1, SDL_RENDERER_ACCELERATED);
|
||||
if (!screen->renderer) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Could not create renderer: %s", SDL_GetError());
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create renderer: %s", SDL_GetError());
|
||||
screen_destroy(screen);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (SDL_RenderSetLogicalSize(screen->renderer, frame_size.width, frame_size.height)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Could not set renderer logical size: %s", SDL_GetError());
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not set renderer logical size: %s", SDL_GetError());
|
||||
screen_destroy(screen);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_Surface *icon = read_xpm(icon_xpm);
|
||||
if (!icon) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not load icon: %s", SDL_GetError());
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load icon: %s", SDL_GetError());
|
||||
screen_destroy(screen);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ SDL_bool screen_init_rendering(struct screen *screen, const char *device_name, s
|
|||
screen->texture = SDL_CreateTexture(screen->renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
|
||||
frame_size.width, frame_size.height);
|
||||
if (!screen->texture) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Could not create texture: %s", SDL_GetError());
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture: %s", SDL_GetError());
|
||||
screen_destroy(screen);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ void screen_destroy(struct screen *screen) {
|
|||
static SDL_bool prepare_for_frame(struct screen *screen, struct size new_frame_size) {
|
||||
if (screen->frame_size.width != new_frame_size.width || screen->frame_size.height != new_frame_size.height) {
|
||||
if (SDL_RenderSetLogicalSize(screen->renderer, new_frame_size.width, new_frame_size.height)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Could not set renderer logical size: %s", SDL_GetError());
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not set renderer logical size: %s", SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ static SDL_bool prepare_for_frame(struct screen *screen, struct size new_frame_s
|
|||
screen->texture = SDL_CreateTexture(screen->renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
|
||||
new_frame_size.width, new_frame_size.height);
|
||||
if (!screen->texture) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Could not create texture: %s", SDL_GetError());
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture: %s", SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ static process_t execute_server(const char *serial, Uint16 max_size, Uint32 bit_
|
|||
|
||||
static void terminate_server(process_t server) {
|
||||
if (!cmd_terminate(server)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not terminate server: %s", strerror(errno));
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not terminate server: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ SDL_Surface *read_xpm(char *xpm[]) {
|
|||
// parse image
|
||||
Uint32 *pixels = SDL_malloc(4 * width * height);
|
||||
if (!pixels) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not allocate icon memory");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate icon memory");
|
||||
return NULL;
|
||||
}
|
||||
for (int y = 0; y < height; ++y) {
|
||||
|
|
Loading…
Reference in a new issue