[asterisk-addons-commits] mnicholson: branch 1.6.2 r928 - in /branches/1.6.2: ./ channels/chan_mobile.c
SVN commits to the Asterisk addons project
asterisk-addons-commits at lists.digium.com
Wed May 27 12:19:40 CDT 2009
Author: mnicholson
Date: Wed May 27 12:19:36 2009
New Revision: 928
URL: http://svn.asterisk.org/svn-view/asterisk-addons?view=rev&rev=928
Log:
Merged revisions 926-927 via svnmerge from
https://origsvn.digium.com/svn/asterisk-addons/trunk
........
r926 | mnicholson | 2009-05-27 12:07:00 -0500 (Wed, 27 May 2009) | 9 lines
Lock the pvt structure in the mbl_read() and mbl_write() functions.
(issue #15075)
Reported by: hmld
Patches:
chan_mobile_v2.diff uploaded by zvision (license 798)
chan_mobile_v2a.diff uploaded by hmld (license 777)
Tested by: hmld, zvision, rseste
........
r927 | mnicholson | 2009-05-27 12:13:44 -0500 (Wed, 27 May 2009) | 9 lines
Handle read errors from the sco_socket by closing the socket conenction and waiting for another one before reading again. This is non standard behavior to accomidate certain Nokia handsets.
(closes issue #15075)
Reported by: hmld
Patches:
chan_mobile_v2.diff uploaded by zvision (license 798)
chan_mobile_v2a.diff uploaded by hmld (license 777)
Tested by: hmld, zvision, rseste
........
Modified:
branches/1.6.2/ (props changed)
branches/1.6.2/channels/chan_mobile.c
Propchange: branches/1.6.2/
------------------------------------------------------------------------------
--- trunk-merged (original)
+++ trunk-merged Wed May 27 12:19:36 2009
@@ -1,1 +1,1 @@
-/trunk:1-907,910
+/trunk:1-907,910,926-927
Modified: branches/1.6.2/channels/chan_mobile.c
URL: http://svn.asterisk.org/svn-view/asterisk-addons/branches/1.6.2/channels/chan_mobile.c?view=diff&rev=928&r1=927&r2=928
==============================================================================
--- branches/1.6.2/channels/chan_mobile.c (original)
+++ branches/1.6.2/channels/chan_mobile.c Wed May 27 12:19:36 2009
@@ -1015,13 +1015,19 @@
{
struct mbl_pvt *pvt = ast->tech_pvt;
+ struct ast_frame *fr = &ast_null_frame;
int r;
ast_debug(3, "*** mbl_read()\n");
- if (!pvt->owner) {
- return &ast_null_frame;
- }
+ while (ast_mutex_trylock(&pvt->lock)) {
+ CHANNEL_DEADLOCK_AVOIDANCE(ast);
+ }
+
+ if (!pvt->owner || pvt->sco_socket == -1) {
+ goto e_return;
+ }
+
memset(&pvt->fr, 0x00, sizeof(struct ast_frame));
pvt->fr.frametype = AST_FRAME_VOICE;
pvt->fr.subclass = DEVICE_FRAME_FORMAT;
@@ -1033,8 +1039,13 @@
pvt->fr.data.ptr = pvt->io_buf + AST_FRIENDLY_OFFSET;
if ((r = read(pvt->sco_socket, pvt->fr.data.ptr, DEVICE_FRAME_SIZE)) == -1) {
- ast_log(LOG_ERROR, "read error %d\n", errno);
- return &ast_null_frame;
+ if (errno != EAGAIN && errno != EINTR) {
+ ast_debug(1, "[%s] read error %d, going to wait for new connection\n", pvt->id, errno);
+ close(pvt->sco_socket);
+ pvt->sco_socket = -1;
+ ast_channel_set_fd(ast, 0, -1);
+ }
+ goto e_return;
}
pvt->fr.datalen = r;
@@ -1043,8 +1054,15 @@
if (pvt->do_alignment_detection)
do_alignment_detection(pvt, pvt->fr.data.ptr, r);
- return ast_dsp_process(ast, pvt->dsp, &pvt->fr);
-
+ fr = ast_dsp_process(ast, pvt->dsp, &pvt->fr);
+
+ ast_mutex_unlock(&pvt->lock);
+
+ return fr;
+
+e_return:
+ ast_mutex_unlock(&pvt->lock);
+ return fr;
}
static int mbl_write(struct ast_channel *ast, struct ast_frame *frame)
@@ -1057,6 +1075,10 @@
if (frame->frametype != AST_FRAME_VOICE) {
return 0;
+ }
+
+ while (ast_mutex_trylock(&pvt->lock)) {
+ CHANNEL_DEADLOCK_AVOIDANCE(ast);
}
ast_smoother_feed(pvt->smoother, frame);
@@ -1065,6 +1087,8 @@
sco_write(pvt->sco_socket, f->data.ptr, f->datalen);
ast_frfree(f);
}
+
+ ast_mutex_unlock(&pvt->lock);
return 0;
More information about the asterisk-addons-commits
mailing list