Display and control your Android device
Replace SDL_assert() by assert()
Romain Vimont510caff0cd1f
diff --git a/app/src/control_msg.c b/app/src/control_msg.cindex 363483eb..fda16025 100644--- a/app/src/control_msg.c+++ b/app/src/control_msg.c@@ -1,7 +1,7 @@#include "control_msg.h"+#include <assert.h>#include <string.h>-#include <SDL2/SDL_assert.h>#include "config.h"#include "util/buffer_util.h"@@ -27,7 +27,7 @@ write_string(const char *utf8, size_t max_len, unsigned char *buf) {static uint16_tto_fixed_point_16(float f) {- SDL_assert(f >= 0.0f && f <= 1.0f);+ assert(f >= 0.0f && f <= 1.0f);uint32_t u = f * 0x1p16f; // 2^16if (u >= 0xffff) {u = 0xffff;diff --git a/app/src/controller.c b/app/src/controller.cindex ec706c95..d59a7411 100644--- a/app/src/controller.c+++ b/app/src/controller.c@@ -1,6 +1,6 @@#include "controller.h"-#include <SDL2/SDL_assert.h>+#include <assert.h>#include "config.h"#include "util/lock.h"@@ -85,7 +85,8 @@ run_controller(void *data) {}struct control_msg msg;bool non_empty = cbuf_take(&controller->queue, &msg);- SDL_assert(non_empty);+ assert(non_empty);+ (void) non_empty;mutex_unlock(controller->mutex);bool ok = process_msg(controller, &msg);diff --git a/app/src/decoder.c b/app/src/decoder.cindex 52176484..5ac6cd44 100644--- a/app/src/decoder.c+++ b/app/src/decoder.c@@ -2,7 +2,6 @@#include <libavformat/avformat.h>#include <libavutil/time.h>-#include <SDL2/SDL_assert.h>#include <SDL2/SDL_events.h>#include <SDL2/SDL_mutex.h>#include <SDL2/SDL_thread.h>diff --git a/app/src/device_msg.c b/app/src/device_msg.cindex aba56bb3..db176129 100644--- a/app/src/device_msg.c+++ b/app/src/device_msg.c@@ -1,7 +1,6 @@#include "device_msg.h"#include <string.h>-#include <SDL2/SDL_assert.h>#include "config.h"#include "util/buffer_util.h"diff --git a/app/src/file_handler.c b/app/src/file_handler.cindex c0b03bcf..ba689404 100644--- a/app/src/file_handler.c+++ b/app/src/file_handler.c@@ -1,7 +1,7 @@#include "file_handler.h"+#include <assert.h>#include <string.h>-#include <SDL2/SDL_assert.h>#include "config.h"#include "command.h"@@ -120,7 +120,8 @@ run_file_handler(void *data) {}struct file_handler_request req;bool non_empty = cbuf_take(&file_handler->queue, &req);- SDL_assert(non_empty);+ assert(non_empty);+ (void) non_empty;process_t process;if (req.action == ACTION_INSTALL_APK) {diff --git a/app/src/fps_counter.c b/app/src/fps_counter.cindex 0c3f13d4..58c62d55 100644--- a/app/src/fps_counter.c+++ b/app/src/fps_counter.c@@ -1,6 +1,6 @@#include "fps_counter.h"-#include <SDL2/SDL_assert.h>+#include <assert.h>#include <SDL2/SDL_timer.h>#include "config.h"@@ -77,7 +77,7 @@ run_fps_counter(void *data) {uint32_t now = SDL_GetTicks();check_interval_expired(counter, now);- SDL_assert(counter->next_timestamp > now);+ assert(counter->next_timestamp > now);uint32_t remaining = counter->next_timestamp - now;// ignore the reason (timeout or signaled), we just loop anywaydiff --git a/app/src/input_manager.c b/app/src/input_manager.cindex e0aa6054..013fb640 100644--- a/app/src/input_manager.c+++ b/app/src/input_manager.c@@ -1,6 +1,6 @@#include "input_manager.h"-#include <SDL2/SDL_assert.h>+#include <assert.h>#include "config.h"#include "event_converter.h"@@ -217,7 +217,7 @@ input_manager_process_text_input(struct input_manager *im,if (!im->prefer_text) {char c = event->text[0];if (isalpha(c) || c == ' ') {- SDL_assert(event->text[1] == '\0');+ assert(event->text[1] == '\0');// letters and space are handled as raw key eventreturn;}diff --git a/app/src/receiver.c b/app/src/receiver.cindex 33bbf8b5..0474ff55 100644--- a/app/src/receiver.c+++ b/app/src/receiver.c@@ -1,6 +1,6 @@#include "receiver.h"-#include <SDL2/SDL_assert.h>+#include <assert.h>#include <SDL2/SDL_clipboard.h>#include "config.h"@@ -49,7 +49,7 @@ process_msgs(const unsigned char *buf, size_t len) {device_msg_destroy(&msg);head += r;- SDL_assert(head <= len);+ assert(head <= len);if (head == len) {return head;}@@ -64,7 +64,7 @@ run_receiver(void *data) {size_t head = 0;for (;;) {- SDL_assert(head < DEVICE_MSG_SERIALIZED_MAX_SIZE);+ assert(head < DEVICE_MSG_SERIALIZED_MAX_SIZE);ssize_t r = net_recv(receiver->control_socket, buf,DEVICE_MSG_SERIALIZED_MAX_SIZE - head);if (r <= 0) {diff --git a/app/src/recorder.c b/app/src/recorder.cindex b5314daf..465b24e8 100644--- a/app/src/recorder.c+++ b/app/src/recorder.c@@ -1,7 +1,7 @@#include "recorder.h"+#include <assert.h>#include <libavutil/time.h>-#include <SDL2/SDL_assert.h>#include "config.h"#include "compat.h"@@ -116,7 +116,7 @@ recorder_get_format_name(enum recorder_format format) {boolrecorder_open(struct recorder *recorder, const AVCodec *input_codec) {const char *format_name = recorder_get_format_name(recorder->format);- SDL_assert(format_name);+ assert(format_name);const AVOutputFormat *format = find_muxer(format_name);if (!format) {LOGE("Could not find muxer");@@ -357,7 +357,7 @@ recorder_join(struct recorder *recorder) {boolrecorder_push(struct recorder *recorder, const AVPacket *packet) {mutex_lock(recorder->mutex);- SDL_assert(!recorder->stopped);+ assert(!recorder->stopped);if (recorder->failed) {// reject any new packet (this will stop the stream)diff --git a/app/src/screen.c b/app/src/screen.cindex 5c1fdab3..beb10754 100644--- a/app/src/screen.c+++ b/app/src/screen.c@@ -1,5 +1,6 @@#include "screen.h"+#include <assert.h>#include <string.h>#include <SDL2/SDL.h>@@ -110,7 +111,7 @@ get_optimal_size(struct size current_size, struct size frame_size) {}// w and h must fit into 16 bits- SDL_assert_release(w < 0x10000 && h < 0x10000);+ assert(w < 0x10000 && h < 0x10000);return (struct size) {w, h};}@@ -392,8 +393,8 @@ screen_handle_window_event(struct screen *screen,break;case SDL_WINDOWEVENT_MAXIMIZED:// The backup size must be non-nul.- SDL_assert(screen->windowed_window_size_backup.width);- SDL_assert(screen->windowed_window_size_backup.height);+ assert(screen->windowed_window_size_backup.width);+ assert(screen->windowed_window_size_backup.height);// Revert the last size, it was updated while screen was maximized.screen->windowed_window_size = screen->windowed_window_size_backup;#ifdef DEBUGdiff --git a/app/src/server.c b/app/src/server.cindex d9114356..90eb4c69 100644--- a/app/src/server.c+++ b/app/src/server.c@@ -1,10 +1,10 @@#include "server.h"+#include <assert.h>#include <errno.h>#include <inttypes.h>#include <libgen.h>#include <stdio.h>-#include <SDL2/SDL_assert.h>#include <SDL2/SDL_timer.h>#include "config.h"@@ -199,7 +199,7 @@ connect_to_server(uint16_t port, uint32_t attempts, uint32_t delay) {static voidclose_socket(socket_t *socket) {- SDL_assert(*socket != INVALID_SOCKET);+ assert(*socket != INVALID_SOCKET);net_shutdown(*socket, SHUT_RDWR);if (!net_close(*socket)) {LOGW("Could not close socket");@@ -323,7 +323,7 @@ server_stop(struct server *server) {close_socket(&server->control_socket);}- SDL_assert(server->process != PROCESS_NONE);+ assert(server->process != PROCESS_NONE);if (!cmd_terminate(server->process)) {LOGW("Could not terminate server");diff --git a/app/src/stream.c b/app/src/stream.cindex 35a541e4..64b2bf39 100644--- a/app/src/stream.c+++ b/app/src/stream.c@@ -1,8 +1,8 @@#include "stream.h"+#include <assert.h>#include <libavformat/avformat.h>#include <libavutil/time.h>-#include <SDL2/SDL_assert.h>#include <SDL2/SDL_events.h>#include <SDL2/SDL_mutex.h>#include <SDL2/SDL_thread.h>@@ -44,8 +44,8 @@ stream_recv_packet(struct stream *stream, AVPacket *packet) {uint64_t pts = buffer_read64be(header);uint32_t len = buffer_read32be(&header[8]);- SDL_assert(pts == NO_PTS || (pts & 0x8000000000000000) == 0);- SDL_assert(len);+ assert(pts == NO_PTS || (pts & 0x8000000000000000) == 0);+ assert(len);if (av_new_packet(packet, len)) {LOGE("Could not allocate packet");@@ -108,8 +108,9 @@ stream_parse(struct stream *stream, AVPacket *packet) {AV_NOPTS_VALUE, AV_NOPTS_VALUE, -1);// PARSER_FLAG_COMPLETE_FRAMES is set- SDL_assert(r == in_len);- SDL_assert(out_len == in_len);+ assert(r == in_len);+ (void) r;+ assert(out_len == in_len);if (stream->parser->key_frame == 1) {packet->flags |= AV_PKT_FLAG_KEY;diff --git a/app/src/tiny_xpm.c b/app/src/tiny_xpm.cindex 29e0b54f..feb3d1cb 100644--- a/app/src/tiny_xpm.c+++ b/app/src/tiny_xpm.c@@ -1,5 +1,6 @@#include "tiny_xpm.h"+#include <assert.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>@@ -51,24 +52,26 @@ read_xpm(char *xpm[]) {int chars = strtol(endptr + 1, &endptr, 10);// sanity checks- SDL_assert(0 <= width && width < 256);- SDL_assert(0 <= height && height < 256);- SDL_assert(0 <= colors && colors < 256);- SDL_assert(chars == 1); // this implementation does not support more+ assert(0 <= width && width < 256);+ assert(0 <= height && height < 256);+ assert(0 <= colors && colors < 256);+ assert(chars == 1); // this implementation does not support more++ (void) chars;// init indexstruct index index[colors];for (int i = 0; i < colors; ++i) {const char *line = xpm[1+i];index[i].c = line[0];- SDL_assert(line[1] == '\t');- SDL_assert(line[2] == 'c');- SDL_assert(line[3] == ' ');+ assert(line[1] == '\t');+ assert(line[2] == 'c');+ assert(line[3] == ' ');if (line[4] == '#') {index[i].color = 0xff000000 | strtol(&line[5], &endptr, 0x10);- SDL_assert(*endptr == '\0');+ assert(*endptr == '\0');} else {- SDL_assert(!strcmp("None", &line[4]));+ assert(!strcmp("None", &line[4]));index[i].color = 0;}}@@ -85,7 +88,8 @@ read_xpm(char *xpm[]) {char c = line[x];uint32_t color;bool color_found = find_color(index, colors, c, &color);- SDL_assert(color_found);+ assert(color_found);+ (void) color_found;pixels[y * width + x] = color;}}diff --git a/app/src/util/queue.h b/app/src/util/queue.hindex 6cf7aba6..12bc9e89 100644--- a/app/src/util/queue.h+++ b/app/src/util/queue.h@@ -2,9 +2,9 @@#ifndef QUEUE_H#define QUEUE_H+#include <assert.h>#include <stdbool.h>#include <stddef.h>-#include <SDL2/SDL_assert.h>#include "config.h"@@ -67,7 +67,7 @@// type so that we can "return" it)#define queue_take(PQ, NEXTFIELD, PITEM) \(void) ({ \- SDL_assert(!queue_is_empty(PQ)); \+ assert(!queue_is_empty(PQ)); \*(PITEM) = (PQ)->first; \(PQ)->first = (PQ)->first->NEXTFIELD; \})diff --git a/app/src/video_buffer.c b/app/src/video_buffer.cindex 9de3ad7f..629680d9 100644--- a/app/src/video_buffer.c+++ b/app/src/video_buffer.c@@ -1,6 +1,6 @@#include "video_buffer.h"-#include <SDL2/SDL_assert.h>+#include <assert.h>#include <SDL2/SDL_mutex.h>#include <libavutil/avutil.h>#include <libavformat/avformat.h>@@ -91,7 +91,7 @@ video_buffer_offer_decoded_frame(struct video_buffer *vb,const AVFrame *video_buffer_consume_rendered_frame(struct video_buffer *vb) {- SDL_assert(!vb->rendering_frame_consumed);+ assert(!vb->rendering_frame_consumed);vb->rendering_frame_consumed = true;fps_counter_add_rendered_frame(vb->fps_counter);if (vb->render_expired_frames) {