@@ -161,6 +161,9 @@ int32_t get_num_physical_cores() {
161
161
return n_threads > 0 ? (n_threads <= 4 ? n_threads : n_threads / 2 ) : 4 ;
162
162
}
163
163
164
+ static sd_progress_cb_t sd_progress_cb = NULL ;
165
+ void * sd_progress_cb_data = NULL ;
166
+
164
167
std::u32string utf8_to_utf32 (const std::string& utf8_str) {
165
168
std::wstring_convert<std::codecvt_utf8<char32_t >, char32_t > converter;
166
169
return converter.from_bytes (utf8_str);
@@ -205,6 +208,10 @@ std::string path_join(const std::string& p1, const std::string& p2) {
205
208
}
206
209
207
210
void 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
+ }
208
215
if (step == 0 ) {
209
216
return ;
210
217
}
@@ -248,8 +255,9 @@ std::string trim(const std::string& s) {
248
255
return rtrim (ltrim (s));
249
256
}
250
257
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
+
253
261
254
262
#define LOG_BUFFER_SIZE 1024
255
263
@@ -286,7 +294,10 @@ void sd_set_log_callback(sd_log_cb_t cb, void* data) {
286
294
sd_log_cb = cb;
287
295
sd_log_cb_data = data;
288
296
}
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
+ }
290
301
const char * sd_get_system_info () {
291
302
static char buffer[1024 ];
292
303
std::stringstream ss;
0 commit comments