| | |
| | | }; |
| | | |
| | | typedef void (*sd_log_cb_t)(enum sd_log_level_t level, const char* text, void* data); |
| | | typedef void (*sd_progress_cb_t)(int step,int steps,float time, void* data); |
| | | |
| | | SD_API void sd_set_log_callback(sd_log_cb_t sd_log_cb, void* data); |
| | | SD_API void sd_set_progress_callback(sd_progress_cb_t cb, void* data); |
| | | SD_API int32_t get_num_physical_cores(); |
| | | SD_API const char* sd_get_system_info(); |
| | | |
| | |
| | | return n_threads > 0 ? (n_threads <= 4 ? n_threads : n_threads / 2) : 4; |
| | | } |
| | | |
| | | static sd_progress_cb_t sd_progress_cb = NULL; |
| | | void* sd_progress_cb_data = NULL; |
| | | |
| | | std::u32string utf8_to_utf32(const std::string& utf8_str) { |
| | | std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter; |
| | | return converter.from_bytes(utf8_str); |
| | |
| | | |
| | | void pretty_progress(int step, int steps, float time) { |
| | | if (step == 0) { |
| | | return; |
| | | } |
| | | if (sd_progress_cb) { |
| | | sd_progress_cb(step,steps,time, sd_progress_cb_data); |
| | | return; |
| | | } |
| | | std::string progress = " |"; |
| | |
| | | sd_log_cb = cb; |
| | | sd_log_cb_data = data; |
| | | } |
| | | void sd_set_progress_callback(sd_progress_cb_t cb, void* data) { |
| | | sd_progress_cb = cb; |
| | | sd_progress_cb_data = data; |
| | | } |
| | | |
| | | const char* sd_get_system_info() { |
| | | static char buffer[1024]; |