ref: f87eb660e3f78100be125e6ef38e07539bb0d53f
parent: ca5618deb1a747f3b46f6240a2b232e632c37b0e
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Nov 16 17:19:32 EST 2020
port to Plan 9
--- /dev/null
+++ b/src/mkfile
@@ -1,0 +1,25 @@
+</$objtype/mkfile
+LIB=/$objtype/lib/libsamplerate.a
+
+CFLAGS=$CFLAGS -p -Iplan9 -DHAVE_CONFIG_H
+
+OFILES=\
+ plan9.$O\
+ samplerate.$O\
+ src_linear.$O\
+ src_sinc.$O\
+ src_zoh.$O\
+
+HFILES=\
+ /sys/include/samplerate.h\
+ common.h\
+ fastest_coeffs.h\
+ high_qual_coeffs.h\
+ mid_qual_coeffs.h\
+ samplerate.h\
+ src_config.h\
+
+/sys/include/%.h: %.h
+ cp $stem.h /sys/include/$stem.h
+
+</sys/src/cmd/mksyslib
--- /dev/null
+++ b/src/plan9.c
@@ -1,0 +1,19 @@
+int
+lrintf(float f)
+{
+ int i;
+
+ *((float*)&i) = f + 12582912.0f;
+
+ return (i & 0x7fffff) - 0x400000;
+}
+
+long
+lrint(double d)
+{
+ long long l;
+
+ *((double*)&l) = d + 6755399441055744.0;
+
+ return l;
+}
--- /dev/null
+++ b/src/plan9/config.h
@@ -1,0 +1,17 @@
+#include <u.h>
+#include <libc.h>
+
+#define SIZEOF_INT sizeof(int)
+#define SIZEOF_LONG sizeof(long)
+#define CPU_IS_LITTLE_ENDIAN
+#define PACKAGE "libsamplerate"
+#define VERSION "nein"
+
+#define NULL nil
+#define UNUSED(x) USED(x)
+
+typedef enum { false, true } bool;
+typedef s32int int32_t;
+
+int lrintf(float f);
+long lrint(double d);
--- a/src/samplerate.h
+++ b/src/samplerate.h
@@ -18,6 +18,7 @@
extern "C" {
#endif /* __cplusplus */
+#pragma lib "libsamplerate.a"
/* Opaque data type SRC_STATE. */
typedef struct SRC_STATE_tag SRC_STATE ;
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -228,7 +228,7 @@
static void
linear_reset (SRC_STATE *state)
-{ LINEAR_DATA *priv = NULL ;
+{ LINEAR_DATA *priv ;
priv = (LINEAR_DATA*) state->private_data ;
if (priv == NULL)
@@ -240,7 +240,7 @@
return ;
} /* linear_reset */
-SRC_STATE *
+static SRC_STATE *
linear_copy (SRC_STATE *state)
{
assert (state != NULL) ;
@@ -290,9 +290,7 @@
linear->last_value = NULL ;
}
free (linear) ;
- linear = NULL ;
}
free (state) ;
- state = NULL ;
}
} /* linear_close */
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -570,7 +570,7 @@
output [ch] = (float) (scale * (left [ch] + right [ch])) ;
} /* calc_output_stereo */
-SRC_ERROR
+static SRC_ERROR
sinc_stereo_vari_process (SRC_STATE *state, SRC_DATA *data)
{ SINC_FILTER *filter ;
double input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -726,7 +726,7 @@
output [ch] = (float) (scale * (left [ch] + right [ch])) ;
} /* calc_output_quad */
-SRC_ERROR
+static SRC_ERROR
sinc_quad_vari_process (SRC_STATE *state, SRC_DATA *data)
{ SINC_FILTER *filter ;
double input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -881,7 +881,7 @@
output [ch] = (float) (scale * (left [ch] + right [ch])) ;
} /* calc_output_hex */
-SRC_ERROR
+static SRC_ERROR
sinc_hex_vari_process (SRC_STATE *state, SRC_DATA *data)
{ SINC_FILTER *filter ;
double input_index, src_ratio, count, float_increment, terminate, rem ;
@@ -1143,7 +1143,7 @@
static SRC_ERROR
prepare_data (SINC_FILTER *filter, int channels, SRC_DATA *data, int half_filter_chan_len)
-{ int len = 0 ;
+{ int len ;
if (filter->b_real_end >= 0)
return SRC_ERR_NO_ERROR ; /* Should be terminating. Just return. */
@@ -1231,9 +1231,7 @@
sinc->buffer = NULL ;
}
free (sinc) ;
- sinc = NULL ;
}
free (state) ;
- state = NULL ;
}
} /* sinc_close */
--- a/src/src_zoh.c
+++ b/src/src_zoh.c
@@ -279,9 +279,7 @@
zoh->last_value = NULL ;
}
free (zoh) ;
- zoh = NULL ;
}
free (state) ;
- state = NULL ;
}
} /* zoh_close */