pcm/Normalizer: add `noexcept`

This commit is contained in:
Max Kellermann 2023-03-13 12:01:21 +01:00
parent 2d7068a09d
commit 984c9c317a
2 changed files with 23 additions and 12 deletions

View File

@ -33,7 +33,8 @@ struct Compressor {
unsigned int bufsz; unsigned int bufsz;
}; };
struct Compressor *Compressor_new(unsigned int history) struct Compressor *
Compressor_new(unsigned int history) noexcept
{ {
Compressor *obj = (Compressor *)malloc(sizeof(struct Compressor)); Compressor *obj = (Compressor *)malloc(sizeof(struct Compressor));
if (obj == nullptr) if (obj == nullptr)
@ -53,7 +54,8 @@ struct Compressor *Compressor_new(unsigned int history)
return obj; return obj;
} }
void Compressor_delete(struct Compressor *obj) void
Compressor_delete(struct Compressor *obj) noexcept
{ {
if (obj->peaks) if (obj->peaks)
free(obj->peaks); free(obj->peaks);
@ -64,7 +66,8 @@ void Compressor_delete(struct Compressor *obj)
free(obj); free(obj);
} }
static int *resizeArray(int *data, int newsz, int oldsz) static int *
resizeArray(int *data, int newsz, int oldsz) noexcept
{ {
data = (int *)realloc(data, newsz*sizeof(int)); data = (int *)realloc(data, newsz*sizeof(int));
if (data == nullptr) if (data == nullptr)
@ -76,7 +79,8 @@ static int *resizeArray(int *data, int newsz, int oldsz)
return data; return data;
} }
void Compressor_setHistory(struct Compressor *obj, unsigned int history) void
Compressor_setHistory(struct Compressor *obj, unsigned int history) noexcept
{ {
if (!history) if (!history)
history = BUCKETS; history = BUCKETS;
@ -87,13 +91,15 @@ void Compressor_setHistory(struct Compressor *obj, unsigned int history)
obj->bufsz = history; obj->bufsz = history;
} }
struct CompressorConfig *Compressor_getConfig(struct Compressor *obj) struct CompressorConfig *
Compressor_getConfig(struct Compressor *obj) noexcept
{ {
return &obj->prefs; return &obj->prefs;
} }
void Compressor_Process_int16(struct Compressor *obj, int16_t *audio, void
unsigned int count) Compressor_Process_int16(struct Compressor *obj, int16_t *audio,
unsigned int count) noexcept
{ {
struct CompressorConfig *prefs = Compressor_getConfig(obj); struct CompressorConfig *prefs = Compressor_getConfig(obj);
int16_t *ap; int16_t *ap;

View File

@ -16,19 +16,24 @@ struct CompressorConfig {
struct Compressor; struct Compressor;
//! Create a new compressor (use history value of 0 for default) //! Create a new compressor (use history value of 0 for default)
struct Compressor *Compressor_new(unsigned int history); struct Compressor *
Compressor_new(unsigned int history) noexcept;
//! Delete a compressor //! Delete a compressor
void Compressor_delete(struct Compressor *); void
Compressor_delete(struct Compressor *) noexcept;
//! Set the history length //! Set the history length
void Compressor_setHistory(struct Compressor *, unsigned int history); void
Compressor_setHistory(struct Compressor *, unsigned int history) noexcept;
//! Get the configuration for a compressor //! Get the configuration for a compressor
struct CompressorConfig *Compressor_getConfig(struct Compressor *); struct CompressorConfig *
Compressor_getConfig(struct Compressor *) noexcept;
//! Process 16-bit signed data //! Process 16-bit signed data
void Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count); void
Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count) noexcept;
//! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed //! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed