- /* there is something to queue */
- if (!ast_channel_trylock(ast)) { /* succeed */
- while(*p) {
- switch (*p) {
- case 'P':
- CDEBUG(call, ast, "Sending queued PROCEEDING to Asterisk.\n");
- ast_queue_control(ast, AST_CONTROL_PROCEEDING);
- break;
- case 'R':
- CDEBUG(call, ast, "Sending queued RINGING to Asterisk.\n");
- ast_queue_control(ast, AST_CONTROL_RINGING);
- ast_setstate(ast, AST_STATE_RINGING);
- break;
- case 'A':
- CDEBUG(call, ast, "Sending queued ANSWER to Asterisk.\n");
- ast_queue_control(ast, AST_CONTROL_ANSWER);
- break;
- case 'H':
- CDEBUG(call, ast, "Sending queued HANGUP to Asterisk.\n");
- ast_queue_hangup(ast);
- break;
- case '1': case '2': case '3': case 'a':
- case '4': case '5': case '6': case 'b':
- case '7': case '8': case '9': case 'c':
- case '*': case '0': case '#': case 'd':
- CDEBUG(call, ast, "Sending queued digit '%c' to Asterisk.\n", *p);
- /* send digit to asterisk */
- memset(&fr, 0, sizeof(fr));
-
- #ifdef LCR_FOR_ASTERISK
- fr.frametype = AST_FRAME_DTMF_BEGIN;
- #endif
-
- #ifdef LCR_FOR_CALLWEAVER
- fr.frametype = AST_FRAME_DTMF;
- #endif
-
- fr.subclass = *p;
- fr.delivery = ast_tv(0, 0);
- ast_queue_frame(ast, &fr);
-
- #ifdef LCR_FOR_ASTERISK
- fr.frametype = AST_FRAME_DTMF_END;
- ast_queue_frame(ast, &fr);
- #endif
-
- break;
- default:
- CDEBUG(call, ast, "Ignoring queued digit 0x%02d.\n", *p);
- }
- p++;
+ if (ast_channel_trylock(ast)) {
+ ast_mutex_unlock(&chan_lock);
+ usleep(1);
+ ast_mutex_lock(&chan_lock);
+ goto again;
+ }
+ while(*p) {
+ switch (*p) {
+ case 'T':
+ CDEBUG(call, ast, "Sending queued PROGRESS to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_PROGRESS);
+ break;
+ case 'P':
+ CDEBUG(call, ast, "Sending queued PROCEEDING to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_PROCEEDING);
+ break;
+ case 'R':
+ CDEBUG(call, ast, "Sending queued RINGING to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_RINGING);
+ ast_setstate(ast, AST_STATE_RINGING);
+ break;
+ case 'N':
+ CDEBUG(call, ast, "Sending queued ANSWER to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_ANSWER);
+ break;
+ case 'H':
+ CDEBUG(call, ast, "Sending queued HANGUP to Asterisk.\n");
+ ast_queue_hangup(ast);
+ break;
+ case '1': case '2': case '3': case 'A':
+ case '4': case '5': case '6': case 'B':
+ case '7': case '8': case '9': case 'C':
+ case '*': case '0': case '#': case 'D':
+ CDEBUG(call, ast, "Sending queued digit '%c' to Asterisk.\n", *p);
+ /* send digit to asterisk */
+ memset(&fr, 0, sizeof(fr));
+
+ #ifdef LCR_FOR_ASTERISK
+ fr.frametype = AST_FRAME_DTMF_BEGIN;
+ #endif
+
+ #ifdef LCR_FOR_CALLWEAVER
+ fr.frametype = AST_FRAME_DTMF;
+ #endif
+
+ fr.subclass = *p;
+ fr.delivery = ast_tv(0, 0);
+ ast_queue_frame(ast, &fr);
+
+ #ifdef LCR_FOR_ASTERISK
+ fr.frametype = AST_FRAME_DTMF_END;
+ ast_queue_frame(ast, &fr);
+ #endif
+
+ break;
+ default:
+ CDEBUG(call, ast, "Ignoring queued digit 0x%02x.\n", *p);