From 1b175025fecb1c10e6719d4ab79c188d473fccc4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 31 Jan 2013 20:33:26 +0100 Subject: [PATCH] pcm_*: convert to C++ --- Makefile.am | 14 ++-- src/MixerAll.cxx | 2 +- src/OutputThread.cxx | 2 +- src/{pcm_channels.c => PcmChannels.cxx} | 22 +++--- src/{pcm_channels.h => PcmChannels.hxx} | 6 +- src/PcmConvert.cxx | 8 +-- src/PcmConvert.hxx | 3 +- src/{pcm_dither.c => PcmDither.cxx} | 6 +- src/{pcm_dither.h => PcmDither.hxx} | 6 +- src/{pcm_format.c => PcmFormat.cxx} | 92 +++++++++++++++---------- src/{pcm_format.h => PcmFormat.hxx} | 6 +- src/{pcm_mix.c => PcmMix.cxx} | 17 ++--- src/{pcm_mix.h => PcmMix.hxx} | 7 +- src/{pcm_prng.h => PcmPrng.hxx} | 6 +- src/{pcm_utils.h => PcmUtils.hxx} | 7 +- src/{pcm_volume.c => PcmVolume.cxx} | 18 +++-- src/{pcm_volume.h => PcmVolume.hxx} | 16 ++--- src/filter/ReplayGainFilterPlugin.cxx | 2 +- src/filter/VolumeFilterPlugin.cxx | 2 +- src/mixer/SoftwareMixerPlugin.cxx | 2 +- test/read_mixer.cxx | 2 +- test/run_filter.cxx | 2 +- test/software_volume.cxx | 2 +- test/test_pcm_channels.cxx | 4 +- test/test_pcm_dither.cxx | 5 +- test/test_pcm_volume.cxx | 2 +- 26 files changed, 132 insertions(+), 129 deletions(-) rename src/{pcm_channels.c => PcmChannels.cxx} (92%) rename src/{pcm_channels.h => PcmChannels.hxx} (96%) rename src/{pcm_dither.c => PcmDither.cxx} (95%) rename src/{pcm_dither.h => PcmDither.hxx} (91%) rename src/{pcm_format.c => PcmFormat.cxx} (82%) rename src/{pcm_format.h => PcmFormat.hxx} (96%) rename src/{pcm_mix.c => PcmMix.cxx} (96%) rename src/{pcm_mix.h => PcmMix.hxx} (93%) rename src/{pcm_prng.h => PcmPrng.hxx} (89%) rename src/{pcm_utils.h => PcmUtils.hxx} (94%) rename src/{pcm_volume.c => PcmVolume.cxx} (90%) rename src/{pcm_volume.h => PcmVolume.hxx} (91%) diff --git a/Makefile.am b/Makefile.am index 37b3699ab..bf2f40666 100644 --- a/Makefile.am +++ b/Makefile.am @@ -333,17 +333,17 @@ libpcm_a_SOURCES = \ src/dsd2pcm/dsd2pcm.c src/dsd2pcm/dsd2pcm.h \ src/pcm_dsd.c src/pcm_dsd.h \ src/pcm_dsd_usb.c src/pcm_dsd_usb.h \ - src/pcm_volume.c src/pcm_volume.h \ - src/pcm_mix.c src/pcm_mix.h \ - src/pcm_channels.c src/pcm_channels.h \ + src/PcmVolume.cxx src/PcmVolume.hxx \ + src/PcmMix.cxx src/PcmMix.hxx \ + src/PcmChannels.cxx src/PcmChannels.hxx \ src/pcm_pack.c src/pcm_pack.h \ - src/pcm_format.c src/pcm_format.h \ + src/PcmFormat.cxx src/PcmFormat.hxx \ src/pcm_resample.c src/pcm_resample.h \ src/pcm_resample_fallback.c \ src/pcm_resample_internal.h \ - src/pcm_dither.c src/pcm_dither.h \ - src/pcm_prng.h \ - src/pcm_utils.h + src/PcmDither.cxx src/PcmDither.hxx \ + src/PcmPrng.hxx \ + src/PcmUtils.hxx libpcm_a_CPPFLAGS = $(AM_CPPFLAGS) \ $(SAMPLERATE_CFLAGS) diff --git a/src/MixerAll.cxx b/src/MixerAll.cxx index a214c1e24..b38005520 100644 --- a/src/MixerAll.cxx +++ b/src/MixerAll.cxx @@ -19,8 +19,8 @@ #include "config.h" #include "MixerAll.hxx" -#include "pcm_volume.h" #include "OutputAll.hxx" +#include "PcmVolume.hxx" extern "C" { #include "mixer_control.h" diff --git a/src/OutputThread.cxx b/src/OutputThread.cxx index fbbab98ea..c7b01d957 100644 --- a/src/OutputThread.cxx +++ b/src/OutputThread.cxx @@ -20,10 +20,10 @@ #include "config.h" #include "OutputThread.hxx" #include "output_api.h" +#include "PcmMix.hxx" extern "C" { #include "output_internal.h" -#include "pcm_mix.h" #include "filter_plugin.h" } diff --git a/src/pcm_channels.c b/src/PcmChannels.cxx similarity index 92% rename from src/pcm_channels.c rename to src/PcmChannels.cxx index 9d166a437..3b100e46f 100644 --- a/src/pcm_channels.c +++ b/src/PcmChannels.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,9 +18,9 @@ */ #include "config.h" -#include "pcm_channels.h" +#include "PcmChannels.hxx" #include "pcm_buffer.h" -#include "pcm_utils.h" +#include "PcmUtils.hxx" #include @@ -84,7 +84,7 @@ pcm_convert_channels_16(struct pcm_buffer *buffer, size_t dest_size = src_size / src_channels * dest_channels; *dest_size_r = dest_size; - int16_t *dest = pcm_buffer_get(buffer, dest_size); + int16_t *dest = (int16_t *)pcm_buffer_get(buffer, dest_size); const int16_t *src_end = pcm_end_pointer(src, src_size); if (src_channels == 1 && dest_channels == 2) @@ -160,8 +160,9 @@ pcm_convert_channels_24(struct pcm_buffer *buffer, size_t dest_size = src_size / src_channels * dest_channels; *dest_size_r = dest_size; - int32_t *dest = pcm_buffer_get(buffer, dest_size); - const int32_t *src_end = pcm_end_pointer(src, src_size); + int32_t *dest = (int32_t *)pcm_buffer_get(buffer, dest_size); + const int32_t *src_end = (const int32_t *) + pcm_end_pointer(src, src_size); if (src_channels == 1 && dest_channels == 2) pcm_convert_channels_24_1_to_2(dest, src, src_end); @@ -229,8 +230,9 @@ pcm_convert_channels_32(struct pcm_buffer *buffer, size_t dest_size = src_size / src_channels * dest_channels; *dest_size_r = dest_size; - int32_t *dest = pcm_buffer_get(buffer, dest_size); - const int32_t *src_end = pcm_end_pointer(src, src_size); + int32_t *dest = (int32_t *)pcm_buffer_get(buffer, dest_size); + const int32_t *src_end = (const int32_t *) + pcm_end_pointer(src, src_size); if (src_channels == 1 && dest_channels == 2) pcm_convert_channels_32_1_to_2(dest, src, src_end); @@ -300,8 +302,8 @@ pcm_convert_channels_float(struct pcm_buffer *buffer, size_t dest_size = src_size / src_channels * dest_channels; *dest_size_r = dest_size; - float *dest = pcm_buffer_get(buffer, dest_size); - const float *src_end = pcm_end_pointer(src, src_size); + float *dest = (float *)pcm_buffer_get(buffer, dest_size); + const float *src_end = (const float *)pcm_end_pointer(src, src_size); if (src_channels == 1 && dest_channels == 2) pcm_convert_channels_float_1_to_2(dest, src, src_end); diff --git a/src/pcm_channels.h b/src/PcmChannels.hxx similarity index 96% rename from src/pcm_channels.h rename to src/PcmChannels.hxx index 6da00316d..ede49cd81 100644 --- a/src/pcm_channels.h +++ b/src/PcmChannels.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPD_PCM_CHANNELS_H -#define MPD_PCM_CHANNELS_H +#ifndef MPD_PCM_CHANNELS_HXX +#define MPD_PCM_CHANNELS_HXX #include #include diff --git a/src/PcmConvert.cxx b/src/PcmConvert.cxx index 175584c83..ed260d074 100644 --- a/src/PcmConvert.cxx +++ b/src/PcmConvert.cxx @@ -19,12 +19,8 @@ #include "config.h" #include "PcmConvert.hxx" - -extern "C" { -#include "pcm_channels.h" -#include "pcm_format.h" -} - +#include "PcmChannels.hxx" +#include "PcmFormat.hxx" #include "pcm_pack.h" #include "audio_format.h" diff --git a/src/PcmConvert.hxx b/src/PcmConvert.hxx index bec30af45..d76ecc125 100644 --- a/src/PcmConvert.hxx +++ b/src/PcmConvert.hxx @@ -20,10 +20,11 @@ #ifndef PCM_CONVERT_HXX #define PCM_CONVERT_HXX +#include "PcmDither.hxx" + extern "C" { #include "pcm_dsd.h" #include "pcm_resample.h" -#include "pcm_dither.h" #include "pcm_buffer.h" } diff --git a/src/pcm_dither.c b/src/PcmDither.cxx similarity index 95% rename from src/pcm_dither.c rename to src/PcmDither.cxx index 4811946c8..e18119082 100644 --- a/src/pcm_dither.c +++ b/src/PcmDither.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,8 +18,8 @@ */ #include "config.h" -#include "pcm_dither.h" -#include "pcm_prng.h" +#include "PcmDither.hxx" +#include "PcmPrng.hxx" static int16_t pcm_dither_sample_24_to_16(int32_t sample, struct pcm_dither *dither) diff --git a/src/pcm_dither.h b/src/PcmDither.hxx similarity index 91% rename from src/pcm_dither.h rename to src/PcmDither.hxx index 046dea21e..59affa088 100644 --- a/src/pcm_dither.h +++ b/src/PcmDither.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPD_PCM_DITHER_H -#define MPD_PCM_DITHER_H +#ifndef MPD_PCM_DITHER_HXX +#define MPD_PCM_DITHER_HXX #include diff --git a/src/pcm_format.c b/src/PcmFormat.cxx similarity index 82% rename from src/pcm_format.c rename to src/PcmFormat.cxx index d3ea3acb0..cf601684a 100644 --- a/src/pcm_format.c +++ b/src/PcmFormat.cxx @@ -18,11 +18,11 @@ */ #include "config.h" -#include "pcm_format.h" -#include "pcm_dither.h" +#include "PcmFormat.hxx" +#include "PcmDither.hxx" #include "pcm_buffer.h" #include "pcm_pack.h" -#include "pcm_utils.h" +#include "PcmUtils.hxx" static void pcm_convert_8_to_16(int16_t *out, const int8_t *in, const int8_t *in_end) @@ -64,7 +64,7 @@ pcm_allocate_8_to_16(struct pcm_buffer *buffer, { int16_t *dest; *dest_size_r = src_size / sizeof(*src) * sizeof(*dest); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_8_to_16(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -77,7 +77,7 @@ pcm_allocate_24p32_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither, int16_t *dest; *dest_size_r = src_size / 2; assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_24_to_16(dither, dest, src, pcm_end_pointer(src, src_size)); return dest; @@ -91,7 +91,7 @@ pcm_allocate_32_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither, int16_t *dest; *dest_size_r = src_size / 2; assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_32_to_16(dither, dest, src, pcm_end_pointer(src, src_size)); return dest; @@ -105,7 +105,7 @@ pcm_allocate_float_to_16(struct pcm_buffer *buffer, int16_t *dest; *dest_size_r = src_size / 2; assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_float_to_16(dest, src, pcm_end_pointer(src, src_size)); return dest; @@ -125,22 +125,26 @@ pcm_convert_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither, case SAMPLE_FORMAT_S8: return pcm_allocate_8_to_16(buffer, - src, src_size, dest_size_r); + (const int8_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_S16: *dest_size_r = src_size; - return src; + return (const int16_t *)src; case SAMPLE_FORMAT_S24_P32: - return pcm_allocate_24p32_to_16(buffer, dither, src, src_size, + return pcm_allocate_24p32_to_16(buffer, dither, + (const int32_t *)src, src_size, dest_size_r); case SAMPLE_FORMAT_S32: - return pcm_allocate_32_to_16(buffer, dither, src, src_size, + return pcm_allocate_32_to_16(buffer, dither, + (const int32_t *)src, src_size, dest_size_r); case SAMPLE_FORMAT_FLOAT: - return pcm_allocate_float_to_16(buffer, src, src_size, + return pcm_allocate_float_to_16(buffer, + (const float *)src, src_size, dest_size_r); } @@ -188,7 +192,7 @@ pcm_allocate_8_to_24(struct pcm_buffer *buffer, { int32_t *dest; *dest_size_r = src_size / sizeof(*src) * sizeof(*dest); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_8_to_24(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -200,7 +204,7 @@ pcm_allocate_16_to_24(struct pcm_buffer *buffer, int32_t *dest; *dest_size_r = src_size * 2; assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_16_to_24(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -210,7 +214,7 @@ pcm_allocate_32_to_24(struct pcm_buffer *buffer, const int32_t *src, size_t src_size, size_t *dest_size_r) { *dest_size_r = src_size; - int32_t *dest = pcm_buffer_get(buffer, *dest_size_r); + int32_t *dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_32_to_24(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -221,7 +225,7 @@ pcm_allocate_float_to_24(struct pcm_buffer *buffer, size_t *dest_size_r) { *dest_size_r = src_size; - int32_t *dest = pcm_buffer_get(buffer, *dest_size_r); + int32_t *dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_float_to_24(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -240,22 +244,26 @@ pcm_convert_to_24(struct pcm_buffer *buffer, case SAMPLE_FORMAT_S8: return pcm_allocate_8_to_24(buffer, - src, src_size, dest_size_r); + (const int8_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_S16: return pcm_allocate_16_to_24(buffer, - src, src_size, dest_size_r); + (const int16_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_S24_P32: *dest_size_r = src_size; - return src; + return (const int32_t *)src; case SAMPLE_FORMAT_S32: - return pcm_allocate_32_to_24(buffer, src, src_size, + return pcm_allocate_32_to_24(buffer, + (const int32_t *)src, src_size, dest_size_r); case SAMPLE_FORMAT_FLOAT: - return pcm_allocate_float_to_24(buffer, src, src_size, + return pcm_allocate_float_to_24(buffer, + (const float *)src, src_size, dest_size_r); } @@ -291,7 +299,7 @@ pcm_allocate_8_to_32(struct pcm_buffer *buffer, { int32_t *dest; *dest_size_r = src_size / sizeof(*src) * sizeof(*dest); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_8_to_32(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -303,7 +311,7 @@ pcm_allocate_16_to_32(struct pcm_buffer *buffer, int32_t *dest; *dest_size_r = src_size * 2; assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_16_to_32(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -314,7 +322,7 @@ pcm_allocate_24p32_to_32(struct pcm_buffer *buffer, size_t *dest_size_r) { *dest_size_r = src_size; - int32_t *dest = pcm_buffer_get(buffer, *dest_size_r); + int32_t *dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_24_to_32(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -346,23 +354,27 @@ pcm_convert_to_32(struct pcm_buffer *buffer, break; case SAMPLE_FORMAT_S8: - return pcm_allocate_8_to_32(buffer, src, src_size, + return pcm_allocate_8_to_32(buffer, + (const int8_t *)src, src_size, dest_size_r); case SAMPLE_FORMAT_S16: - return pcm_allocate_16_to_32(buffer, src, src_size, + return pcm_allocate_16_to_32(buffer, + (const int16_t *)src, src_size, dest_size_r); case SAMPLE_FORMAT_S24_P32: - return pcm_allocate_24p32_to_32(buffer, src, src_size, + return pcm_allocate_24p32_to_32(buffer, + (const int32_t *)src, src_size, dest_size_r); case SAMPLE_FORMAT_S32: *dest_size_r = src_size; - return src; + return (const int32_t *)src; case SAMPLE_FORMAT_FLOAT: - return pcm_allocate_float_to_32(buffer, src, src_size, + return pcm_allocate_float_to_32(buffer, + (const float *)src, src_size, dest_size_r); } @@ -412,7 +424,7 @@ pcm_allocate_8_to_float(struct pcm_buffer *buffer, { float *dest; *dest_size_r = src_size / sizeof(*src) * sizeof(*dest); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (float *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_8_to_float(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -425,7 +437,7 @@ pcm_allocate_16_to_float(struct pcm_buffer *buffer, float *dest; *dest_size_r = src_size * 2; assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); - dest = pcm_buffer_get(buffer, *dest_size_r); + dest = (float *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_16_to_float(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -436,7 +448,7 @@ pcm_allocate_24p32_to_float(struct pcm_buffer *buffer, size_t *dest_size_r) { *dest_size_r = src_size; - float *dest = pcm_buffer_get(buffer, *dest_size_r); + float *dest = (float *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_24_to_float(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -447,7 +459,7 @@ pcm_allocate_32_to_float(struct pcm_buffer *buffer, size_t *dest_size_r) { *dest_size_r = src_size; - float *dest = pcm_buffer_get(buffer, *dest_size_r); + float *dest = (float *)pcm_buffer_get(buffer, *dest_size_r); pcm_convert_32_to_float(dest, src, pcm_end_pointer(src, src_size)); return dest; } @@ -464,23 +476,27 @@ pcm_convert_to_float(struct pcm_buffer *buffer, case SAMPLE_FORMAT_S8: return pcm_allocate_8_to_float(buffer, - src, src_size, dest_size_r); + (const int8_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_S16: return pcm_allocate_16_to_float(buffer, - src, src_size, dest_size_r); + (const int16_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_S24_P32: return pcm_allocate_24p32_to_float(buffer, - src, src_size, dest_size_r); + (const int32_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_S32: return pcm_allocate_32_to_float(buffer, - src, src_size, dest_size_r); + (const int32_t *)src, src_size, + dest_size_r); case SAMPLE_FORMAT_FLOAT: *dest_size_r = src_size; - return src; + return (const float *)src; } return NULL; diff --git a/src/pcm_format.h b/src/PcmFormat.hxx similarity index 96% rename from src/pcm_format.h rename to src/PcmFormat.hxx index 48bcd0662..d739f60d1 100644 --- a/src/pcm_format.h +++ b/src/PcmFormat.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef PCM_FORMAT_H -#define PCM_FORMAT_H +#ifndef MPD_PCM_FORMAT_HXX +#define MPD_PCM_FORMAT_HXX #include "audio_format.h" diff --git a/src/pcm_mix.c b/src/PcmMix.cxx similarity index 96% rename from src/pcm_mix.c rename to src/PcmMix.cxx index 6c6d1b4ab..4f8f3882c 100644 --- a/src/pcm_mix.c +++ b/src/PcmMix.cxx @@ -18,18 +18,13 @@ */ #include "config.h" -#include "pcm_mix.h" -#include "pcm_volume.h" -#include "pcm_utils.h" +#include "PcmMix.hxx" +#include "PcmVolume.hxx" +#include "PcmUtils.hxx" #include "audio_format.h" -#include - #include -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "pcm" - static void pcm_add_vol_8(int8_t *buffer1, const int8_t *buffer2, unsigned num_samples, int volume1, int volume2) @@ -144,7 +139,8 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size, return true; case SAMPLE_FORMAT_FLOAT: - pcm_add_vol_float(buffer1, buffer2, size / 4, + pcm_add_vol_float((float *)buffer1, (const float *)buffer2, + size / 4, pcm_volume_to_float(vol1), pcm_volume_to_float(vol2)); return true; @@ -249,7 +245,8 @@ pcm_add(void *buffer1, const void *buffer2, size_t size, return true; case SAMPLE_FORMAT_FLOAT: - pcm_add_float(buffer1, buffer2, size / 4); + pcm_add_float((float *)buffer1, (const float *)buffer2, + size / 4); return true; } diff --git a/src/pcm_mix.h b/src/PcmMix.hxx similarity index 93% rename from src/pcm_mix.h rename to src/PcmMix.hxx index 0cf557680..bb7110d04 100644 --- a/src/pcm_mix.h +++ b/src/PcmMix.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,13 +17,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef PCM_MIX_H -#define PCM_MIX_H +#ifndef MPD_PCM_MIX_HXX +#define MPD_PCM_MIX_HXX #include "audio_format.h" #include "gcc.h" -#include #include /* diff --git a/src/pcm_prng.h b/src/PcmPrng.hxx similarity index 89% rename from src/pcm_prng.h rename to src/PcmPrng.hxx index 457ba4b66..0c823250d 100644 --- a/src/pcm_prng.h +++ b/src/PcmPrng.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef PCM_PRNG_H -#define PCM_PRNG_H +#ifndef MPD_PCM_PRNG_HXX +#define MPD_PCM_PRNG_HXX /** * A very simple linear congruential PRNG. It's good enough for PCM diff --git a/src/pcm_utils.h b/src/PcmUtils.hxx similarity index 94% rename from src/pcm_utils.h rename to src/PcmUtils.hxx index 21df95e48..a95af7e68 100644 --- a/src/pcm_utils.h +++ b/src/PcmUtils.hxx @@ -29,10 +29,11 @@ * function to convert a source pointer and a byte count to an "end" * pointer for use in loops. */ -static inline const void * -pcm_end_pointer(const void *p, size_t size) +template +static inline const T * +pcm_end_pointer(const T *p, size_t size) { - return (const char *)p + size; + return (const T *)((const uint8_t *)p + size); } /** diff --git a/src/pcm_volume.c b/src/PcmVolume.cxx similarity index 90% rename from src/pcm_volume.c rename to src/PcmVolume.cxx index 49c86026f..e19469f4a 100644 --- a/src/pcm_volume.c +++ b/src/PcmVolume.cxx @@ -18,8 +18,8 @@ */ #include "config.h" -#include "pcm_volume.h" -#include "pcm_utils.h" +#include "PcmVolume.hxx" +#include "PcmUtils.hxx" #include "audio_format.h" #include @@ -163,23 +163,27 @@ pcm_volume(void *buffer, size_t length, return false; case SAMPLE_FORMAT_S8: - pcm_volume_change_8(buffer, end, volume); + pcm_volume_change_8((int8_t *)buffer, (const int8_t *)end, + volume); return true; case SAMPLE_FORMAT_S16: - pcm_volume_change_16(buffer, end, volume); + pcm_volume_change_16((int16_t *)buffer, (const int16_t *)end, + volume); return true; case SAMPLE_FORMAT_S24_P32: - pcm_volume_change_24(buffer, end, volume); + pcm_volume_change_24((int32_t *)buffer, (const int32_t *)end, + volume); return true; case SAMPLE_FORMAT_S32: - pcm_volume_change_32(buffer, end, volume); + pcm_volume_change_32((int32_t *)buffer, (const int32_t *)end, + volume); return true; case SAMPLE_FORMAT_FLOAT: - pcm_volume_change_float(buffer, end, + pcm_volume_change_float((float *)buffer, (const float *)end, pcm_volume_to_float(volume)); return true; } diff --git a/src/pcm_volume.h b/src/PcmVolume.hxx similarity index 91% rename from src/pcm_volume.h rename to src/PcmVolume.hxx index c161a72c7..d3e6a5536 100644 --- a/src/pcm_volume.h +++ b/src/PcmVolume.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,10 +17,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef PCM_VOLUME_H -#define PCM_VOLUME_H +#ifndef MPD_PCM_VOLUME_HXX +#define MPD_PCM_VOLUME_HXX -#include "pcm_prng.h" +#include "PcmPrng.hxx" #include "audio_format.h" #include @@ -65,10 +65,6 @@ pcm_volume_dither(void) return (r & 511) - ((r >> 9) & 511); } -#ifdef __cplusplus -extern "C" { -#endif - /** * Adjust the volume of the specified PCM buffer. * @@ -83,8 +79,4 @@ pcm_volume(void *buffer, size_t length, enum sample_format format, int volume); -#ifdef __cplusplus -} -#endif - #endif diff --git a/src/filter/ReplayGainFilterPlugin.cxx b/src/filter/ReplayGainFilterPlugin.cxx index f4b1f92ee..9fb412be7 100644 --- a/src/filter/ReplayGainFilterPlugin.cxx +++ b/src/filter/ReplayGainFilterPlugin.cxx @@ -26,10 +26,10 @@ #include "replay_gain_info.h" #include "replay_gain_config.h" #include "mixer_control.h" +#include "PcmVolume.hxx" extern "C" { #include "pcm_buffer.h" -#include "pcm_volume.h" } #include diff --git a/src/filter/VolumeFilterPlugin.cxx b/src/filter/VolumeFilterPlugin.cxx index 764d2453f..5066ebbfa 100644 --- a/src/filter/VolumeFilterPlugin.cxx +++ b/src/filter/VolumeFilterPlugin.cxx @@ -24,7 +24,7 @@ #include "filter_registry.h" #include "conf.h" #include "pcm_buffer.h" -#include "pcm_volume.h" +#include "PcmVolume.hxx" #include "audio_format.h" #include diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx index 45f564c9d..c06ce18ea 100644 --- a/src/mixer/SoftwareMixerPlugin.cxx +++ b/src/mixer/SoftwareMixerPlugin.cxx @@ -23,7 +23,7 @@ #include "filter_plugin.h" #include "filter_registry.h" #include "filter/VolumeFilterPlugin.hxx" -#include "pcm_volume.h" +#include "PcmVolume.hxx" #include #include diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx index 799bbefd5..d0426c9a9 100644 --- a/test/read_mixer.cxx +++ b/test/read_mixer.cxx @@ -25,7 +25,7 @@ extern "C" { #include "filter_registry.h" } -#include "pcm_volume.h" +#include "PcmVolume.hxx" #include "GlobalEvents.hxx" #include "Main.hxx" #include "event/Loop.hxx" diff --git a/test/run_filter.cxx b/test/run_filter.cxx index 87672adc5..2d53ed496 100644 --- a/test/run_filter.cxx +++ b/test/run_filter.cxx @@ -23,7 +23,7 @@ #include "AudioParser.hxx" #include "audio_format.h" #include "filter_plugin.h" -#include "pcm_volume.h" +#include "PcmVolume.hxx" #include "mixer_control.h" #include "stdbin.h" diff --git a/test/software_volume.cxx b/test/software_volume.cxx index 2579a4f0b..929932398 100644 --- a/test/software_volume.cxx +++ b/test/software_volume.cxx @@ -24,7 +24,7 @@ */ #include "config.h" -#include "pcm_volume.h" +#include "PcmVolume.hxx" #include "AudioParser.hxx" #include "audio_format.h" #include "stdbin.h" diff --git a/test/test_pcm_channels.cxx b/test/test_pcm_channels.cxx index 66f4bc63c..38d030519 100644 --- a/test/test_pcm_channels.cxx +++ b/test/test_pcm_channels.cxx @@ -19,9 +19,7 @@ #include "config.h" #include "test_pcm_all.hxx" -extern "C" { -#include "pcm_channels.h" -} +#include "PcmChannels.hxx" #include "pcm_buffer.h" #include diff --git a/test/test_pcm_dither.cxx b/test/test_pcm_dither.cxx index 47b94764d..44830746f 100644 --- a/test/test_pcm_dither.cxx +++ b/test/test_pcm_dither.cxx @@ -18,10 +18,7 @@ */ #include "test_pcm_all.hxx" - -extern "C" { -#include "pcm_dither.h" -} +#include "PcmDither.hxx" #include diff --git a/test/test_pcm_volume.cxx b/test/test_pcm_volume.cxx index ab8444411..4ec76e79c 100644 --- a/test/test_pcm_volume.cxx +++ b/test/test_pcm_volume.cxx @@ -18,7 +18,7 @@ */ #include "test_pcm_all.hxx" -#include "pcm_volume.h" +#include "PcmVolume.hxx" #include