@@ -161,6 +161,9 @@ int32_t get_num_physical_cores() {
161161 return n_threads > 0 ? (n_threads <= 4 ? n_threads : n_threads / 2 ) : 4 ;
162162}
163163
164+ static sd_progress_cb_t sd_progress_cb = NULL ;
165+ void * sd_progress_cb_data = NULL ;
166+
164167std::u32string utf8_to_utf32 (const std::string& utf8_str) {
165168 std::wstring_convert<std::codecvt_utf8<char32_t >, char32_t > converter;
166169 return converter.from_bytes (utf8_str);
@@ -205,6 +208,10 @@ std::string path_join(const std::string& p1, const std::string& p2) {
205208}
206209
207210void pretty_progress (int step, int steps, float time) {
211+ if (sd_progress_cb) {
212+ sd_progress_cb (step,steps,time, sd_progress_cb_data);
213+ return ;
214+ }
208215 if (step == 0 ) {
209216 return ;
210217 }
@@ -248,8 +255,9 @@ std::string trim(const std::string& s) {
248255 return rtrim (ltrim (s));
249256}
250257
251- static sd_log_cb_t sd_log_cb = NULL ;
252- void * sd_log_cb_data = NULL ;
258+ static sd_log_cb_t sd_log_cb = NULL ;
259+ void * sd_log_cb_data = NULL ;
260+
253261
254262#define LOG_BUFFER_SIZE 1024
255263
@@ -286,7 +294,10 @@ void sd_set_log_callback(sd_log_cb_t cb, void* data) {
286294 sd_log_cb = cb;
287295 sd_log_cb_data = data;
288296}
289-
297+ void sd_set_progress_callback (sd_progress_cb_t cb, void * data) {
298+ sd_progress_cb = cb;
299+ sd_progress_cb_data = data;
300+ }
290301const char * sd_get_system_info () {
291302 static char buffer[1024 ];
292303 std::stringstream ss;
0 commit comments