mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
provide squeezelite error log in UI
This commit is contained in:
@@ -13,6 +13,7 @@ idf_component_register( SRC_DIRS . external ac101 tas57xx wm8978
|
||||
display
|
||||
tools
|
||||
audio
|
||||
_override
|
||||
EMBED_FILES vu_s.data arrow.data
|
||||
)
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "esp_wifi.h"
|
||||
#include "monitor.h"
|
||||
#include "platform_config.h"
|
||||
#include "messaging.h"
|
||||
|
||||
mutex_type slimp_mutex;
|
||||
static jmp_buf jumpbuf;
|
||||
@@ -29,6 +30,15 @@ _sig_func_ptr signal(int sig, _sig_func_ptr func) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void em_logprint(const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
vmessaging_post_message(MESSAGING_ERROR, MESSAGING_CLASS_SYSTEM, fmt, args);
|
||||
va_end(args);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
void *audio_calloc(size_t nmemb, size_t size) {
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
@@ -55,6 +65,7 @@ int embedded_init(void) {
|
||||
mutex_create(slimp_mutex);
|
||||
sb_controls_init();
|
||||
custom_player_id = sb_displayer_init() ? 100 : 101;
|
||||
|
||||
return setjmp(jumpbuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ extern u8_t custom_player_id;
|
||||
// to force some special buffer attribute
|
||||
#define EXT_BSS __attribute__((section(".ext_ram.bss")))
|
||||
|
||||
// otherwise just leave it empty
|
||||
void em_logprint(const char *fmt, ...);
|
||||
#define LOG_ERROR(fmt, ...) em_logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__);
|
||||
|
||||
// all exit() calls are made from main thread (or a function called in main thread)
|
||||
void embedded_exit(int code);
|
||||
#define exit(code) do { embedded_exit(code); } while (0)
|
||||
|
||||
@@ -275,7 +275,11 @@ static void sighandler(int signum) {
|
||||
signal(signum, SIG_DFL);
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED
|
||||
int main(int argc, char **argv) {
|
||||
#else
|
||||
int squeezelite_main(int argc, char **argv) {
|
||||
#endif
|
||||
char *server = NULL;
|
||||
char *output_device = "default";
|
||||
char *include_codecs = NULL;
|
||||
@@ -845,5 +849,5 @@ int main(int argc, char **argv) {
|
||||
free_ssl_symbols();
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -393,7 +393,6 @@ typedef enum { lERROR = 0, lWARN, lINFO, lDEBUG, lSDEBUG } log_level;
|
||||
const char *logtime(void);
|
||||
void logprint(const char *fmt, ...);
|
||||
|
||||
#define LOG_ERROR(fmt, ...) logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define LOG_WARN(fmt, ...) if (loglevel >= lWARN) logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define LOG_INFO(fmt, ...) if (loglevel >= lINFO) logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define LOG_DEBUG(fmt, ...) if (loglevel >= lDEBUG) logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
@@ -406,6 +405,10 @@ typedef int sockfd;
|
||||
#include "embedded.h"
|
||||
#endif
|
||||
|
||||
#ifndef LOG_ERROR
|
||||
#define LOG_ERROR(fmt, ...) logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if !defined(MSG_NOSIGNAL)
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
@@ -390,7 +390,7 @@ void stream_init(log_level level, unsigned stream_buf_size) {
|
||||
buf_init(streambuf, stream_buf_size);
|
||||
if (streambuf->buf == NULL) {
|
||||
LOG_ERROR("unable to malloc buffer");
|
||||
exit(0);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
#if USE_SSL
|
||||
@@ -401,7 +401,7 @@ void stream_init(log_level level, unsigned stream_buf_size) {
|
||||
SSLctx = SSL_CTX_new(SSLv23_client_method());
|
||||
if (SSLctx == NULL) {
|
||||
LOG_ERROR("unable to allocate SSL context");
|
||||
exit(0);
|
||||
exit(3);
|
||||
}
|
||||
SSL_CTX_set_options(SSLctx, SSL_OP_NO_SSLv2);
|
||||
#if !LINKALL && !NO_SSLSYM
|
||||
|
||||
Reference in New Issue
Block a user