pcm/Dsd2Pcm: add noexcept and remove extern

This commit is contained in:
Max Kellermann 2020-01-14 17:46:25 +01:00
parent e565dcf18c
commit 91bc41ea20
2 changed files with 30 additions and 20 deletions

View File

@ -124,7 +124,8 @@ static constexpr double htaps[HTAPS] = {
static float ctables[CTABLES][256]; static float ctables[CTABLES][256];
static int precalculated = 0; static int precalculated = 0;
static void precalc() static void
precalc() noexcept
{ {
int t, e, m, k; int t, e, m, k;
double acc; double acc;
@ -149,7 +150,8 @@ struct dsd2pcm_ctx_s
unsigned fifopos; unsigned fifopos;
}; };
extern dsd2pcm_ctx* dsd2pcm_init() dsd2pcm_ctx *
dsd2pcm_init() noexcept
{ {
dsd2pcm_ctx* ptr; dsd2pcm_ctx* ptr;
if (!precalculated) precalc(); if (!precalculated) precalc();
@ -158,12 +160,14 @@ extern dsd2pcm_ctx* dsd2pcm_init()
return ptr; return ptr;
} }
extern void dsd2pcm_destroy(dsd2pcm_ctx* ptr) void
dsd2pcm_destroy(dsd2pcm_ctx *ptr) noexcept
{ {
free(ptr); free(ptr);
} }
extern dsd2pcm_ctx* dsd2pcm_clone(dsd2pcm_ctx* ptr) dsd2pcm_ctx *
dsd2pcm_clone(dsd2pcm_ctx *ptr) noexcept
{ {
dsd2pcm_ctx* p2; dsd2pcm_ctx* p2;
p2 = (dsd2pcm_ctx*) malloc(sizeof(dsd2pcm_ctx)); p2 = (dsd2pcm_ctx*) malloc(sizeof(dsd2pcm_ctx));
@ -173,7 +177,8 @@ extern dsd2pcm_ctx* dsd2pcm_clone(dsd2pcm_ctx* ptr)
return p2; return p2;
} }
extern void dsd2pcm_reset(dsd2pcm_ctx* ptr) void
dsd2pcm_reset(dsd2pcm_ctx *ptr) noexcept
{ {
int i; int i;
for (i=0; i<FIFOSIZE; ++i) for (i=0; i<FIFOSIZE; ++i)
@ -186,12 +191,12 @@ extern void dsd2pcm_reset(dsd2pcm_ctx* ptr)
*/ */
} }
extern void dsd2pcm_translate( void
dsd2pcm_ctx* ptr, dsd2pcm_translate(dsd2pcm_ctx *ptr,
size_t samples, size_t samples,
const unsigned char *src, ptrdiff_t src_stride, const unsigned char *src, ptrdiff_t src_stride,
int lsbf, int lsbf,
float *dst, ptrdiff_t dst_stride) float *dst, ptrdiff_t dst_stride) noexcept
{ {
unsigned ffp; unsigned ffp;
unsigned i; unsigned i;

View File

@ -45,24 +45,28 @@ typedef struct dsd2pcm_ctx_s dsd2pcm_ctx;
* POSIX thread-safety definition because it modifies global state * POSIX thread-safety definition because it modifies global state
* (lookup tables are computed during the first call) * (lookup tables are computed during the first call)
*/ */
extern dsd2pcm_ctx* dsd2pcm_init(); dsd2pcm_ctx *
dsd2pcm_init() noexcept;
/** /**
* deinitializes a "dsd2pcm engine" * deinitializes a "dsd2pcm engine"
* (releases memory, don't forget!) * (releases memory, don't forget!)
*/ */
extern void dsd2pcm_destroy(dsd2pcm_ctx *ctx); void
dsd2pcm_destroy(dsd2pcm_ctx *ctx) noexcept;
/** /**
* clones the context and returns a pointer to the * clones the context and returns a pointer to the
* newly allocated copy * newly allocated copy
*/ */
extern dsd2pcm_ctx* dsd2pcm_clone(dsd2pcm_ctx *ctx); dsd2pcm_ctx *
dsd2pcm_clone(dsd2pcm_ctx *ctx) noexcept;
/** /**
* resets the internal state for a fresh new stream * resets the internal state for a fresh new stream
*/ */
extern void dsd2pcm_reset(dsd2pcm_ctx *ctx); void
dsd2pcm_reset(dsd2pcm_ctx *ctx) noexcept;
/** /**
* "translates" a stream of octets to a stream of floats * "translates" a stream of octets to a stream of floats
@ -75,11 +79,12 @@ extern void dsd2pcm_reset(dsd2pcm_ctx *ctx);
* @param dst -- pointer to first float (output) * @param dst -- pointer to first float (output)
* @param dst_stride -- dst pointer increment * @param dst_stride -- dst pointer increment
*/ */
extern void dsd2pcm_translate(dsd2pcm_ctx *ctx, void
dsd2pcm_translate(dsd2pcm_ctx *ctx,
size_t samples, size_t samples,
const unsigned char *src, ptrdiff_t src_stride, const unsigned char *src, ptrdiff_t src_stride,
int lsbitfirst, int lsbitfirst,
float *dst, ptrdiff_t dst_stride); float *dst, ptrdiff_t dst_stride) noexcept;
#endif /* include guard DSD2PCM_H_INCLUDED */ #endif /* include guard DSD2PCM_H_INCLUDED */