restructure a block to reduce nesting
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48750 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
2ea5003b5b
commit
69f35c5e62
|
@ -189,8 +189,7 @@ static const unsigned short escapes[] = {
|
|||
|
||||
#define SMSLEN 160 /*!< max SMS length */
|
||||
|
||||
typedef struct sms_s
|
||||
{
|
||||
typedef struct sms_s {
|
||||
unsigned char hangup; /*!< we are done... */
|
||||
unsigned char err; /*!< set for any errors */
|
||||
unsigned char smsc:1; /*!< we are SMSC */
|
||||
|
@ -1556,22 +1555,43 @@ static int sms_generate (struct ast_channel *chan, void *data, int len, int samp
|
|||
* bits in h->ibitt.
|
||||
* XXX the rest is to be determined.
|
||||
*/
|
||||
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
|
||||
/* Do we really need to remain deaf while a packet is
|
||||
* being transmitted ?
|
||||
int bit;
|
||||
|
||||
/*
|
||||
* 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)
|
||||
return; /* sending */
|
||||
#endif
|
||||
while (samples--) {
|
||||
return;
|
||||
for ( ; samples-- ; data++) {
|
||||
unsigned long long m0, m1;
|
||||
if (abs (*data) > h->imag)
|
||||
h->imag = abs (*data);
|
||||
else
|
||||
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;
|
||||
|
||||
/* 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;
|
||||
if ((h->ipc1 += 13) >= 80)
|
||||
h->ipc1 -= 80;
|
||||
{
|
||||
char bit;
|
||||
|
||||
/* set new bit to 1 or 0 depending on which value is stronger */
|
||||
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 = {
|
||||
|
|
Reference in New Issue