Lines Matching refs:impl
60 MppClockImpl *impl = mpp_calloc(MppClockImpl, 1); in mpp_clock_get() local
62 if (impl) { in mpp_clock_get()
63 impl->check = clock_name; in mpp_clock_get()
64 snprintf(impl->name, sizeof(impl->name) - 1, name, NULL); in mpp_clock_get()
68 return impl; in mpp_clock_get()
217 MppTimerImpl *impl = (MppTimerImpl *)ctx; in mpp_timer_thread() local
218 MppThread *thd = impl->thd; in mpp_timer_thread()
219 rk_s32 timer_fd = impl->timer_fd; in mpp_timer_thread()
223 ts.it_value.tv_sec = impl->initial / 1000; in mpp_timer_thread()
224 ts.it_value.tv_nsec = (impl->initial % 1000) * 1000; in mpp_timer_thread()
227 ts.it_interval.tv_sec = impl->interval / 1000; in mpp_timer_thread()
228 ts.it_interval.tv_nsec = (impl->interval % 1000) * 1000 * 1000; in mpp_timer_thread()
246 fd_cnt = epoll_wait(impl->epoll_fd, &events, 1, 500); in mpp_timer_thread()
252 impl->func(impl->ctx); in mpp_timer_thread()
261 MppTimerImpl *impl = NULL; in mpp_timer_get() local
268 impl = mpp_calloc(MppTimerImpl, 1); in mpp_timer_get()
269 if (!impl) { in mpp_timer_get()
289 impl->timer_fd = timer_fd; in mpp_timer_get()
290 impl->epoll_fd = epoll_fd; in mpp_timer_get()
292 impl->initial = 1000; in mpp_timer_get()
293 impl->interval = 1000; in mpp_timer_get()
294 impl->check = timer_name; in mpp_timer_get()
295 snprintf(impl->name, sizeof(impl->name) - 1, name, NULL); in mpp_timer_get()
297 return impl; in mpp_timer_get()
302 if (impl) { in mpp_timer_get()
303 mpp_free(impl); in mpp_timer_get()
304 impl = NULL; in mpp_timer_get()
322 MppTimerImpl *impl = (MppTimerImpl *)timer; in mpp_timer_set_callback() local
324 if (check_is_mpp_timer(impl)) { in mpp_timer_set_callback()
325 mpp_err_f("invalid timer %p\n", impl); in mpp_timer_set_callback()
334 impl->func = func; in mpp_timer_set_callback()
335 impl->ctx = ctx; in mpp_timer_set_callback()
340 MppTimerImpl *impl = (MppTimerImpl *)timer; in mpp_timer_set_timing() local
342 if (check_is_mpp_timer(impl)) { in mpp_timer_set_timing()
343 mpp_err_f("invalid timer %p\n", impl); in mpp_timer_set_timing()
347 impl->initial = initial; in mpp_timer_set_timing()
348 impl->interval = interval; in mpp_timer_set_timing()
353 MppTimerImpl *impl = (MppTimerImpl *)timer; in mpp_timer_set_enable() local
355 if (check_is_mpp_timer(impl)) { in mpp_timer_set_enable()
356 mpp_err_f("invalid timer %p\n", impl); in mpp_timer_set_enable()
360 if (!impl->func || impl->initial < 0 || impl->interval < 0) { in mpp_timer_set_enable()
362 impl->func, impl->initial, impl->interval); in mpp_timer_set_enable()
367 if (!impl->enabled && !impl->thd) { in mpp_timer_set_enable()
368 MppThread *thd = mpp_thread_create(mpp_timer_thread, impl, impl->name); in mpp_timer_set_enable()
371 impl->thd = thd; in mpp_timer_set_enable()
372 impl->enabled = 1; in mpp_timer_set_enable()
373 mpp_thread_start(impl->thd); in mpp_timer_set_enable()
377 if (impl->enabled && impl->thd) { in mpp_timer_set_enable()
378 mpp_thread_stop(impl->thd); in mpp_timer_set_enable()
379 impl->enabled = 0; in mpp_timer_set_enable()
386 MppTimerImpl *impl = (MppTimerImpl *)timer; in mpp_timer_put() local
388 if (check_is_mpp_timer(impl)) { in mpp_timer_put()
389 mpp_err_f("invalid timer %p\n", impl); in mpp_timer_put()
393 if (impl->enabled) in mpp_timer_put()
394 mpp_timer_set_enable(impl, 0); in mpp_timer_put()
396 if (impl->timer_fd >= 0) { in mpp_timer_put()
397 close(impl->timer_fd); in mpp_timer_put()
398 impl->timer_fd = -1; in mpp_timer_put()
401 if (impl->epoll_fd >= 0) { in mpp_timer_put()
402 close(impl->epoll_fd); in mpp_timer_put()
403 impl->epoll_fd = -1; in mpp_timer_put()
406 if (impl->thd) { in mpp_timer_put()
407 mpp_thread_destroy(impl->thd); in mpp_timer_put()
408 impl->thd = NULL; in mpp_timer_put()
411 if (impl) { in mpp_timer_put()
412 mpp_free(impl); in mpp_timer_put()
413 impl = NULL; in mpp_timer_put()
451 MppStopwatchImpl *impl = mpp_calloc(MppStopwatchImpl, 1); in mpp_stopwatch_get() local
454 if (impl && nodes) { in mpp_stopwatch_get()
455 impl->check = stopwatch_name; in mpp_stopwatch_get()
456 snprintf(impl->name, sizeof(impl->name) - 1, name, NULL); in mpp_stopwatch_get()
457 impl->nodes = nodes; in mpp_stopwatch_get()
458 impl->max_count = 8; in mpp_stopwatch_get()
461 MPP_FREE(impl); in mpp_stopwatch_get()
465 return impl; in mpp_stopwatch_get()
470 MppStopwatchImpl *impl = (MppStopwatchImpl *)stopwatch; in mpp_stopwatch_set_show_on_exit() local
472 if (check_is_mpp_stopwatch(impl)) { in mpp_stopwatch_set_show_on_exit()
473 mpp_err_f("invalid stopwatch %p\n", impl); in mpp_stopwatch_set_show_on_exit()
477 impl->show_on_exit = show_on_exit; in mpp_stopwatch_set_show_on_exit()
482 MppStopwatchImpl *impl = (MppStopwatchImpl *)stopwatch; in mpp_stopwatch_record() local
485 if (!impl) in mpp_stopwatch_record()
488 if (check_is_mpp_stopwatch(impl)) { in mpp_stopwatch_record()
489 mpp_err_f("invalid stopwatch %p on %s\n", impl, event); in mpp_stopwatch_record()
493 if (impl->filled_count >= impl->max_count) { in mpp_stopwatch_record()
494 rk_s32 max_count = impl->max_count * 2; in mpp_stopwatch_record()
495 MppStopwatchNode *nodes = mpp_realloc(impl->nodes, MppStopwatchNode, in mpp_stopwatch_record()
499 impl->nodes = nodes; in mpp_stopwatch_record()
500 impl->max_count = max_count; in mpp_stopwatch_record()
504 if (impl->filled_count < impl->max_count) { in mpp_stopwatch_record()
505 MppStopwatchNode *node = impl->nodes + impl->filled_count; in mpp_stopwatch_record()
511 if (len > impl->log_len) in mpp_stopwatch_record()
512 impl->log_len = len; in mpp_stopwatch_record()
514 impl->filled_count++; in mpp_stopwatch_record()
520 MppStopwatchImpl *impl = (MppStopwatchImpl *)stopwatch; in mpp_stopwatch_put() local
522 if (check_is_mpp_stopwatch(impl)) { in mpp_stopwatch_put()
523 mpp_err_f("invalid stopwatch %p\n", impl); in mpp_stopwatch_put()
527 if (impl->show_on_exit && impl->nodes && impl->filled_count) { in mpp_stopwatch_put()
528 MppStopwatchNode *node = impl->nodes; in mpp_stopwatch_put()
533 snprintf(fmt, sizeof(fmt) - 1, "%%s %%-%ds: %%6.2f\n", impl->log_len); in mpp_stopwatch_put()
536 for (i = 1; i < impl->filled_count; i++) { in mpp_stopwatch_put()
537 mpp_log(fmt, impl->name, node->event, in mpp_stopwatch_put()
543 MPP_FREE(impl->nodes); in mpp_stopwatch_put()
544 MPP_FREE(impl); in mpp_stopwatch_put()
549 MppStopwatchImpl *impl = (MppStopwatchImpl *)stopwatch; in mpp_stopwatch_elapsed_time() local
551 if (check_is_mpp_stopwatch(impl)) { in mpp_stopwatch_elapsed_time()
552 mpp_err_f("invalid stopwatch %p\n", impl); in mpp_stopwatch_elapsed_time()
556 if (impl->filled_count < 2) in mpp_stopwatch_elapsed_time()
559 rk_s64 base_time = impl->nodes[0].time; in mpp_stopwatch_elapsed_time()
560 rk_s64 curr_time = impl->nodes[impl->filled_count - 1].time; in mpp_stopwatch_elapsed_time()