Asterisk - The Open Source Telephony Project GIT-master-d5a0626
|
Timing source management. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/timing.h"
#include "asterisk/lock.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/time.h"
#include "asterisk/heap.h"
#include "asterisk/module.h"
#include "asterisk/poll-compat.h"
Go to the source code of this file.
Data Structures | |
struct | ast_timer |
struct | timing_holder |
Functions | |
void * | _ast_register_timing_interface (struct ast_timing_interface *funcs, struct ast_module *mod) |
int | ast_timer_ack (const struct ast_timer *handle, unsigned int quantity) |
Acknowledge a timer event. More... | |
void | ast_timer_close (struct ast_timer *handle) |
Close an opened timing handle. More... | |
int | ast_timer_disable_continuous (const struct ast_timer *handle) |
Disable continuous mode. More... | |
int | ast_timer_enable_continuous (const struct ast_timer *handle) |
Enable continuous mode. More... | |
int | ast_timer_fd (const struct ast_timer *handle) |
Get a poll()-able file descriptor for a timer. More... | |
enum ast_timer_event | ast_timer_get_event (const struct ast_timer *handle) |
Retrieve timing event. More... | |
unsigned int | ast_timer_get_max_rate (const struct ast_timer *handle) |
Get maximum rate supported for a timer. More... | |
const char * | ast_timer_get_name (const struct ast_timer *handle) |
Get name of timer in use. More... | |
struct ast_timer * | ast_timer_open (void) |
Open a timer. More... | |
int | ast_timer_set_rate (const struct ast_timer *handle, unsigned int rate) |
Set the timing tick rate. More... | |
int | ast_timing_init (void) |
int | ast_unregister_timing_interface (void *handle) |
Unregister a previously registered timing interface. More... | |
static int | timing_holder_cmp (void *_h1, void *_h2) |
static void | timing_shutdown (void) |
static char * | timing_test (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
Variables | |
static struct ast_cli_entry | cli_timing [] |
static struct ast_heap * | timing_interfaces |
Timing source management.
Definition in file timing.c.
void * _ast_register_timing_interface | ( | struct ast_timing_interface * | funcs, |
struct ast_module * | mod | ||
) |
Definition at line 73 of file timing.c.
References ast_calloc, ast_heap_push, ast_heap_unlock, ast_heap_wrlock, timing_holder::iface, timing_holder::mod, NULL, ast_timing_interface::timer_ack, ast_timing_interface::timer_close, ast_timing_interface::timer_disable_continuous, ast_timing_interface::timer_enable_continuous, ast_timing_interface::timer_fd, ast_timing_interface::timer_get_event, ast_timing_interface::timer_get_max_rate, ast_timing_interface::timer_open, ast_timing_interface::timer_set_rate, and timing_interfaces.
int ast_timer_ack | ( | const struct ast_timer * | handle, |
unsigned int | quantity | ||
) |
Acknowledge a timer event.
handle | timer handle returned from timer_open() |
quantity | number of timer events to acknowledge |
-1 | failure, with errno set |
0 | success |
Definition at line 171 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_ack.
Referenced by __ast_read(), hook_event_cb(), monmp3thread(), snoop_read(), softmix_mixing_loop(), spandsp_fax_read(), timing_read(), and timing_test().
void ast_timer_close | ( | struct ast_timer * | handle | ) |
Close an opened timing handle.
handle | timer handle returned from timer_open() |
Definition at line 154 of file timing.c.
References ast_free, ast_module_unref, ast_timer::data, ast_timer::holder, timing_holder::iface, timing_holder::mod, and ast_timing_interface::timer_close.
Referenced by __unload_module(), ast_channel_destructor(), init_app_class(), jb_framedata_destroy(), load_module(), local_ast_moh_start(), moh_class_destructor(), session_destroy(), snoop_destroy(), softmix_bridge_data_destroy(), and timing_test().
int ast_timer_disable_continuous | ( | const struct ast_timer * | handle | ) |
Disable continuous mode.
handle | timer handle returned from timer_close() |
-1 | failure, with errno set |
0 | success |
Definition at line 181 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_disable_continuous.
Referenced by __ast_read().
int ast_timer_enable_continuous | ( | const struct ast_timer * | handle | ) |
Enable continuous mode.
handle | timer handle returned from timer_open() |
Continuous mode causes poll() on the timer's fd to immediately return always until continuous mode is disabled.
-1 | failure, with errno set |
0 | success |
Definition at line 176 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_enable_continuous.
Referenced by __ast_queue_frame().
int ast_timer_fd | ( | const struct ast_timer * | handle | ) |
Get a poll()-able file descriptor for a timer.
handle | timer handle returned from timer_open() |
Definition at line 161 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_fd.
Referenced by __ast_channel_alloc_ap(), jb_framedata_init(), monmp3thread(), network_thread(), softmix_mixing_loop(), spandsp_fax_new(), stasis_app_control_snoop(), and timing_test().
enum ast_timer_event ast_timer_get_event | ( | const struct ast_timer * | handle | ) |
Retrieve timing event.
handle | timer handle returned by timer_open() |
After poll() indicates that there is input on the timer's fd, this will be called to find out what triggered it.
Definition at line 186 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_get_event.
Referenced by __ast_read().
unsigned int ast_timer_get_max_rate | ( | const struct ast_timer * | handle | ) |
Get maximum rate supported for a timer.
handle | timer handle returned by timer_open() |
Definition at line 191 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_get_max_rate.
Referenced by ast_settimeout_full().
const char * ast_timer_get_name | ( | const struct ast_timer * | handle | ) |
Get name of timer in use.
handle | timer handle returned by timer_open() |
Definition at line 196 of file timing.c.
References ast_timer::holder, timing_holder::iface, and ast_timing_interface::name.
Referenced by __ast_channel_alloc_ap().
struct ast_timer * ast_timer_open | ( | void | ) |
Open a timer.
NULL | on error, with errno set |
non-NULL | timer handle on success |
Definition at line 122 of file timing.c.
References ast_calloc, ast_heap_peek(), ast_heap_rdlock, ast_heap_unlock, ast_module_running_ref, ast_module_unref, ast_timer::data, ast_timer::holder, timing_holder::iface, timing_holder::mod, NULL, ast_timing_interface::timer_close, ast_timing_interface::timer_open, and timing_interfaces.
Referenced by __ast_channel_alloc_ap(), init_app_class(), jb_framedata_init(), load_module(), local_ast_moh_start(), softmix_bridge_create(), spandsp_fax_new(), stasis_app_control_snoop(), and timing_test().
int ast_timer_set_rate | ( | const struct ast_timer * | handle, |
unsigned int | rate | ||
) |
Set the timing tick rate.
handle | timer handle returned from timer_open() |
rate | ticks per second, 0 turns the ticks off if needed |
Use this function if you want the timer to show input at a certain rate. The other alternative use of a timer is the continuous mode.
-1 | error, with errno set |
0 | success |
Definition at line 166 of file timing.c.
References ast_timer::data, ast_timer::holder, timing_holder::iface, and ast_timing_interface::timer_set_rate.
Referenced by __ast_read(), ast_deactivate_generator(), ast_settimeout_full(), hook_event_cb(), init_app_class(), jb_framedata_init(), load_module(), local_ast_moh_start(), set_config(), softmix_mixing_loop(), spandsp_fax_start(), stasis_app_control_snoop(), and timing_test().
int ast_timing_init | ( | void | ) |
Provided by timing.c
Definition at line 289 of file timing.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_heap_create, ast_register_cleanup(), cli_timing, timing_holder_cmp(), timing_interfaces, and timing_shutdown().
Referenced by asterisk_daemon().
int ast_unregister_timing_interface | ( | void * | handle | ) |
Unregister a previously registered timing interface.
handle | The handle returned from a prior successful call to ast_register_timing_interface(). |
0 | success |
non-zero | failure |
Definition at line 104 of file timing.c.
References ast_free, ast_heap_remove(), ast_heap_unlock, ast_heap_wrlock, NULL, and timing_interfaces.
Referenced by unload_module().
|
static |
Definition at line 59 of file timing.c.
References timing_holder::iface, and ast_timing_interface::priority.
Referenced by ast_timing_init().
|
static |
Definition at line 281 of file timing.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), ast_heap_destroy(), cli_timing, NULL, and timing_interfaces.
Referenced by ast_timing_init().
|
static |
Definition at line 201 of file timing.c.
References a, ast_cli(), ast_poll, ast_timer_ack(), ast_timer_close(), ast_timer_fd(), ast_timer_open(), ast_timer_set_rate(), ast_tvdiff_ms(), ast_tvnow(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, end, errno, ast_timer::holder, timing_holder::iface, ast_timing_interface::name, NULL, timer, and ast_cli_entry::usage.
|
static |
Definition at line 277 of file timing.c.
Referenced by ast_timing_init(), and timing_shutdown().
|
static |
Definition at line 52 of file timing.c.
Referenced by _ast_register_timing_interface(), ast_timer_open(), ast_timing_init(), ast_unregister_timing_interface(), and timing_shutdown().