aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/devicestate.h
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-01 23:34:43 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-01 23:34:43 +0000
commit8452527230d6c4c9e85686eb2cf6bf9a33f2e19b (patch)
treeca2f21d45b7f24e39079d1aec0006a66cad40dec /include/asterisk/devicestate.h
parentf576c0719efeb491624a56a19c52a80dd4baa07a (diff)
Merge major changes to the way device state is passed around Asterisk. The two
places that cared about device states were app_queue and the hint code in pbx.c. The changes include converting it to use the Asterisk event system, as well as other efficiency improvements. * app_queue: This module used to register a callback into devicestate.c to monitor device state changes. Now, it is just a subscriber to Asterisk events with the type, device state. * pbx.c hints: Previously, the device state processing thread in devicestate.c would call ast_hint_state_changed() each time the state of a device changed. Then, that code would go looking for all the hints that monitor that device, and call their callbacks. All of this blocked the device state processing thread. Now, the hint code is a subscriber of Asterisk events with the type, device state. Furthermore, when this code receives a device state change event, it queues it up to be processed by another thread so that it doesn't block one of the event processing threads. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@66958 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/devicestate.h')
-rw-r--r--include/asterisk/devicestate.h40
1 files changed, 17 insertions, 23 deletions
diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h
index dd7b939be..b13547a16 100644
--- a/include/asterisk/devicestate.h
+++ b/include/asterisk/devicestate.h
@@ -19,6 +19,18 @@
/*! \file
* \brief Device state management
*
+ * To subscribe to device state changes, use the generic ast_event_subscribe
+ * method. For an example, see apps/app_queue.c.
+ *
+ * \todo Currently, when the state of a device changes, the device state provider
+ * calls one of the functions defined here to queue an object to say that the
+ * state of a device has changed. However, this does not include the new state.
+ * Another thread processes these device state change objects and calls the
+ * device state provider's callback to figure out what the new state is. It
+ * would make a lot more sense for the new state to be included in the original
+ * function call that says the state of a device has changed. However, it
+ * will take a lot of work to change this.
+ *
* \arg See \ref AstExtState
*/
@@ -29,7 +41,11 @@
extern "C" {
#endif
-/*! Device States */
+/*! Device States
+ * \note The order of these states may not change because they are included
+ * in Asterisk events which may be transmitted across the network to
+ * other servers.
+ */
enum ast_device_state {
AST_DEVICE_UNKNOWN, /*!< Device is valid but channel didn't know state */
AST_DEVICE_NOT_INUSE, /*!< Device is not used */
@@ -42,9 +58,6 @@ enum ast_device_state {
AST_DEVICE_ONHOLD, /*!< Device is on hold */
};
-/*! \brief Devicestate watcher call back */
-typedef int (*ast_devstate_cb_type)(const char *dev, enum ast_device_state state, void *data);
-
/*! \brief Devicestate provider call back */
typedef enum ast_device_state (*ast_devstate_prov_cb_type)(const char *data);
@@ -93,7 +106,6 @@ enum ast_device_state ast_device_state(const char *device);
int ast_device_state_changed(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
-
/*! \brief Tells Asterisk the State for Device is changed
* \param device devicename like a dialstring
* Asterisk polls the new extensionstates and calls the registered
@@ -102,22 +114,6 @@ int ast_device_state_changed(const char *fmt, ...)
*/
int ast_device_state_changed_literal(const char *device);
-/*! \brief Registers a device state change callback
- * \param callback Callback
- * \param data to pass to callback
- * The callback is called if the state for extension is changed
- * Return -1 on failure, ID on success
- */
-int ast_devstate_add(ast_devstate_cb_type callback, void *data);
-
-/*! \brief Unregisters a device state change callback
- * \param callback Callback
- * \param data to pass to callback
- * The callback is called if the state for extension is changed
- * Return -1 on failure, ID on success
- */
-void ast_devstate_del(ast_devstate_cb_type callback, void *data);
-
/*! \brief Add device state provider
* \param label to use in hint, like label:object
* \param callback Callback
@@ -132,8 +128,6 @@ int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
*/
int ast_devstate_prov_del(const char *label);
-int ast_device_state_engine_init(void);
-
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif