[asterisk-commits] oej: branch group/pinequeue r306253 - in /team/group/pinequeue: apps/ main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Feb 4 04:47:40 CST 2011
Author: oej
Date: Fri Feb 4 04:47:33 2011
New Revision: 306253
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=306253
Log:
Fix a few outstanding issues.
Note to myself: Do not try to read data from de-allocated structures.
You will get random results...
Modified:
team/group/pinequeue/apps/app_queue.c
team/group/pinequeue/main/channel.c
team/group/pinequeue/main/file.c
team/group/pinequeue/res/res_musiconhold.c
Modified: team/group/pinequeue/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pinequeue/apps/app_queue.c?view=diff&rev=306253&r1=306252&r2=306253
==============================================================================
--- team/group/pinequeue/apps/app_queue.c (original)
+++ team/group/pinequeue/apps/app_queue.c Fri Feb 4 04:47:33 2011
@@ -1915,7 +1915,7 @@
}
}
if (avgholdsecs >= 1) {
- res = ast_say_number(qe->chan, avgholdmins > 1 ? avgholdsecs : avgholdmins * 60 + avgholdsecs, AST_DIGIT_ANY, qe->chan->language, NULL);
+ res = ast_say_number(qe->chan, avgholdsecs, AST_DIGIT_ANY, qe->chan->language, NULL);
if (res)
goto playout;
@@ -2567,7 +2567,9 @@
watchers[0] = in;
start = NULL;
- play_file(qe->chan, NULL, 0, qe->moh);
+ if (background_prompts) {
+ play_file(qe->chan, NULL, 0, qe->moh);
+ }
for (retry = 0; retry < 2; retry++) {
numlines = 0;
@@ -2898,6 +2900,9 @@
*reason = QUEUE_TIMEOUT;
break;
}
+ if (background_prompts) {
+ play_file(qe->chan, NULL, 0, qe->moh);
+ }
/* If we are going to exit due to a leavewhenempty condition, we should
* actually attempt to keep the caller in the queue until we have
@@ -3453,8 +3458,7 @@
AST_LIST_LOCK(dialed_interfaces);
AST_LIST_TRAVERSE(dialed_interfaces, di, list) {
if (!strcasecmp(cur->interface, di->interface)) {
- ast_log(LOG_DEBUG, "Skipping dialing interface '%s' since it has already been dialed\n",
- di->interface);
+ ast_debug(3, "Skipping dialing interface '%s' since it has already been dialed\n", di->interface);
break;
}
}
@@ -3865,8 +3869,7 @@
}
if (!ast_strlen_zero(gosubexec)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "app_queue: gosub=%s.\n", gosubexec);
+ ast_debug(1, "app_queue: gosub=%s.\n", gosubexec);
res = ast_autoservice_start(qe->chan);
if (res) {
ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n");
@@ -4728,38 +4731,40 @@
{
struct gen_state *state = params;
- if (option_debug > 3) {
- ast_log(LOG_DEBUG, "--- Allocating generator for %s\n", chan->name);
- }
+ ast_debug(3, "--- Allocating generator for %s\n", chan->name);
return state;
}
/*! \brief Close file stream used by generator */
static void gen_closestream(struct gen_state *state)
{
- if (!state->stream)
+ if (!state->stream) {
+ ast_debug(3, "--- No active stream to close.\n");
return;
+ }
ast_closestream(state->stream);
- ast_log(LOG_DEBUG, " --- Closing stream -- Filename %s\n", state->filename);
state->filename[0] = '\0';
state->chan->stream = NULL;
state->stream = NULL;
state->aqsi->now_playing = 0; /* Important flag to indicate we are no longer playing on this channel */
- if (state->chan->moh) {
- ast_log(LOG_DEBUG, "--- Restarting MOH --\n");
- if (state->aqsi->ringing) {
- ast_indicate(qe->chan, AST_CONTROL_RINGING);
- } else {
- ast_moh_start(state->chan, state->aqsi->moh, NULL);
- }
- }
+ //ast_log(LOG_DEBUG, "--- Restarting MOH --\n");
+ //if (state->aqsi->ringing) {
+ //ast_indicate(state->chan, AST_CONTROL_RINGING);
+ //} else if (state->aqsi->moh) {
+ //ast_moh_start(state->chan, state->aqsi->moh, NULL);
+ //}
}
/*! \brief Release generator on channel */
static void gen_release(struct ast_channel *chan, void *data)
{
struct gen_state *state = data;
+ ast_debug(3, "--- releasing stream \n");
+ if (!data) {
+ ast_debug(3, "--- No state??? \n");
+ return;
+ }
gen_closestream(state);
ast_free(state);
}
@@ -4770,9 +4775,7 @@
{
struct ast_frame *f = NULL;
if (state && state->chan) {
- if (option_debug > 4) {
- ast_log(LOG_DEBUG, "... Generating frames for %s\n", state->chan->name);
- }
+ ast_debug(3, "... Generating frames for %s\n", state->chan->name);
} else {
ast_log(LOG_ERROR, "... no channel to generate frames for!\n");
return f;
@@ -4803,6 +4806,8 @@
struct ast_frame *f = NULL;
int res = 0;
+ ast_debug(2, "***** Generating good old prompts for your benefit. Did I hear a thank you?\n");
+
if (!state) {
ast_log(LOG_ERROR, "---- Do not have a current state data structure\n");
return -1;
@@ -4813,18 +4818,21 @@
}
state->sample_queue += samples;
+ ast_debug(3, "--------->>>>> Generating %d samples - sample queue now %d channel %s\n", samples, state->sample_queue, chan->name);
while (state->sample_queue > 0) {
- if (!(f = gen_readframe(state)))
+ if (!(f = gen_readframe(state))) {
+ ast_debug(3, "---- :-( Could not get more frames\n");
return -1;
+ }
res = ast_write(chan, f);
+ state->sample_queue -= f->samples;
ast_frfree(f);
if (res < 0) {
ast_log(LOG_WARNING, "Failed to write frame: %s\n", strerror(errno));
return -1;
}
- state->sample_queue -= f->samples;
}
return res;
@@ -4859,6 +4867,7 @@
struct gen_state *generatordata;
struct ast_queue_streamfile_name *sfn = NULL;
char playfilename[512];
+
if (!background_prompts) {
if (ast_strlen_zero(filename)) {
@@ -4871,8 +4880,12 @@
res = ast_waitstream(chan, AST_DIGIT_ANY);
}
ast_stopstream(chan);
- /* Maybe ringing, but let's play moh games here */
- ast_moh_start(qe->chan, qe->moh, NULL);
+ if (ringing) {
+ ast_indicate(chan, AST_CONTROL_RINGING);
+ } else {
+ ast_moh_start(chan, moh, NULL);
+ }
+
return res;
}
@@ -4889,8 +4902,8 @@
ast_log(LOG_ERROR, "Can't find the queue_ds_sound_ending datastore! on chan %s\n", chan->name);
return 1; /* Why continue, if I can't access the datastore & list? */
}
+ ast_debug(2, "---- Aqsi now playing: %d\n", aqsi->now_playing);
- /* If we are not playing - see if we can play the next file in the playlist */
if (aqsi->now_playing == 0) {
playfilename[0] = '\0';
if (ast_strlen_zero(filename)) {
@@ -4901,13 +4914,16 @@
ringing = aqsi->ringing;
moh = aqsi->moh;
free(sfn);
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "--- No filename and not playing - selecting next file in playlist - %s\n", playfilename);
- }
+ ast_debug(3, "--- No filename and not playing - selecting next file in playlist - %s\n", playfilename);
}
if (ast_strlen_zero(playfilename)) {
- if (option_debug > 2 ) {
- ast_log(LOG_DEBUG, "--- empty queue... No filename and not currently playing\n");
+ ast_debug(3, "--- empty queue... No filename and not currently playing\n");
+ if (ringing) {
+ ast_indicate(chan, AST_CONTROL_RINGING);
+ } else {
+ if (!ast_test_flag(chan, AST_FLAG_MOH)) {
+ ast_moh_start(chan, aqsi->qe->moh, NULL);
+ }
}
return -1;
}
@@ -4916,9 +4932,7 @@
}
} else {
if (ast_strlen_zero(filename)) {
- if (option_debug > 2 ) {
- ast_log(LOG_DEBUG, "--- just checking... No filename and currently playing\n");
- }
+ ast_debug(3, "--- just checking... No filename and currently playing\n");
return -1;
}
}
@@ -4928,9 +4942,7 @@
if (aqsi->now_playing) {
struct ast_queue_streamfile_name *fn = ast_calloc(1, sizeof(*fn));
fn->filename = ast_strdup(filename);
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, " queued sound file %s for playing on chan %s\n", filename, chan->name);
- }
+ ast_debug(3, " queued sound file %s for playing on chan %s\n", filename, chan->name);
/* link the struct into the current ast_queue_streamfile_info struct */
AST_LIST_INSERT_TAIL(&aqsi->flist, fn, list);
@@ -4940,25 +4952,17 @@
/* Stop the music on hold so we can play our own file */
if (ringing) {
- if (option_debug > 1) {
- ast_log(LOG_DEBUG, "Stopping Indication on %s\n", chan->name);
- }
+ ast_debug(3, "Stopping Indication on %s\n", chan->name);
ast_indicate(chan,-1);
} else {
- if (option_debug > 1) {
- ast_log(LOG_DEBUG, "Stopping MOH on chan %s\n", chan->name);
- }
+ ast_debug(3, "Stopping MOH on chan %s\n", chan->name);
ast_moh_stop(chan);
}
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Stopping Streaming on chan %s\n", chan->name);
- }
+ ast_debug(3, "Stopping Streaming on chan %s\n", chan->name);
ast_stopstream(chan);
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Autoservice stop on chan %s\n", chan->name);
- }
+ ast_debug(3, "Autoservice stop on chan %s\n", chan->name);
ast_autoservice_stop(chan);
/* Create generator to start playing audio without waiting */
@@ -4971,23 +4975,22 @@
generatordata->chan = chan;
generatordata->aqsi = aqsi;
- ast_log(LOG_DEBUG, "--- Starting to play file %s \n", playfilename);
/* Starting new generator on channel. */
if (ast_activate_generator(chan, &play_file_gen, generatordata)) {
- ast_log(LOG_DEBUG, "Not playing requested prompt %s. Generator failed on %s.\n", playfilename, chan->name);
+ ast_log(LOG_ERROR, "Not playing requested prompt %s. Generator failed on %s.\n", playfilename, chan->name);
/* oops, the current file has problems */
/* restore the moh */
if (ringing) {
- ast_log(LOG_DEBUG, "Starting Indicate\n");
ast_indicate(chan, AST_CONTROL_RINGING);
} else {
- ast_log(LOG_DEBUG, "Starting MOH %s on chan %s\n", aqsi->qe->moh, chan->name);
ast_moh_start(chan, aqsi->qe->moh, NULL);
}
AST_LIST_UNLOCK(&aqsi->flist);
return 1;
+ } else {
+ ast_debug(3, "--- Generator Starting to play file %s \n", playfilename);
}
aqsi->now_playing = 1; /* We have begun playback */
}
@@ -5193,8 +5196,9 @@
break;
}
- ast_log(LOG_DEBUG, "--- We should be here, really...\n");
- play_file(qe.chan, NULL, ringing, qe.moh); /* OEJ - Trigger next prompt */
+ if (background_prompts) {
+ play_file(qe.chan, NULL, ringing, qe.moh); /* OEJ - Trigger next prompt */
+ }
if (makeannouncement) {
/* Make a position announcement, if enabled */
if (qe.parent->announcefrequency)
@@ -6871,7 +6875,6 @@
int wordlen = strlen(word);
char *ret = NULL;
if (pos != 3) /* Wha? */ {
- ast_log(LOG_DEBUG, "Hitting this???, pos is %d\n", pos);
return NULL;
}
Modified: team/group/pinequeue/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pinequeue/main/channel.c?view=diff&rev=306253&r1=306252&r2=306253
==============================================================================
--- team/group/pinequeue/main/channel.c (original)
+++ team/group/pinequeue/main/channel.c Fri Feb 4 04:47:33 2011
@@ -1944,12 +1944,12 @@
void ast_deactivate_generator(struct ast_channel *chan)
{
- ast_log(LOG_ERROR,"ast_deactivate_generator() called on chan %s\n", chan->name);
+ ast_debug(3, "ast_deactivate_generator() called on chan %s\n", chan->name);
ast_channel_lock(chan);
if (chan->generatordata) {
if (chan->generator && chan->generator->release)
chan->generator->release(chan, chan->generatordata);
- ast_log(LOG_ERROR,"removing the generator stuff on chan %s\n", chan->name);
+ ast_debug(3,"removing the generator stuff on chan %s\n", chan->name);
chan->generatordata = NULL;
chan->generator = NULL;
ast_channel_set_fd(chan, AST_GENERATOR_FD, -1);
@@ -1957,6 +1957,7 @@
ast_settimeout(chan, 0, NULL, NULL);
}
ast_channel_unlock(chan);
+ ast_log(LOG_DEBUG, "ast_deactivate_generator() done on chan %s\n", chan->name);
}
static int generator_force(const void *data)
@@ -1966,7 +1967,7 @@
int res;
int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = NULL;
struct ast_channel *chan = (struct ast_channel *)data;
- ast_log(LOG_ERROR, "GENERATOR_FORCE CALLED on chan %s\n", chan->name);
+
ast_channel_lock(chan);
tmp = chan->generatordata;
chan->generatordata = NULL;
@@ -1974,14 +1975,16 @@
generate = chan->generator->generate;
ast_channel_unlock(chan);
- if (!tmp || !generate)
+ ast_debug(3, "GENERATOR_FORCE: generate() CALLED res=%d on chan %s\n", res, chan->name);
+ if (!tmp || !generate) {
+ ast_log(LOG_ERROR, "--- Can't find generator data or generator function \n");
return 0;
+ }
res = generate(chan, tmp, 0, ast_format_rate(chan->writeformat & AST_FORMAT_AUDIO_MASK) / 50);
chan->generatordata = tmp;
- ast_log(LOG_ERROR, "GENERATOR_FORCE: generate() CALLED res=%d on chan %s\n", res, chan->name);
if (res) {
ast_debug(1, "Auto-deactivating generator on chan %s\n", chan->name);
ast_deactivate_generator(chan);
@@ -1994,7 +1997,7 @@
{
int res = 0;
- ast_log(LOG_ERROR,"In the activate_generator func. gen->alloc = %p on chan %s\n", gen->alloc, chan->name);
+ ast_log(LOG_DEBUG,"In the activate_generator func. gen->alloc = %p on chan %s\n", gen->alloc, chan->name);
ast_channel_lock(chan);
if (chan->generatordata) {
if (chan->generator && chan->generator->release)
@@ -2002,11 +2005,11 @@
chan->generatordata = NULL;
}
if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
- ast_log(LOG_ERROR,"Generator Data is -1\n");
+ ast_debug(3,"Generator Data is -1\n");
res = -1;
}
if (!res) {
- ast_log(LOG_ERROR,"About to settimeout for generator_force on chan %s\n", chan->name);
+ ast_debug(3,"About to settimeout for generator_force on chan %s\n", chan->name);
ast_settimeout(chan, 160, generator_force, chan);
chan->generator = gen;
}
@@ -2407,10 +2410,10 @@
int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *data), void *data)
{
int res = -1;
- ast_log(LOG_ERROR,"in settimeout\n");
+ ast_debug(3,"in settimeout\n");
#ifdef HAVE_DAHDI
ast_channel_lock(c);
- ast_log(LOG_ERROR,"in settimeout (HAVE DAHDI) timingfd=%d; timingfunc=%p; timingdata=%p\n", c->timingfd, c->timingfunc, c->timingdata);
+ ast_debug(3,"in settimeout (HAVE DAHDI) timingfd=%d; timingfunc=%p; timingdata=%p\n", c->timingfd, c->timingfunc, c->timingdata);
if (c->timingfd > -1) {
if (!func) {
samples = 0;
@@ -2422,6 +2425,8 @@
c->timingdata = data;
}
ast_channel_unlock(c);
+#else
+ ast_debug(3, "-- Set timeout have no timer to work with\n");
#endif
return res;
}
@@ -2521,6 +2526,7 @@
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
{
+ ast_debug(3, "----- Jost poking around. Have a happy life. \n");
if (chan->generator && chan->generator->generate && chan->generatordata && !ast_internal_timing_enabled(chan)) {
void *tmp = chan->generatordata;
int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = chan->generator->generate;
@@ -2533,6 +2539,7 @@
ast_settimeout(chan, 0, NULL, NULL);
}
+ ast_debug(3, "--- Deactivating generator \n");
chan->generatordata = NULL; /* reset, to let writes go through */
if (f->subclass != chan->writeformat) {
@@ -2555,6 +2562,7 @@
res = generate(chan, tmp, f->datalen, samples);
ast_channel_lock(chan);
chan->generatordata = tmp;
+ ast_debug(3, "--- Reactivating generator \n");
if (res) {
if (option_debug > 1)
ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
@@ -3061,6 +3069,7 @@
/* Run generator sitting on the line if timing device not available
* and synchronous generation of outgoing frames is necessary */
+ ast_debug(3, ">>>>>>>>> just another silly message. We are generating, man! \n");
ast_read_generator_actions(chan, f);
}
default:
Modified: team/group/pinequeue/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pinequeue/main/file.c?view=diff&rev=306253&r1=306252&r2=306253
==============================================================================
--- team/group/pinequeue/main/file.c (original)
+++ team/group/pinequeue/main/file.c Fri Feb 4 04:47:33 2011
@@ -741,6 +741,7 @@
struct ast_frame *fr;
if (s->orig_chan_name && strcasecmp(s->owner->name, s->orig_chan_name)) {
+ ast_log(LOG_DEBUG, "--- Giving up here\n");
goto return_failure;
}
@@ -751,6 +752,7 @@
ast_log(LOG_WARNING, "Failed to write frame\n");
ast_frfree(fr);
}
+ ast_log(LOG_DEBUG, "--- Giving up here now\n");
goto return_failure;
}
Modified: team/group/pinequeue/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pinequeue/res/res_musiconhold.c?view=diff&rev=306253&r1=306252&r2=306253
==============================================================================
--- team/group/pinequeue/res/res_musiconhold.c (original)
+++ team/group/pinequeue/res/res_musiconhold.c Fri Feb 4 04:47:33 2011
@@ -306,7 +306,6 @@
state->sample_queue += samples;
while (state->sample_queue > 0) {
- ast_log(LOG_ERROR,"about to lock chan & read & write data\n");
ast_channel_lock(chan);
if ((f = moh_files_readframe(chan))) {
/* We need to be sure that we unlock
@@ -316,11 +315,9 @@
* indirect channels, like local channels
*/
ast_channel_unlock(chan);
- ast_log(LOG_ERROR,"read frame, about to write it\n");
state->samples += f->samples;
state->sample_queue -= f->samples;
res = ast_write(chan, f);
- ast_log(LOG_ERROR,"wrote frame, res=%d\n", res);
ast_frfree(f);
if (res < 0) {
ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
@@ -1407,13 +1404,9 @@
ast_set_flag(chan, AST_FLAG_MOH);
if (mohclass->total_files) {
- ast_log(LOG_ERROR,"MOH about to activate_generator: total_files=%d; class=%s;\n", mohclass->total_files, mohclass->mode);
res = ast_activate_generator(chan, &moh_file_stream, mohclass);
- ast_log(LOG_ERROR,"MOH started, total_files=%d; class=%s;\n", mohclass->total_files, mohclass->mode);
} else {
- ast_log(LOG_ERROR,"MOH about to activate_generator: total_files=%d; class=%s;\n", mohclass->total_files, mohclass->mode);
res = ast_activate_generator(chan, &mohgen, mohclass);
- ast_log(LOG_ERROR,"MOH started, total_files=%d; class=%s;\n", mohclass->total_files, mohclass->mode);
}
mohclass = mohclass_unref(mohclass);
More information about the asterisk-commits
mailing list