From c13d601fb4bb03ad7b60942d4dec600a5f85c251 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 8 Jul 2005 21:14:34 +0000 Subject: queue device state changes and handle them serially in a background thread optimize device state related functions add ast_get_channel_by_name_prefix to allow searching for matching channels in O(1) operation git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6062 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/channel.h | 45 +++++++++--------------------------------- include/asterisk/linkedlists.h | 6 ++++-- include/asterisk/pbx.h | 23 ++------------------- 3 files changed, 15 insertions(+), 59 deletions(-) (limited to 'include') diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 817d3cc97..9380d7884 100755 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -444,21 +444,6 @@ struct outgoing_helper { /*! Do not transmit voice data */ #define AST_STATE_MUTE (1 << 16) -/*! Device is valid but channel didn't know state */ -#define AST_DEVICE_UNKNOWN 0 -/*! Device is not used */ -#define AST_DEVICE_NOT_INUSE 1 -/*! Device is in use */ -#define AST_DEVICE_INUSE 2 -/*! Device is busy */ -#define AST_DEVICE_BUSY 3 -/*! Device is invalid */ -#define AST_DEVICE_INVALID 4 -/*! Device is unavailable */ -#define AST_DEVICE_UNAVAILABLE 5 -/*! Device is ringing */ -#define AST_DEVICE_RINGING 6 - /*! Create a channel structure */ /*! Returns NULL on failure to allocate. New channels are by default set to the "default" context and @@ -494,27 +479,6 @@ void ast_channel_free(struct ast_channel *); */ struct ast_channel *ast_request(const char *type, int format, void *data, int *status); -/*! Search the Channels by Name */ -/*! - * \param device like a dialstring - * Search the Device in active channels by compare the channelname against - * the devicename. Compared are only the first chars to the first '-' char. - * Returns an AST_DEVICE_UNKNOWN if no channel found or - * AST_DEVICE_INUSE if a channel is found - */ -int ast_parse_device_state(char *device); - -/*! Asks a channel for device state */ -/*! - * \param device like a dialstring - * Asks a channel for device state, data is normaly a number from dialstring - * used by the low level module - * Trys the channel devicestate callback if not supported search in the - * active channels list for the device. - * Returns an AST_DEVICE_??? state -1 on failure - */ -int ast_device_state(char *device); - /*! * \param type type of channel to request * \param format requested channel format @@ -545,6 +509,12 @@ int ast_channel_register(const struct ast_channel_tech *tech); */ void ast_channel_unregister(const struct ast_channel_tech *tech); +/*! Get a channel technology structure by name + * \param name name of technology to find + * \return a pointer to the structure, or NULL if no matching technology found + */ +const struct ast_channel_tech *ast_get_channel_tech(const char *name); + /*! Hang up a channel */ /*! * \param chan channel to hang up @@ -759,6 +729,9 @@ struct ast_channel *ast_channel_walk_locked(const struct ast_channel *prev); /*! Get channel by name (locks channel) */ struct ast_channel *ast_get_channel_by_name_locked(const char *chan); +/*! Get channel by name prefix (locks channel) */ +struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, const int namelen); + /*! Waits for a digit */ /*! * \param c channel to wait for a digit on diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 9f5f216fd..b4085d7b9 100755 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -306,11 +306,13 @@ struct { \ used to link entries of this list together. Removes the head entry from the list, and returns a pointer to it. The - forward-link pointer in the returned entry is \b not cleared. + forward-link pointer in the returned entry is \b not cleared. This macro + is safe to call on an empty list. */ #define AST_LIST_REMOVE_HEAD(head, field) ({ \ typeof((head)->first) cur = (head)->first; \ - (head)->first = (head)->first->field.next; \ + if (cur) \ + (head)->first = cur->field.next; \ cur; \ }) diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index b0f92b60a..187372dcb 100755 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -51,8 +51,6 @@ struct ast_sw; typedef int (*ast_state_cb_type)(char *context, char* id, int state, void *data); -typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data); - /*! Data structure associated with a custom function */ struct ast_custom_function { char *name; @@ -253,16 +251,6 @@ int ast_unregister_application(const char *app); */ int ast_extension_state(struct ast_channel *c, char *context, char *exten); -/*! Tells Asterisk the State for Device is changed */ -/*! - * \param fmt devicename like a dialstring with format parameters - * Asterisk polls the new extensionstates and calls the registered - * callbacks for the changed extensions - * Returns 0 on success, -1 on failure - */ -int ast_device_state_changed(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); - /*! Registers a state change callback */ /*! * \param context which context to look in @@ -275,15 +263,6 @@ int ast_device_state_changed(const char *fmt, ...) int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type callback, void *data); -/*! Registers a device state change 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); -void ast_devstate_del(ast_devstate_cb_type callback, void *data); - /*! Deletes a registered state change callback by ID */ /*! * \param id of the callback to delete @@ -629,6 +608,8 @@ char *ast_func_read(struct ast_channel *chan, const char *in, char *workspace, s */ void ast_func_write(struct ast_channel *chan, const char *in, const char *value); +void ast_hint_state_changed(const char *device); + #if defined(__cplusplus) || defined(c_plusplus) } #endif -- cgit v1.2.3