ref: 69a5eceea271b3cb64b415dca48f723c6d5d2d92
parent: 4559df4cef0fac5663bf70b002da3bf7d442baee
parent: c57d537b390a9ab296fdd66838df9603c106f5fb
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Sat Apr 22 14:23:51 EDT 2023
Merge pull request #108 from laamaa/bugfixes Bugfixes and performance improvements
--- a/audio.c
+++ b/audio.c
@@ -18,6 +18,9 @@
int m8_device_id = -1;
int devcount_in = 0; // audio input device count
+ // wait for system to initialize possible new audio devices
+ SDL_Delay(500);
+
devcount_in = SDL_GetNumAudioDevices(SDL_TRUE);
if (devcount_in < 1) {@@ -26,6 +29,7 @@
} else { for (i = 0; i < devcount_in; i++) {// Check if input device exists before doing anything else
+ SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, "%s", SDL_GetAudioDeviceName(i, SDL_TRUE));
if (SDL_strstr(SDL_GetAudioDeviceName(i, SDL_TRUE), "M8") != NULL) { SDL_Log("M8 Audio Input device found: %s",SDL_GetAudioDeviceName(i, SDL_TRUE));
--- a/fx_cube.c
+++ b/fx_cube.c
@@ -1,5 +1,6 @@
#include <SDL.h>
#include "SDL2_inprint.h"
+#include "SDL_pixels.h"
#define target_width 320
#define target_height 240
@@ -66,6 +67,8 @@
SDL_Texture *og_target = SDL_GetRenderTarget(fx_renderer);
SDL_SetRenderTarget(fx_renderer, texture_text);
+ SDL_SetRenderDrawColor(fx_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
+ SDL_RenderClear(fx_renderer);
inprint(fx_renderer, text_disconnected, 168, 230, 0xFFFFFF, 0x000000);
inprint(fx_renderer, text_m8c, 2, 2, 0xFFFFFF, 0x000000);
@@ -93,7 +96,7 @@
SDL_Texture *og_texture = SDL_GetRenderTarget(fx_renderer);
SDL_SetRenderTarget(fx_renderer, texture_cube);
- SDL_SetRenderDrawColor(fx_renderer, 0, 0, 0, 200);
+ SDL_SetRenderDrawColor(fx_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
SDL_RenderClear(fx_renderer);
int seconds = SDL_GetTicks() / 1000;
--- a/input.c
+++ b/input.c
@@ -4,6 +4,7 @@
#include <SDL.h>
#include <stdio.h>
+#include "SDL_timer.h"
#include "config.h"
#include "input.h"
#include "render.h"
@@ -392,8 +393,12 @@
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED)
{- SDL_Log("Resizing window...");- key = (input_msg_s){special, msg_reset_display};+ static uint32_t ticks_window_resized = 0;
+ if (SDL_GetTicks() - ticks_window_resized > 500) {+ SDL_Log("Resizing window...");+ key = (input_msg_s){special, msg_reset_display};+ ticks_window_resized = SDL_GetTicks();
+ }
}
break;
--- a/input.h
+++ b/input.h
@@ -5,6 +5,7 @@
#define INPUT_H_
#include <stdint.h>
+#include "config.h"
typedef enum input_buttons_t {INPUT_UP,
@@ -38,6 +39,6 @@
int initialize_game_controllers();
void close_game_controllers();
-input_msg_s get_input_msg();
+input_msg_s get_input_msg(config_params_s *conf);
-#endif
\ No newline at end of file
+#endif
--- a/main.c
+++ b/main.c
@@ -133,9 +133,10 @@
if (run == WAIT_FOR_DEVICE && init_serial(0) == 1) { if (conf.audio_enabled == 1) {- if (audio_init(conf.audio_buffer_size, conf.audio_device_name) == 0) {- SDL_Log("Cannot initialize audio, exiting.");- run = QUIT;
+ if (audio_init(conf.audio_buffer_size, conf.audio_device_name) ==
+ 0) {+ SDL_Log("Cannot initialize audio");+ conf.audio_enabled = 0;
}
}
@@ -251,6 +252,9 @@
port_inited = 0;
run = WAIT_FOR_DEVICE;
close_serial_port();
+ if (conf.audio_enabled == 1) {+ audio_destroy();
+ }
/* we'll make one more loop to see if the device is still there
* but just sending zero bytes. if it doesn't get detected when
* resetting the port, it will disconnect */
--
⑨