Sane FreeBSD patch
[asterisk/asterisk.git] / apps / app_intercom.c
index e12f097..4c2379c 100755 (executable)
@@ -11,6 +11,7 @@
  * the GNU General Public License
  */
  
+#include <asterisk/lock.h>
 #include <asterisk/file.h>
 #include <asterisk/frame.h>
 #include <asterisk/logger.h>
 #include <stdlib.h>
 #include <pthread.h>
 #include <sys/time.h>
+#ifdef __linux__
 #include <linux/soundcard.h>
+#elif defined(__FreeBSD__)
+#include <machine/soundcard.h>
+#else
+#include <soundcard.h>
+#endif
 #include <netinet/in.h>
 
 #define DEV_DSP "/dev/dsp"
@@ -40,37 +47,37 @@ static char *app = "Intercom";
 static char *synopsis = "(Obsolete) Send to Intercom";
 static char *descrip = 
 "  Intercom(): Sends the user to the intercom (i.e. /dev/dsp).  This program\n"
-"  is generally considered obselete by the chan_oss module.  Returns 0 if the\n"
-"  user exits with a DTMF tone, or -1 if they hangup.\n";
+"is generally considered  obselete by the chan_oss module.  Returns 0 if the\n"
+"user exits with a DTMF tone, or -1 if they hangup.\n";
 
 STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
 
-static pthread_mutex_t sound_lock = PTHREAD_MUTEX_INITIALIZER;
+static ast_mutex_t sound_lock = AST_MUTEX_INITIALIZER;
 static int sound = -1;
 
 static int write_audio(short *data, int len)
 {
        int res;
        struct audio_buf_info info;
-       ast_pthread_mutex_lock(&sound_lock);
+       ast_mutex_lock(&sound_lock);
        if (sound < 0) {
                ast_log(LOG_WARNING, "Sound device closed?\n");
-               ast_pthread_mutex_unlock(&sound_lock);
+               ast_mutex_unlock(&sound_lock);
                return -1;
        }
     if (ioctl(sound, SNDCTL_DSP_GETOSPACE, &info)) {
                ast_log(LOG_WARNING, "Unable to read output space\n");
-               ast_pthread_mutex_unlock(&sound_lock);
+               ast_mutex_unlock(&sound_lock);
         return -1;
     }
        res = write(sound, data, len);
-       ast_pthread_mutex_unlock(&sound_lock);
+       ast_mutex_unlock(&sound_lock);
        return res;
 }
 
-static int create_audio()
+static int create_audio(void)
 {
        int fmt, desired, res, fd;
        fd = open(DEV_DSP, O_WRONLY);