[asterisk-commits] dvossel: branch dvossel/awesomehooks r287641 - in /team/dvossel/awesomehooks:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 20 16:26:47 CDT 2010
Author: dvossel
Date: Mon Sep 20 16:26:43 2010
New Revision: 287641
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287641
Log:
addresses latest round of reviewboard comments
Modified:
team/dvossel/awesomehooks/funcs/func_frame_trace.c
team/dvossel/awesomehooks/include/asterisk/framehook.h
team/dvossel/awesomehooks/main/framehook.c
Modified: team/dvossel/awesomehooks/funcs/func_frame_trace.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/funcs/func_frame_trace.c?view=diff&rev=287641&r1=287640&r2=287641
==============================================================================
--- team/dvossel/awesomehooks/funcs/func_frame_trace.c (original)
+++ team/dvossel/awesomehooks/funcs/func_frame_trace.c Mon Sep 20 16:26:43 2010
@@ -226,88 +226,88 @@
switch (frame->subclass.integer) {
case AST_CONTROL_HANGUP:
ast_verbose("SubClass: HANGUP\n");
- break;
+ break;
case AST_CONTROL_RING:
ast_verbose("SubClass: RING\n");
- break;
+ break;
case AST_CONTROL_RINGING:
ast_verbose("SubClass: RINGING\n");
- break;
+ break;
case AST_CONTROL_ANSWER:
ast_verbose("SubClass: ANSWER\n");
- break;
+ break;
case AST_CONTROL_BUSY:
ast_verbose("SubClass: BUSY\n");
- break;
+ break;
case AST_CONTROL_TAKEOFFHOOK:
ast_verbose("SubClass: TAKEOFFHOOK\n");
- break;
+ break;
case AST_CONTROL_OFFHOOK:
ast_verbose("SubClass: OFFHOOK\n");
- break;
+ break;
case AST_CONTROL_CONGESTION:
ast_verbose("SubClass: CONGESTION\n");
- break;
+ break;
case AST_CONTROL_FLASH:
ast_verbose("SubClass: FLASH\n");
- break;
+ break;
case AST_CONTROL_WINK:
ast_verbose("SubClass: WINK\n");
- break;
+ break;
case AST_CONTROL_OPTION:
ast_verbose("SubClass: OPTION\n");
- break;
+ break;
case AST_CONTROL_RADIO_KEY:
ast_verbose("SubClass: RADIO KEY\n");
- break;
+ break;
case AST_CONTROL_RADIO_UNKEY:
ast_verbose("SubClass: RADIO UNKEY\n");
- break;
+ break;
case AST_CONTROL_PROGRESS:
ast_verbose("SubClass: PROGRESS\n");
- break;
+ break;
case AST_CONTROL_PROCEEDING:
ast_verbose("SubClass: PROCEEDING\n");
- break;
+ break;
case AST_CONTROL_HOLD:
ast_verbose("SubClass: HOLD\n");
- break;
+ break;
case AST_CONTROL_UNHOLD:
ast_verbose("SubClass: UNHOLD\n");
- break;
+ break;
case AST_CONTROL_VIDUPDATE:
ast_verbose("SubClass: VIDUPDATE\n");
- break;
+ break;
case _XXX_AST_CONTROL_T38:
ast_verbose("SubClass: XXX T38\n");
- break;
+ break;
case AST_CONTROL_SRCUPDATE:
ast_verbose("SubClass: SRCUPDATE\n");
- break;
+ break;
case AST_CONTROL_TRANSFER:
ast_verbose("SubClass: TRANSFER\n");
- break;
+ break;
case AST_CONTROL_CONNECTED_LINE:
ast_verbose("SubClass: CONNECTED LINE\n");
- break;
+ break;
case AST_CONTROL_REDIRECTING:
ast_verbose("SubClass: REDIRECTING\n");
- break;
+ break;
case AST_CONTROL_T38_PARAMETERS:
ast_verbose("SubClass: T38 PARAMETERS\n");
- break;
+ break;
case AST_CONTROL_CC:
ast_verbose("SubClass: CC\n");
- break;
+ break;
case AST_CONTROL_SRCCHANGE:
ast_verbose("SubClass: SRCCHANGE\n");
- break;
+ break;
case AST_CONTROL_READ_ACTION:
ast_verbose("SubClass: READ ACTION\n");
- break;
+ break;
case AST_CONTROL_AOC:
ast_verbose("SubClass: AOC\n");
- break;
+ break;
default:
ast_verbose("SubClass: Unknown %d\n", frame->subclass.integer);
}
@@ -338,8 +338,6 @@
ast_verbose("FrameType: DTMF BEGIN\n");
ast_verbose("Digit: %d\n", frame->subclass.integer);
break;
- default:
- ast_verbose("FrameType: Unknown %d\n", frame->frametype);
}
ast_verbose("Src: %s\n", ast_strlen_zero(frame->src) ? "NOT PRESENT" : frame->src);
Modified: team/dvossel/awesomehooks/include/asterisk/framehook.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/include/asterisk/framehook.h?view=diff&rev=287641&r1=287640&r2=287641
==============================================================================
--- team/dvossel/awesomehooks/include/asterisk/framehook.h (original)
+++ team/dvossel/awesomehooks/include/asterisk/framehook.h Mon Sep 20 16:26:43 2010
@@ -107,7 +107,8 @@
return frame;
{
- int some_function() {
+ int some_function()
+ {
struct ast_framehook_interface interface = {
.version = AST_FRAMEHOOK_INTERFACE_VERSION,
.event_cb = hook_event_cb,
@@ -199,7 +200,7 @@
typedef void (*ast_framehook_destroy_callback)(void *data);
#define AST_FRAMEHOOK_INTERFACE_VERSION 1
-/* This interface is required for attaching a framehook to a channel. */
+/*! This interface is required for attaching a framehook to a channel. */
struct ast_framehook_interface {
/*! framehook interface version number */
uint16_t version;
@@ -208,7 +209,7 @@
/*! destroy_cb is optional. This function is called immediately before the framehook
* is destroyed to allow for stored_data cleanup. */
ast_framehook_destroy_callback destroy_cb;
- /*! This pointer can represent any custom data to be stored on the framehook. This
+ /*! This pointer can represent any custom data to be stored on the !framehook. This
* data pointer will be provided during each event callback which allows the framehook
* to store any stateful data associated with the application using the hook. */
void *data;
Modified: team/dvossel/awesomehooks/main/framehook.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/main/framehook.c?view=diff&rev=287641&r1=287640&r2=287641
==============================================================================
--- team/dvossel/awesomehooks/main/framehook.c (original)
+++ team/dvossel/awesomehooks/main/framehook.c Mon Sep 20 16:26:43 2010
@@ -33,19 +33,13 @@
#include "asterisk/frame.h"
struct ast_framehook {
- uint16_t version;
- /*! This pointer holds any stateful data an application wishes to store. */
- void *data;
+ struct ast_framehook_interface i;
/*! This pointer to ast_channel the framehook is attached to. */
struct ast_channel *chan;
/*! the id representing this framehook on a channel */
unsigned int id;
/*! when set, this signals the read and write function to detach the hook */
int detach_and_destroy_me;
- /*! Pointer to the registered event callback function. */
- ast_framehook_event_callback event_cb;
- /*! Pointer to the registered destruction callback function. */
- ast_framehook_destroy_callback destroy_cb;
/*! list entry for ast_framehook_list object */
AST_LIST_ENTRY(ast_framehook) list;
};
@@ -58,7 +52,7 @@
static void framehook_detach_and_destroy(struct ast_framehook *framehook)
{
struct ast_frame *frame;
- frame = framehook->event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_DETACHED, framehook->data);
+ frame = framehook->i.event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_DETACHED, framehook->i.data);
/* never assume anything about this function. If you can return a frame during
* the detached event, then assume someone will. */
if (frame) {
@@ -66,8 +60,8 @@
}
framehook->chan = NULL;
- if (framehook->destroy_cb) {
- framehook->destroy_cb(framehook->data);
+ if (framehook->i.destroy_cb) {
+ framehook->i.destroy_cb(framehook->i.data);
}
ast_free(framehook);
}
@@ -86,7 +80,7 @@
AST_LIST_REMOVE_CURRENT(list);
framehook_detach_and_destroy(framehook);
} else {
- frame = framehook->event_cb(framehook->chan, frame, event, framehook->data);
+ frame = framehook->i.event_cb(framehook->chan, frame, event, framehook->i.data);
}
}
AST_LIST_TRAVERSE_SAFE_END;
@@ -97,13 +91,15 @@
{
struct ast_framehook *framehook;
struct ast_frame *frame;
+ if (i->version != AST_FRAMEHOOK_INTERFACE_VERSION) {
+ ast_log(LOG_ERROR, "Version '%hu' of framehook interface not what we compiled against (%hu)\n",
+ i->version, AST_FRAMEHOOK_INTERFACE_VERSION);
+ return -1;
+ }
if (!i->event_cb || !(framehook = ast_calloc(1, sizeof(*framehook)))) {
return -1;
}
- framehook->version = i->version;
- framehook->event_cb = i->event_cb;
- framehook->destroy_cb = i->destroy_cb;
- framehook->data = i->data;
+ framehook->i = *i;
framehook->chan = chan;
/* create the framehook list if it didn't already exist */
@@ -116,7 +112,7 @@
AST_LIST_INSERT_TAIL(&chan->framehooks->list, framehook, list);
/* Tell the event callback we're live and rocking */
- frame = framehook->event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, framehook->data);
+ frame = framehook->i.event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, framehook->i.data);
/* Never assume anything about this function. If you can return a frame during
* the attached event, then assume someone will. */
More information about the asterisk-commits
mailing list