[asterisk-commits] russell: branch russell/chan_console r81424 - /team/russell/chan_console/chan...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Sep 1 00:09:31 CDT 2007
Author: russell
Date: Sat Sep 1 00:09:31 2007
New Revision: 81424
URL: http://svn.digium.com/view/asterisk?view=rev&rev=81424
Log:
simplify handle_output a bit by putting all error handling in one spot at the
end of the function
Modified:
team/russell/chan_console/channels/chan_console.c
Modified: team/russell/chan_console/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_console.c?view=diff&rev=81424&r1=81423&r2=81424
==============================================================================
--- team/russell/chan_console/channels/chan_console.c (original)
+++ team/russell/chan_console/channels/chan_console.c Sat Sep 1 00:09:31 2007
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2006, Digium, Inc.
+ * Copyright (C) 2006 - 2007, Digium, Inc.
*
* Russell Bryant <russell at digium.com>
*
@@ -573,14 +573,17 @@
{
unsigned int src = 0;
unsigned int num_samples;
- struct ast_frame *fr;
+ struct ast_frame *fr = NULL;
+ int res = paContinue;
ast_mutex_lock(&pvt->lock);
+
/* Fill the buffer with the current sound if one is set */
if (pvt->cursound != -1) {
send_sound(pvt, output, frame_count);
frame_count = 0;
}
+
/* Empty the write buffer */
if (frame_count && pvt->write_dst) {
num_samples = MIN(pvt->write_dst * 2, frame_count);
@@ -589,6 +592,7 @@
src += num_samples * 2;
frame_count -= num_samples;
}
+
/* Get the rest from queued frames */
while (frame_count) {
while (!(fr = AST_LIST_REMOVE_HEAD(&pvt->frames, frame_list))) {
@@ -599,11 +603,8 @@
}
ast_cond_wait(&pvt->cond, &pvt->lock);
if (!pvt->hookstate) {
- if (fr)
- ast_frfree(fr);
- ast_mutex_unlock(&pvt->lock);
- pvt->incallback = 0;
- return paAbort;
+ res = paAbort;
+ goto return_cleanup;
}
}
num_samples = MIN(fr->samples, frame_count);
@@ -614,11 +615,14 @@
memcpy(&pvt->write_buf + pvt->write_dst, fr->data + num_samples * 2, (fr->samples - num_samples) * 2);
pvt->write_dst += (fr->samples - num_samples) * 2;
}
+ }
+
+return_cleanup:
+ ast_mutex_unlock(&pvt->lock);
+ if (fr)
ast_frfree(fr);
- }
- ast_mutex_unlock(&pvt->lock);
-
- return paContinue;
+
+ return res;
}
static int handle_input(struct console_pvt *pvt, const void *input, unsigned long frame_count)
More information about the asterisk-commits
mailing list