]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8960 Set buffer position to beginning on reset
authorPiotr Gregor <piotrek.gregor@gmail.com>
Sat, 19 Mar 2016 23:28:35 +0000 (23:28 +0000)
committerPiotr Gregor <piotrek.gregor@gmail.com>
Sat, 19 Mar 2016 23:43:50 +0000 (23:43 +0000)
Now buffer position is reset to 0.

src/mod/applications/mod_avmd/buffer.h
src/mod/applications/mod_avmd/mod_avmd.c
src/mod/applications/mod_avmd/sma_buf.h

index a92904ddbcfad67bb86e1b597444bf41c29d9f91..46d1c07d4cb99122b838033b965d11dda8f067ce 100644 (file)
@@ -92,13 +92,14 @@ extern size_t next_power_of_2(size_t v);
 
 //#define DESTROY_CIRC_BUFFER(b) free((b)->buf)
 #define GET_BACKLOG_POS(b) ((b)->lpos - (b)->backlog)
-#define GET_CURRENT_POS(b) ((b)->lpos)
-#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_POS((b)))
+#define GET_CURRENT_POS(b) ((b)->pos)
+#define GET_CURRENT_LPOS(b) ((b)->lpos)
+#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_LPOS((b)))
 
 #define ADD_SAMPLE(b, s) \
     do { \
        INC_POS((b)); \
-       SET_SAMPLE((b), GET_CURRENT_POS((b)), (s)); \
+       SET_SAMPLE((b), GET_CURRENT_LPOS((b)), (s)); \
     } while (0)
 
 #endif
index ed1b676756785f18839d798b624a9bf65289b8c7..66a07264c1a78110c0bf0e508e821ba5543a0a40 100644 (file)
  *
  * This module detects voicemail beeps using a generalized approach.
  *
- * Mofdifications:
- *
- *      Piotr Gregor <piotrek.gregor@gmail.com>
- *      FS-8808 :   code refactor
- *      FS-8809 :   fix MAP_POPULATE undeclared
- *      FS-8810 :   fix float-int-float fast arc cosine
- *                  mapping construction (reuse)
- *      FS-8852 :   use predefined table length instead
- *                  of hardcoded computation
- *      FS-8853 :   enable change of resolution (and size)
- *                  of fast arc cos table
- *      FS-8854 :   initialize circular buffer
- *      FS-8855 :   fix APPEND_SMA_VAL macro and avmd_process
- *                  callback so that the variance of tone's
- *                  frequency estimation is correctly
- *                  calculated
+ * Modifications:
+ *      Piotr Gregor <piotrek.gregor@gmail.com>:
+ *      FS-8808, FS-8809, FS-8810, FS-8852, FS-8853, FS-8854, FS-8855
  */
 
 #include <switch.h>
@@ -91,7 +78,7 @@
 /*! Maximum frequency as digital normalized frequency */
 #define MAX_FREQUENCY_R(r) ((2.0 * M_PI * MAX_FREQUENCY) / (r))
 /* decrease this value to eliminate false positives */
-#define VARIANCE_THRESHOLD (0.001)
+#define VARIANCE_THRESHOLD (0.0001)
 
 #include "amplitude.h"
 #include "buffer.h"
@@ -233,7 +220,7 @@ static switch_bool_t avmd_callback(switch_media_bug_t * bug, void *user_data, sw
 /*! \brief FreeSWITCH module loading function.
  *
  * @author Eric des Courtis
- * @par    Changes: Piotr Gregor, 07 Feb 2016 (FS-8809, FS-8810)
+ * @par    Modifications: Piotr Gregor
  * @return On success SWITCH_STATUS_SUCCES,
  *         on failure SWITCH_STATUS_TERM.
  */
@@ -587,8 +574,7 @@ end:
 
 /*! \brief Process one frame of data with avmd algorithm.
  * @author Eric des Courtis
- * @par Modifications: Piotr Gregor (FS-8852, FS-8853, FS-8854, FS-8855)
- *      (improved variance estimation calculation)
+ * @par Modifications: Piotr Gregor
  * @param session An avmd session.
  * @param frame An audio frame.
  */
index 0bbdc3e1f484ecec612dc450689e6ce495ec39bb..55a50719d4b843ebccb43a91ca33ce500a471c12 100644 (file)
@@ -31,7 +31,8 @@ typedef struct {
 
 #define GET_SMA_SAMPLE(b, p) ((b)->data[(p) % (b)->len])
 #define SET_SMA_SAMPLE(b, p, v) ((b)->data[(p) % (b)->len] = (v))
-#define GET_CURRENT_SMA_POS(b) ((b)->lpos)
+#define GET_CURRENT_SMA_POS(b) ((b)->pos)
+#define GET_CURRENT_SMA_LPOS(b) ((b)->lpos)
 
 #define INC_SMA_POS(b) \
     { \
@@ -52,6 +53,8 @@ typedef struct {
     { \
        (b)->sma = 0.0; \
        (void)memset((b)->data, 0, sizeof(BUFF_TYPE) * (b)->len); \
+       (b)->pos = 0; \
+       (b)->lpos = 0; \
     }
 
 /*