Version 0.1.10 from FTP
[asterisk/asterisk.git] / channels / chan_modem_aopen.c
index ae2b7e4..f93fe0b 100755 (executable)
@@ -194,9 +194,13 @@ static struct ast_frame *aopen_handle_escape(struct ast_modem_pvt *p, char esc)
                ast_log(LOG_DEBUG, "Escaped character '%c'\n", esc);
        
        switch(esc) {
+       case 'R': /* Pseudo ring */
+               p->fr.frametype = AST_FRAME_CONTROL;
+               p->fr.subclass = AST_CONTROL_RING;
+               return &p->fr;
        case 'X': /* Pseudo connect */
                p->fr.frametype = AST_FRAME_CONTROL;
-               p->fr.subclass = AST_CONTROL_ANSWER;
+               p->fr.subclass = AST_CONTROL_RING;
                if (p->owner)
                        p->owner->state = AST_STATE_UP;
                if (aopen_startrec(p))
@@ -255,11 +259,14 @@ static struct ast_frame *aopen_read(struct ast_modem_pvt *p)
                                /* If we're in immediate mode, reply now */
                                if (p->mode == MODEM_MODE_IMMEDIATE)
                                        return aopen_handle_escape(p, 'X');
-                       }
+                       } else
                        if (!strcasecmp(result, "BUSY")) {
                                /* Same as a busy signal */
                                return aopen_handle_escape(p, 'b');
-                       }
+                       } else
+                       if (!strcasecmp(result, "RING")) {
+                               return aopen_handle_escape(p, 'R');
+                       } else
                        if (!strcasecmp(result, "NO DIALTONE")) {
                                /* There's no dialtone, so the line isn't working */
                                ast_log(LOG_WARNING, "Device '%s' lacking dialtone\n", p->dev);
@@ -356,17 +363,17 @@ static char *aopen_identify(struct ast_modem_pvt *p)
 
 static void aopen_incusecnt()
 {
-       pthread_mutex_lock(&usecnt_lock);
+       ast_pthread_mutex_lock(&usecnt_lock);
        usecnt++;
-       pthread_mutex_unlock(&usecnt_lock);
+       ast_pthread_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
 static void aopen_decusecnt()
 {
-       pthread_mutex_lock(&usecnt_lock);
+       ast_pthread_mutex_lock(&usecnt_lock);
        usecnt++;
-       pthread_mutex_unlock(&usecnt_lock);
+       ast_pthread_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
 }
 
@@ -450,9 +457,9 @@ static struct ast_modem_driver aopen_driver =
 int usecount(void)
 {
        int res;
-       pthread_mutex_lock(&usecnt_lock);
+       ast_pthread_mutex_lock(&usecnt_lock);
        res = usecnt;
-       pthread_mutex_unlock(&usecnt_lock);
+       ast_pthread_mutex_unlock(&usecnt_lock);
        return res;
 }
 
@@ -471,3 +478,7 @@ char *description()
        return desc;
 }
 
+char *key()
+{
+       return ASTERISK_GPL_KEY;
+}