aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-11-15 20:21:57 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-11-25 19:23:53 +0100
commitc84318b245793dd48aac30c0f30b5e8f356ba42e (patch)
tree6115179c5cfcb05eb3d0df2b31b0fa07391e07fc /src/common
parent8f6d0752df7b5e3a3f0c70742bc9e4b45ceebf40 (diff)
Restructure: Move jitter from common code to 'libjitter'
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Makefile.am1
-rw-r--r--src/common/jitter.c115
-rw-r--r--src/common/jitter.h13
-rw-r--r--src/common/mncc_console.c2
-rw-r--r--src/common/sender.h2
5 files changed, 2 insertions, 131 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 443823d..8ca32bb 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -7,7 +7,6 @@ libcommon_a_SOURCES = \
debug.c \
sound_alsa.c \
goertzel.c \
- jitter.c \
emphasis.c \
compandor.c \
fft.c \
diff --git a/src/common/jitter.c b/src/common/jitter.c
deleted file mode 100644
index 865438b..0000000
--- a/src/common/jitter.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Jitter buffering functions
- *
- * (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
- * All Rights Reserved
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-#include "sample.h"
-#include "debug.h"
-#include "jitter.h"
-
-/* create jitter buffer */
-int jitter_create(jitter_t *jitter, int length)
-{
- memset(jitter, 0, sizeof(*jitter));
- jitter->spl = calloc(length * sizeof(sample_t), 1);
- if (!jitter->spl) {
- PDEBUG(DDSP, DEBUG_ERROR, "No memory for jitter buffer.\n");
- return -ENOMEM;
- }
- jitter->len = length;
-
- return 0;
-}
-
-void jitter_destroy(jitter_t *jitter)
-{
- if (jitter->spl) {
- free(jitter->spl);
- jitter->spl = NULL;
- }
-}
-
-/* store audio in jitterbuffer
- *
- * stop if buffer is completely filled
- */
-void jitter_save(jitter_t *jb, sample_t *samples, int length)
-{
- sample_t *spl;
- int inptr, outptr, len, space;
- int i;
-
- spl = jb->spl;
- inptr = jb->inptr;
- outptr = jb->outptr;
- len = jb->len;
- space = (outptr - inptr + len - 1) % len;
-
- if (space < length)
- length = space;
- for (i = 0; i < length; i++) {
- spl[inptr++] = *samples++;
- if (inptr == len)
- inptr = 0;
- }
-
- jb->inptr = inptr;
-}
-
-/* get audio from jitterbuffer
- */
-void jitter_load(jitter_t *jb, sample_t *samples, int length)
-{
- sample_t *spl;
- int inptr, outptr, len, fill;
- int i, ii;
-
- spl = jb->spl;
- inptr = jb->inptr;
- outptr = jb->outptr;
- len = jb->len;
- fill = (inptr - outptr + len) % len;
-
- if (fill < length)
- ii = fill;
- else
- ii = length;
-
- /* fill what we got */
- for (i = 0; i < ii; i++) {
- *samples++ = spl[outptr++];
- if (outptr == len)
- outptr = 0;
- }
- /* on underrun, fill with silence */
- for (; i < length; i++) {
- *samples++ = 0;
- }
-
- jb->outptr = outptr;
-}
-
-void jitter_clear(jitter_t *jb)
-{
- jb->inptr = jb->outptr = 0;
-}
-
diff --git a/src/common/jitter.h b/src/common/jitter.h
deleted file mode 100644
index 658da19..0000000
--- a/src/common/jitter.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-typedef struct jitter {
- sample_t *spl; /* pointer to sample buffer */
- int len; /* buffer size: number of samples */
- int inptr, outptr; /* write pointer and read pointer */
-} jitter_t;
-
-int jitter_create(jitter_t *jitter, int length);
-void jitter_destroy(jitter_t *jitter);
-void jitter_save(jitter_t *jb, sample_t *samples, int length);
-void jitter_load(jitter_t *jb, sample_t *samples, int length);
-void jitter_clear(jitter_t *jb);
-
diff --git a/src/common/mncc_console.c b/src/common/mncc_console.c
index fc779f4..77d820c 100644
--- a/src/common/mncc_console.c
+++ b/src/common/mncc_console.c
@@ -26,7 +26,7 @@
#include <sys/time.h>
#include "sample.h"
#include "../libsamplerate/samplerate.h"
-#include "jitter.h"
+#include "../libjitter/jitter.h"
#include "debug.h"
#include "testton.h"
#include "mncc.h"
diff --git a/src/common/sender.h b/src/common/sender.h
index 4da32cd..6ec6ad8 100644
--- a/src/common/sender.h
+++ b/src/common/sender.h
@@ -4,7 +4,7 @@
#endif
#include "../libwave/wave.h"
#include "../libsamplerate/samplerate.h"
-#include "jitter.h"
+#include "../libjitter/jitter.h"
#include "emphasis.h"
#include "display.h"