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

View File

@ -45,24 +45,28 @@ typedef struct dsd2pcm_ctx_s dsd2pcm_ctx;
* POSIX thread-safety definition because it modifies global state
* (lookup tables are computed during the first call)
*/
extern dsd2pcm_ctx* dsd2pcm_init();
dsd2pcm_ctx *
dsd2pcm_init() noexcept;
/**
* deinitializes a "dsd2pcm engine"
* (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
* 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
*/
extern void dsd2pcm_reset(dsd2pcm_ctx *ctx);
void
dsd2pcm_reset(dsd2pcm_ctx *ctx) noexcept;
/**
* "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_stride -- dst pointer increment
*/
extern void dsd2pcm_translate(dsd2pcm_ctx *ctx,
size_t samples,
const unsigned char *src, ptrdiff_t src_stride,
int lsbitfirst,
float *dst, ptrdiff_t dst_stride);
void
dsd2pcm_translate(dsd2pcm_ctx *ctx,
size_t samples,
const unsigned char *src, ptrdiff_t src_stride,
int lsbitfirst,
float *dst, ptrdiff_t dst_stride) noexcept;
#endif /* include guard DSD2PCM_H_INCLUDED */