fixed trace bug
[lcr.git] / chan_lcr.c
index ff8da54..7eabe0e 100644 (file)
@@ -475,6 +475,14 @@ void apply_opt(struct chan_call *call, char *data)
                        if (call->bchannel)
                                bchannel_pipeline(call->bchannel, call->pipeline);
                        break;
+               case 'r':
+                       if (opt[1] == '\0') {
+                               CERROR(call, call->ast, "Option 'r' (re-buffer 160 bytes) expects no parameter.\n", opt);
+                               break;
+                       }
+                       CDEBUG(call, call->ast, "Option 'r' (re-buffer 160 bytes)");
+                       call->rebuffer = 1;
+                       break;
 #if 0
                case 's':
                        if (opt[1] != '\0') {
@@ -682,6 +690,7 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
 
                /* change state */
                call->state = CHAN_LCR_STATE_IN_PROCEEDING;
+               ast_setstate(ast, AST_STATE_OFFHOOK);
 
                goto start;
        }
@@ -696,6 +705,7 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
 
                /* change state */
                call->state = CHAN_LCR_STATE_IN_DIALING;
+               ast_setstate(ast, AST_STATE_OFFHOOK);
 
                /* if match, start pbx */
                if (ast_exists_extension(ast, ast->context, ast->exten, 1, call->oad)) {
@@ -1935,7 +1945,11 @@ static struct ast_frame *lcr_read(struct ast_channel *ast)
                return NULL;
        }
        if (call->pipe[0] > -1) {
-               len = read(call->pipe[0], call->read_buff, sizeof(call->read_buff));
+               if (call->rebuffer) {
+                       len = read(call->pipe[0], call->read_buff, 160);
+               } else {
+                       len = read(call->pipe[0], call->read_buff, sizeof(call->read_buff));
+               }
                if (len <= 0) {
                        close(call->pipe[0]);
                        call->pipe[0] = -1;