Don't do reinvite if both parties talk diffrent codecs
[asterisk/asterisk.git] / channels / chan_oss.c
index ffbbbde..3557ac0 100755 (executable)
@@ -35,6 +35,8 @@
 #include <stdio.h>
 #ifdef __linux
 #include <linux/soundcard.h>
+#elif defined(__FreeBSD__)
+#include <machine/soundcard.h>
 #else
 #include <soundcard.h>
 #endif
 #include "answer.h"
 
 /* Which device to use */
+#ifdef __OpenBSD__
+#define DEV_DSP "/dev/audio"
+#else
 #define DEV_DSP "/dev/dsp"
+#endif
 
 /* Lets use 160 sample frames, just like GSM.  */
 #define FRAME_SIZE 160
@@ -64,7 +70,7 @@ static int silencesuppression = 0;
 static int silencethreshold = 1000;
 
 
-static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
+static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 static char *type = "Console";
 static char *desc = "OSS Console Channel Driver";
@@ -75,7 +81,7 @@ static char context[AST_MAX_EXTENSION] = "default";
 static char language[MAX_LANGUAGE] = "";
 static char exten[AST_MAX_EXTENSION] = "s";
 
-int hookstate=0;
+static int hookstate=0;
 
 static short silence[FRAME_SIZE] = {0, };
 
@@ -123,7 +129,7 @@ static int time_has_passed(void)
    with 160 sample frames, and a buffer size of 3, we have a 60ms buffer, 
    usually plenty. */
 
-pthread_t sthread;
+static pthread_t sthread;
 
 #define MAX_BUFFER_SIZE 100
 static int buffersize = 3;
@@ -245,7 +251,7 @@ static void *sound_thread(void *unused)
                        if (sounddev > max)
                                max = sounddev;
                }
-               res = select(max + 1, &rfds, &wfds, NULL, NULL);
+               res = ast_select(max + 1, &rfds, &wfds, NULL, NULL);
                if (res < 1) {
                        ast_log(LOG_WARNING, "select failed: %s\n", strerror(errno));
                        continue;
@@ -490,9 +496,9 @@ static int oss_hangup(struct ast_channel *c)
        c->pvt->pvt = NULL;
        oss.owner = NULL;
        ast_verbose( " << Hangup on console >> \n");
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        usecnt--;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        if (hookstate) {
                if (autoanswer) {
                        /* Assume auto-hangup too */
@@ -712,9 +718,9 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
                        strncpy(tmp->language, language, sizeof(tmp->language)-1);
                p->owner = tmp;
                ast_setstate(tmp, state);
-               ast_pthread_mutex_lock(&usecnt_lock);
+               ast_mutex_lock(&usecnt_lock);
                usecnt++;
-               ast_pthread_mutex_unlock(&usecnt_lock);
+               ast_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
@@ -1029,9 +1035,9 @@ char *description()
 int usecount()
 {
        int res;
-       ast_pthread_mutex_lock(&usecnt_lock);
+       ast_mutex_lock(&usecnt_lock);
        res = usecnt;
-       ast_pthread_mutex_unlock(&usecnt_lock);
+       ast_mutex_unlock(&usecnt_lock);
        return res;
 }