don't take locks when reading usecounts, they are not necessary (bug #4585)
[asterisk/asterisk.git] / formats / format_ilbc.c
index d4863c7..1d4388a 100755 (executable)
@@ -5,34 +5,34 @@
  *
  * Brian K. West <brian@bkw.org>
  * 
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999 - 2005, Digium, Inc.
  *
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
  *
  * This program is free software, distributed under the terms of
  * the GNU General Public License
  */
  
-#include <asterisk/lock.h>
-#include <asterisk/channel.h>
-#include <asterisk/file.h>
-#include <asterisk/logger.h>
-#include <asterisk/sched.h>
-#include <asterisk/module.h>
+#include <unistd.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <stdlib.h>
 #include <sys/time.h>
 #include <stdio.h>
-#include <unistd.h>
 #include <errno.h>
 #include <string.h>
-#include <pthread.h>
-#ifdef __linux__
-#include <endian.h>
-#else
-#include <machine/endian.h>
-#endif
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/lock.h"
+#include "asterisk/channel.h"
+#include "asterisk/file.h"
+#include "asterisk/logger.h"
+#include "asterisk/sched.h"
+#include "asterisk/module.h"
+#include "asterisk/endian.h"
 
 /* Some Ideas for this code came from makeg729e.c by Jeffrey Chilton */
 
@@ -51,7 +51,7 @@ struct ast_filestream {
 };
 
 
-static ast_mutex_t ilbc_lock = AST_MUTEX_INITIALIZER;
+AST_MUTEX_DEFINE_STATIC(ilbc_lock);
 static int glistcnt = 0;
 
 static char *name = "iLBC";
@@ -85,7 +85,7 @@ static struct ast_filestream *ilbc_open(int fd)
        return tmp;
 }
 
-static struct ast_filestream *ilbc_rewrite(int fd, char *comment)
+static struct ast_filestream *ilbc_rewrite(int fd, const char *comment)
 {
        /* We don't have any header to read or anything really, but
           if we did, it would go here.  We also might want to check
@@ -186,7 +186,7 @@ static int ilbc_seek(struct ast_filestream *fs, long sample_offset, int whence)
        if (whence != SEEK_FORCECUR) {
                offset = (offset > max)?max:offset;
        }
-       // protect against seeking beyond begining.
+       /* protect against seeking beyond begining. */
        offset = (offset < min)?min:offset;
        if (lseek(fs->fd, offset, SEEK_SET) < 0)
                return -1;
@@ -231,14 +231,7 @@ int unload_module()
 
 int usecount()
 {
-       int res;
-       if (ast_mutex_lock(&ilbc_lock)) {
-               ast_log(LOG_WARNING, "Unable to lock ilbc list\n");
-               return -1;
-       }
-       res = glistcnt;
-       ast_mutex_unlock(&ilbc_lock);
-       return res;
+       return glistcnt;
 }
 
 char *description()