diff --git a/src/filter/plugins/NormalizeFilterPlugin.cxx b/src/filter/plugins/NormalizeFilterPlugin.cxx index f6db758ee..2b501fb5c 100644 --- a/src/filter/plugins/NormalizeFilterPlugin.cxx +++ b/src/filter/plugins/NormalizeFilterPlugin.cxx @@ -7,7 +7,7 @@ #include "filter/Prepared.hxx" #include "pcm/Buffer.hxx" #include "pcm/AudioFormat.hxx" -#include "pcm/AudioCompress/compress.h" +#include "pcm/Normalizer.hxx" #include diff --git a/src/pcm/AudioCompress/compress.c b/src/pcm/Normalizer.cxx similarity index 92% rename from src/pcm/AudioCompress/compress.c rename to src/pcm/Normalizer.cxx index e46e4a9a7..1dbf40d57 100644 --- a/src/pcm/AudioCompress/compress.c +++ b/src/pcm/Normalizer.cxx @@ -1,13 +1,14 @@ // SPDX-License-Identifier: LGPL-2.1 -// (c)2007 busybee (http://beesbuzz.biz/ +// Copyright The Music Player Daemon Project +// Based on AudioCompress (c)2007 busybee (http://beesbuzz.biz/ + +#include "Normalizer.hxx" #include #include #include #include -#include "compress.h" - /*** Default configuration stuff ***/ #define TARGET 16384 /*!< Target level (on a scale of 0-32767) */ @@ -34,8 +35,8 @@ struct Compressor { struct Compressor *Compressor_new(unsigned int history) { - struct Compressor *obj = malloc(sizeof(struct Compressor)); - if (obj == NULL) + Compressor *obj = (Compressor *)malloc(sizeof(struct Compressor)); + if (obj == nullptr) /* out of memory, not much we can do */ abort(); @@ -43,7 +44,7 @@ struct Compressor *Compressor_new(unsigned int history) obj->prefs.maxgain = GAINMAX; obj->prefs.smooth = GAINSMOOTH; - obj->peaks = obj->gain = obj->clipped = NULL; + obj->peaks = obj->gain = obj->clipped = nullptr; obj->bufsz = 0; obj->pos = 0; @@ -65,8 +66,8 @@ void Compressor_delete(struct Compressor *obj) static int *resizeArray(int *data, int newsz, int oldsz) { - data = realloc(data, newsz*sizeof(int)); - if (data == NULL) + data = (int *)realloc(data, newsz*sizeof(int)); + if (data == nullptr) /* out of memory, not much we can do */ abort(); diff --git a/src/pcm/AudioCompress/compress.h b/src/pcm/Normalizer.hxx similarity index 83% rename from src/pcm/AudioCompress/compress.h rename to src/pcm/Normalizer.hxx index 4144e5dac..2e0d14d56 100644 --- a/src/pcm/AudioCompress/compress.h +++ b/src/pcm/Normalizer.hxx @@ -1,10 +1,10 @@ // SPDX-License-Identifier: LGPL-2.1 -// (c)2007 busybee (http://beesbuzz.biz/ +// Copyright The Music Player Daemon Project +// Based on AudioCompress (c)2007 busybee (http://beesbuzz.biz/ -#ifndef COMPRESS_H -#define COMPRESS_H +#pragma once -#include +#include //! Configuration values for the compressor object struct CompressorConfig { @@ -15,10 +15,6 @@ struct CompressorConfig { struct Compressor; -#ifdef __cplusplus -extern "C" { -#endif - //! Create a new compressor (use history value of 0 for default) struct Compressor *Compressor_new(unsigned int history); @@ -34,12 +30,6 @@ struct CompressorConfig *Compressor_getConfig(struct Compressor *); //! Process 16-bit signed data void Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count); -#ifdef __cplusplus -} -#endif - //! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed //! TODO: functions for getting at the peak/gain/clip history buffers (for monitoring) - -#endif diff --git a/src/pcm/meson.build b/src/pcm/meson.build index 59d73d59e..0c769c4e7 100644 --- a/src/pcm/meson.build +++ b/src/pcm/meson.build @@ -47,7 +47,7 @@ pcm_sources = [ 'GlueResampler.cxx', 'FallbackResampler.cxx', 'ConfiguredResampler.cxx', - 'AudioCompress/compress.c', + 'Normalizer.cxx', 'ReplayGainAnalyzer.cxx', 'MixRampAnalyzer.cxx', 'MixRampGlue.cxx', diff --git a/test/run_normalize.cxx b/test/run_normalize.cxx index f70a6ea9e..4145a96d7 100644 --- a/test/run_normalize.cxx +++ b/test/run_normalize.cxx @@ -7,7 +7,7 @@ * */ -#include "pcm/AudioCompress/compress.h" +#include "pcm/Normalizer.hxx" #include "pcm/AudioParser.hxx" #include "pcm/AudioFormat.hxx" #include "util/PrintException.hxx"