Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Timing source management. More...
Go to the source code of this file.
Data Structures | |
struct | ast_timing_interface |
Timing module interface. More... | |
Macros | |
#define | ast_register_timing_interface(i) _ast_register_timing_interface(i, AST_MODULE_SELF) |
Register a set of timing functions. More... | |
Enumerations | |
enum | ast_timer_event { AST_TIMING_EVENT_EXPIRED = 1 , AST_TIMING_EVENT_CONTINUOUS = 2 } |
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_unregister_timing_interface (void *handle) |
Unregister a previously registered timing interface. More... | |
Timing source management.
Portions of Asterisk require a timing source, a periodic trigger for media handling activities. The functions in this file allow a loadable module to provide a timing source for Asterisk and its modules, so that those modules can request a 'timing handle' when they require one. These handles are file descriptors, which can be used with select() or poll().
The timing source used by Asterisk must provide the following features:
1) Periodic triggers, with a configurable interval (specified as number of triggers per second).
2) Multiple outstanding triggers, each of which must be 'acked' to clear it. Triggers must also be 'ackable' in quantity.
3) Continuous trigger mode, which when enabled causes every call to poll() on the timer handle to immediately return.
4) Multiple 'event types', so that the code using the timer can know whether the wakeup it received was due to a periodic trigger or a continuous trigger.
Definition in file timing.h.
#define ast_register_timing_interface | ( | i | ) | _ast_register_timing_interface(i, AST_MODULE_SELF) |
Register a set of timing functions.
i | An instance of the ast_timing_interfaces structure with pointers to the functions provided by the timing implementation. |
NULL | failure |
non-Null | handle to be passed to ast_unregister_timing_interface() on success |
enum ast_timer_event |
Enumerator | |
---|---|
AST_TIMING_EVENT_EXPIRED | |
AST_TIMING_EVENT_CONTINUOUS |
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_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().