[asterisk-commits] seanbright: branch group/asterisk-cpp r168399 - in /team/group/asterisk-cpp: ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jan 10 18:06:30 CST 2009
Author: seanbright
Date: Sat Jan 10 18:06:29 2009
New Revision: 168399
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168399
Log:
channel.c is mostly done, except for the ast_channel_tech madness.
Modified:
team/group/asterisk-cpp/include/asterisk/channel.h
team/group/asterisk-cpp/include/asterisk/frame.h
team/group/asterisk-cpp/main/channel.c
team/group/asterisk-cpp/main/frame.c
Modified: team/group/asterisk-cpp/include/asterisk/channel.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/channel.h?view=diff&rev=168399&r1=168398&r2=168399
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/channel.h (original)
+++ team/group/asterisk-cpp/include/asterisk/channel.h Sat Jan 10 18:06:29 2009
@@ -1269,7 +1269,7 @@
* Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in
*rf (remember, it could be NULL) and which channel (0 or 1) in rc */
/* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */
-int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,
+ast_bridge_result ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,
struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);
/*!
@@ -1319,7 +1319,7 @@
* See above
* Returns the text form of the binary transfer capability
*/
-char *ast_transfercapability2str(int transfercapability) attribute_const;
+const char *ast_transfercapability2str(int transfercapability) attribute_const;
/* Options: Some low-level drivers may implement "options" allowing fine tuning of the
low level channel. See frame.h for options. Note that many channel drivers may support
Modified: team/group/asterisk-cpp/include/asterisk/frame.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/frame.h?view=diff&rev=168399&r1=168398&r2=168399
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/frame.h (original)
+++ team/group/asterisk-cpp/include/asterisk/frame.h Sat Jan 10 18:06:29 2009
@@ -523,7 +523,7 @@
struct ast_format_list *ast_get_format_list_index(int index);
struct ast_format_list *ast_get_format_list(size_t *size);
-void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix);
+void ast_frame_dump(const char *name, struct ast_frame *f, const char *prefix);
/*! \page AudioCodecPref Audio Codec Preferences
Modified: team/group/asterisk-cpp/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/channel.c?view=diff&rev=168399&r1=168398&r2=168399
==============================================================================
--- team/group/asterisk-cpp/main/channel.c (original)
+++ team/group/asterisk-cpp/main/channel.c Sat Jan 10 18:06:29 2009
@@ -326,8 +326,8 @@
}
static struct ast_cli_entry cli_channel[] = {
- AST_CLI_DEFINE(handle_cli_core_show_channeltypes, "List available channel types"),
- AST_CLI_DEFINE(handle_cli_core_show_channeltype, "Give more details on that channel type")
+ ast_cli_entry(handle_cli_core_show_channeltypes, "List available channel types"),
+ ast_cli_entry(handle_cli_core_show_channeltype, "Give more details on that channel type")
};
#ifdef CHANNEL_TRACE
@@ -401,7 +401,7 @@
else
ast_log(LOG_DEBUG, "Changing trace context from %s to %s\n", AST_LIST_FIRST(&traced->trace)->context, chan->context);
/* alloc or bail out */
- trace = ast_malloc(sizeof(*trace));
+ trace = (struct ast_chan_trace *) ast_malloc(sizeof(*trace));
if (!trace)
return -1;
/* save the current location and store it in the trace list */
@@ -431,7 +431,7 @@
store = ast_datastore_alloc(&ast_chan_trace_datastore_info, "ChanTrace");
if (!store)
return -1;
- traced = ast_calloc(1, sizeof(*traced));
+ traced = (struct ast_chan_trace_data *) ast_calloc(1, sizeof(*traced));
if (!traced) {
ast_datastore_free(store);
return -1;
@@ -567,7 +567,7 @@
}
}
- if (!(chan = ast_calloc(1, sizeof(*chan)))) {
+ if (!(chan = (struct chanlist *) ast_calloc(1, sizeof(*chan)))) {
AST_RWLIST_UNLOCK(&channels);
return -1;
}
@@ -627,9 +627,7 @@
/*! \brief Gives the string form of a given hangup cause */
const char *ast_cause2str(int cause)
{
- int x;
-
- for (x = 0; x < ARRAY_LEN(causes); x++) {
+ for (size_t x = 0; x < ARRAY_LEN(causes); x++) {
if (causes[x].cause == cause)
return causes[x].desc;
}
@@ -640,9 +638,7 @@
/*! \brief Convert a symbolic hangup cause to number */
int ast_str2cause(const char *name)
{
- int x;
-
- for (x = 0; x < ARRAY_LEN(causes); x++)
+ for (size_t x = 0; x < ARRAY_LEN(causes); x++)
if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
return causes[x].cause;
@@ -678,7 +674,7 @@
case AST_STATE_PRERING:
return "Pre-ring";
default:
- if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
+ if (!(buf = (char *) ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
return "Unknown";
snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state);
return buf;
@@ -686,7 +682,7 @@
}
/*! \brief Gives the string form of a given transfer capability */
-char *ast_transfercapability2str(int transfercapability)
+const char *ast_transfercapability2str(int transfercapability)
{
switch (transfercapability) {
case AST_TRANS_CAP_SPEECH:
@@ -711,7 +707,6 @@
{
/* This just our opinion, expressed in code. We are asked to choose
the best codec to use, given no information */
- int x;
static const int prefs[] =
{
/*! Okay, ulaw is used by all telephony equipment, so start with it */
@@ -749,7 +744,7 @@
fmts &= AST_FORMAT_AUDIO_MASK;
/* Find the first preferred codec in the format given */
- for (x = 0; x < ARRAY_LEN(prefs); x++) {
+ for (size_t x = 0; x < ARRAY_LEN(prefs); x++) {
if (fmts & prefs[x])
return prefs[x];
}
@@ -760,8 +755,8 @@
}
static const struct ast_channel_tech null_tech = {
- .type = "NULL",
- .description = "Null channel (should not see this)",
+ .type = "NULL",
+ .description = "Null channel (should not see this)"
};
/*! \brief Create a new channel structure */
@@ -779,7 +774,7 @@
return NULL;
}
- if (!(tmp = ast_calloc(1, sizeof(*tmp))))
+ if (!(tmp = (struct ast_channel *) ast_calloc(1, sizeof(*tmp))))
return NULL;
if (!(tmp->sched = sched_context_create())) {
@@ -848,7 +843,7 @@
ast_string_field_set(tmp, name, "**Unknown**");
/* Initial state */
- tmp->_state = state;
+ tmp->_state = (ast_channel_state) state;
tmp->streamid = -1;
@@ -941,8 +936,8 @@
"AccountCode: %s\r\n"
"Uniqueid: %s\r\n",
tmp->name,
- state,
- ast_state2str(state),
+ (int) state,
+ ast_state2str((ast_channel_state) state),
S_OR(cid_num, ""),
S_OR(cid_name, ""),
tmp->accountcode,
@@ -1027,7 +1022,7 @@
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup(struct ast_channel *chan)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+ struct ast_frame f(AST_FRAME_CONTROL, AST_CONTROL_HANGUP);
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
chan->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -1039,7 +1034,7 @@
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
{
- struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+ struct ast_frame f(AST_FRAME_CONTROL, AST_CONTROL_HANGUP);
if (cause >= 0)
f.data.uint32 = cause;
@@ -1059,9 +1054,7 @@
/*! \brief Queue a control frame */
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
-
- f.subclass = control;
+ struct ast_frame f(AST_FRAME_CONTROL, control);
return ast_queue_frame(chan, &f);
}
@@ -1070,9 +1063,8 @@
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
const void *data, size_t datalen)
{
- struct ast_frame f = { AST_FRAME_CONTROL, };
-
- f.subclass = control;
+ struct ast_frame f(AST_FRAME_CONTROL, control);
+
f.data.ptr = (void *) data;
f.datalen = datalen;
@@ -1873,8 +1865,8 @@
} *fdmap = NULL;
if ((sz = n * AST_MAX_FDS + nfds)) {
- pfds = alloca(sizeof(*pfds) * sz);
- fdmap = alloca(sizeof(*fdmap) * sz);
+ pfds = (struct pollfd *) alloca(sizeof(*pfds) * sz);
+ fdmap = (struct fdmap *) alloca(sizeof(*fdmap) * sz);
}
if (outfd)
@@ -2704,7 +2696,7 @@
if (!chan->emulate_dtmf_duration) {
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
- } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
+ } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= (int) chan->emulate_dtmf_duration) {
chan->emulate_dtmf_duration = 0;
ast_frfree(f);
f = &chan->dtmff;
@@ -2737,7 +2729,7 @@
if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
struct timeval now = ast_tvnow();
- if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
+ if (ast_tvdiff_ms(now, chan->dtmf_tv) >= (int) chan->emulate_dtmf_duration) {
chan->emulate_dtmf_duration = 0;
ast_frfree(f);
f = &chan->dtmff;
@@ -2893,7 +2885,7 @@
{
/* By using an enum, we'll get compiler warnings for values not handled
* in switch statements. */
- enum ast_control_frame_type condition = _condition;
+ enum ast_control_frame_type condition = (ast_control_frame_type) _condition;
const struct ind_tone_zone_sound *ts = NULL;
int res = -1;
@@ -3102,13 +3094,12 @@
int ast_prod(struct ast_channel *chan)
{
- struct ast_frame a = { AST_FRAME_VOICE };
char nothing[128];
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
+ struct ast_frame a(AST_FRAME_VOICE, chan->rawwriteformat);
ast_debug(1, "Prodding channel '%s'\n", chan->name);
- a.subclass = chan->rawwriteformat;
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
if (ast_write(chan, &a))
@@ -3453,7 +3444,7 @@
}
ast_set_callerid(chan, cid_num, cid_name, cid_num);
- if (ast_call(chan, data, 0)) { /* ast_call failed... */
+ if (ast_call(chan, (char *) data, 0)) { /* ast_call failed... */
ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
} else {
res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
@@ -4049,7 +4040,7 @@
state of the original channel. */
origstate = original->_state;
original->_state = clonechan->_state;
- clonechan->_state = origstate;
+ clonechan->_state = (ast_channel_state) origstate;
if (clonechan->tech->fixup){
res = clonechan->tech->fixup(original, clonechan);
@@ -4074,7 +4065,7 @@
/* Update the type. */
t_pvt = original->monitor;
original->monitor = clonechan->monitor;
- clonechan->monitor = t_pvt;
+ clonechan->monitor = (struct ast_channel_monitor *) t_pvt;
/* Keep the same language. */
ast_string_field_set(original, language, clonechan->language);
@@ -4517,18 +4508,18 @@
if (c0->_bridge) {
ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
c0->name, c0->_bridge->name);
- return -1;
+ return AST_BRIDGE_FAILED;
}
if (c1->_bridge) {
ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
c1->name, c1->_bridge->name);
- return -1;
+ return AST_BRIDGE_FAILED;
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
- return -1;
+ return AST_BRIDGE_FAILED;
*fo = NULL;
firstpass = config->firstpass;
@@ -4606,7 +4597,7 @@
*fo = NULL;
if (who)
*rc = who;
- res = 0;
+ res = AST_BRIDGE_COMPLETE;
break;
}
@@ -4642,7 +4633,7 @@
*fo = NULL;
if (who)
*rc = who;
- res = 0;
+ res = AST_BRIDGE_COMPLETE;
ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
c0->name, c1->name,
ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
@@ -4818,7 +4809,7 @@
static void tonepair_release(struct ast_channel *chan, void *params)
{
- struct tonepair_state *ts = params;
+ struct tonepair_state *ts = (struct tonepair_state *) params;
if (chan)
ast_set_write_format(chan, ts->origwfmt);
@@ -4828,9 +4819,9 @@
static void *tonepair_alloc(struct ast_channel *chan, void *params)
{
struct tonepair_state *ts;
- struct tonepair_def *td = params;
-
- if (!(ts = ast_calloc(1, sizeof(*ts))))
+ struct tonepair_def *td = (struct tonepair_def *) params;
+
+ if (!(ts = (struct tonepair_state *) ast_calloc(1, sizeof(*ts))))
return NULL;
ts->origwfmt = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
@@ -4856,7 +4847,7 @@
static int tonepair_generator(struct ast_channel *chan, void *data, int len, int samples)
{
- struct tonepair_state *ts = data;
+ struct tonepair_state *ts = (struct tonepair_state *) data;
int x;
/* we need to prepare a frame with 16 * timelen samples as we're
@@ -4864,7 +4855,7 @@
*/
len = samples * 2;
- if (len > sizeof(ts->data) / 2 - 1) {
+ if (len > (int) sizeof(ts->data) / 2 - 1) {
ast_log(LOG_WARNING, "Can't generate that much data!\n");
return -1;
}
@@ -4902,9 +4893,10 @@
}
static struct ast_generator tonepair = {
- alloc: tonepair_alloc,
- release: tonepair_release,
- generate: tonepair_generator,
+ tonepair_alloc,
+ tonepair_release,
+ tonepair_generator,
+ NULL
};
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
@@ -5072,13 +5064,7 @@
static int silence_generator_generate(struct ast_channel *chan, void *data, int len, int samples)
{
short buf[samples];
- struct ast_frame frame = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
- .data.ptr = buf,
- .samples = samples,
- .datalen = sizeof(buf),
- };
+ struct ast_frame frame(AST_FRAME_VOICE, AST_FORMAT_SLINEAR, sizeof(buf), samples, (void *) buf);
memset(buf, 0, sizeof(buf));
@@ -5089,9 +5075,10 @@
}
static struct ast_generator silence_generator = {
- .alloc = silence_generator_alloc,
- .release = silence_generator_release,
- .generate = silence_generator_generate,
+ silence_generator_alloc,
+ silence_generator_release,
+ silence_generator_generate,
+ NULL
};
struct ast_silence_generator {
@@ -5102,7 +5089,7 @@
{
struct ast_silence_generator *state;
- if (!(state = ast_calloc(1, sizeof(*state)))) {
+ if (!(state = (struct ast_silence_generator *) ast_calloc(1, sizeof(*state)))) {
return NULL;
}
Modified: team/group/asterisk-cpp/main/frame.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/frame.c?view=diff&rev=168399&r1=168398&r2=168399
==============================================================================
--- team/group/asterisk-cpp/main/frame.c (original)
+++ team/group/asterisk-cpp/main/frame.c Sat Jan 10 18:06:29 2009
@@ -697,7 +697,7 @@
}
/*! Dump a frame for debugging purposes */
-void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
+void ast_frame_dump(const char *name, struct ast_frame *f, const char *prefix)
{
const char noname[] = "unknown";
char ftype[40] = "Unknown Frametype";
More information about the asterisk-commits
mailing list