mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 18:40:46 +00:00
restructure a block to reduce nesting
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48750 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -189,8 +189,7 @@ static const unsigned short escapes[] = {
|
|||||||
|
|
||||||
#define SMSLEN 160 /*!< max SMS length */
|
#define SMSLEN 160 /*!< max SMS length */
|
||||||
|
|
||||||
typedef struct sms_s
|
typedef struct sms_s {
|
||||||
{
|
|
||||||
unsigned char hangup; /*!< we are done... */
|
unsigned char hangup; /*!< we are done... */
|
||||||
unsigned char err; /*!< set for any errors */
|
unsigned char err; /*!< set for any errors */
|
||||||
unsigned char smsc:1; /*!< we are SMSC */
|
unsigned char smsc:1; /*!< we are SMSC */
|
||||||
@@ -1558,20 +1557,41 @@ static int sms_generate (struct ast_channel *chan, void *data, int len, int samp
|
|||||||
*/
|
*/
|
||||||
static void sms_process(sms_t * h, int samples, signed short *data)
|
static void sms_process(sms_t * h, int samples, signed short *data)
|
||||||
{
|
{
|
||||||
#if 1
|
int bit;
|
||||||
/* Do we really need to remain deaf while a packet is
|
|
||||||
* being transmitted ?
|
/*
|
||||||
|
* Ignore incoming audio while a packet is being transmitted,
|
||||||
|
* the protocol is half-duplex.
|
||||||
|
* Unfortunately this means that if the outbound and incoming
|
||||||
|
* transmission overlap (which is an error condition anyways),
|
||||||
|
* we may miss some data and this makes debugging harder.
|
||||||
*/
|
*/
|
||||||
if (h->obyten || h->osync)
|
if (h->obyten || h->osync)
|
||||||
return; /* sending */
|
return;
|
||||||
#endif
|
for ( ; samples-- ; data++) {
|
||||||
while (samples--) {
|
|
||||||
unsigned long long m0, m1;
|
unsigned long long m0, m1;
|
||||||
if (abs (*data) > h->imag)
|
if (abs (*data) > h->imag)
|
||||||
h->imag = abs (*data);
|
h->imag = abs (*data);
|
||||||
else
|
else
|
||||||
h->imag = h->imag * 7 / 8;
|
h->imag = h->imag * 7 / 8;
|
||||||
if (h->imag > 500) {
|
if (h->imag <= 500) { /* below [arbitrary] threahold: lost carrier */
|
||||||
|
if (h->idle++ == 80000) { /* nothing happening */
|
||||||
|
ast_log (LOG_NOTICE, "No data, hanging up\n");
|
||||||
|
h->hangup = 1;
|
||||||
|
h->err = 1;
|
||||||
|
}
|
||||||
|
if (h->ierr) { /* error */
|
||||||
|
ast_log (LOG_NOTICE, "Error %d, hanging up\n", h->ierr);
|
||||||
|
/* Protocol 1 */
|
||||||
|
h->err = 1;
|
||||||
|
h->omsg[0] = 0x92; /* error */
|
||||||
|
h->omsg[1] = 1;
|
||||||
|
h->omsg[2] = h->ierr;
|
||||||
|
sms_messagetx (h); /* send error */
|
||||||
|
}
|
||||||
|
h->ierr = h->ibitn = h->ibytep = h->ibytec = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
h->idle = 0;
|
h->idle = 0;
|
||||||
|
|
||||||
/* multiply signal by the two carriers. */
|
/* multiply signal by the two carriers. */
|
||||||
@@ -1592,8 +1612,6 @@ static void sms_process (sms_t * h, int samples, signed short *data)
|
|||||||
h->ips1 -= 80;
|
h->ips1 -= 80;
|
||||||
if ((h->ipc1 += 13) >= 80)
|
if ((h->ipc1 += 13) >= 80)
|
||||||
h->ipc1 -= 80;
|
h->ipc1 -= 80;
|
||||||
{
|
|
||||||
char bit;
|
|
||||||
|
|
||||||
/* set new bit to 1 or 0 depending on which value is stronger */
|
/* set new bit to 1 or 0 depending on which value is stronger */
|
||||||
h->ibith <<= 1;
|
h->ibith <<= 1;
|
||||||
@@ -1659,25 +1677,6 @@ static void sms_process (sms_t * h, int samples, signed short *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* lost carrier */
|
|
||||||
if (h->idle++ == 80000) { /* nothing happening */
|
|
||||||
ast_log (LOG_NOTICE, "No data, hanging up\n");
|
|
||||||
h->hangup = 1;
|
|
||||||
h->err = 1;
|
|
||||||
}
|
|
||||||
if (h->ierr) { /* error */
|
|
||||||
ast_log (LOG_NOTICE, "Error %d, hanging up\n", h->ierr);
|
|
||||||
/* Protocol 1 */
|
|
||||||
h->err = 1;
|
|
||||||
h->omsg[0] = 0x92; /* error */
|
|
||||||
h->omsg[1] = 1;
|
|
||||||
h->omsg[2] = h->ierr;
|
|
||||||
sms_messagetx (h); /* send error */
|
|
||||||
}
|
|
||||||
h->ierr = h->ibitn = h->ibytep = h->ibytec = 0;
|
|
||||||
}
|
|
||||||
data++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_generator smsgen = {
|
static struct ast_generator smsgen = {
|
||||||
|
Reference in New Issue
Block a user